Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a function *.m file that accepts a 2-dimensional array as a function inpu

ID: 3654725 • Letter: C

Question

Create a function *.m file that accepts a 2-dimensional array as a function input and has two function outputs. This function will use a nested loop to create one column vector that contains the sum of all the positive values in each row and another column vector that contains sum of all the negative numbers of each row. These two column vectors should be returned (sent back) to the function call. Here is the code I have so far function [ sumpos, sumneg ] = sums( A ) k=1; sumpos=0; sumneg=0; for k=1:numel(A) if A(k)>0 sumpos=sumpos+A(k); end for k=1:numel(A) if A(k)<0 sumneg=sumneg+A(k); end end end sumpos; sumneg; end

Explanation / Answer

function [ sumpos, sumneg ] = sums( A ) k=1; sumpos=0; sumneg=0; for k=1:length(A) for j=1:length(A) if A(k,j)>0 sumpos=sumpos+A(k,j); end if A(k,j)
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote