Loop Analysis If the MATLAB function LR Sum below receives t

Loop Analysis If the MATLAB function LR Sum below receives the given matrix A as input, determine what the function would return in ret. A =[1 2 3 4 5 6 7 8 9 10 11 12] Your analysis for this loop must be done by hand below-you must write-out your answers and you must verify and \"desk-check\" everything by hand below. As shown in lecture, you must write-out a table that contains each iteration number and the values of ii, jj, A (ii, j j ) and ret (ii) for each iteration of the nested loops. You should not use MATLAB for this problem, unless it is to check your hand-work after you\'ve finished. function [ret] = LR Sum(A) [m, n] = size (A); ret = zeros(m, 1); for ii = l:m for jj = l:ii ret(ii) = ret(ii) + A(ii, jj); end end end

Solution


Result:
1
11
30

ii jj A(ii,jj) ret(ii)
1 1 1 1
2 1 5 5
2 2 6 11
3 1 9 9
3 2 10 19
3 3 11 30
 Loop Analysis If the MATLAB function LR Sum below receives the given matrix A as input, determine what the function would return in ret. A =[1 2 3 4 5 6 7 8 9

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site