In MATLABThe output should whatever is described in the ques
In MATLAB,The output should whatever is described in the question. Each function file must use a for loop in its calculations (even if that isn’t the most efficient way to do the calculation). The built-in function length may be helpful to you. Test each function with each of the following vectors: [1 2 3 4 5] [10 20 30 40 50] 5. Add up all the values of the elements and returns the sum. (You can check your answer with the builtin function sum).
Solution
function s = getsum(x)
 sz = size(x)(1,2);
 s = 0;
 for i = 1:sz
 s = s + x(1,i);
 end
 end
 x = [1,2,3,4,5];
 as = getsum(x);
 disp(as);
 disp(sum(x(:)));
 x = [10 20 30 40 50];
 as = getsum(x);
 disp(as);
 disp(sum(x(:)));

