Write a function called halfsum that takes as input an at most two-dimensional matrix A and computes the sum of the elements of A that are in the diagonal or are to the right of it. example, the input is [1 2 3; 4 5 6; 7 8 9],the ans is 26
function s = halfsum(A)
[row col] = size(A);
if row ~= col
error(‘Expecting a square matrix here people…’);
end
s = 0;
for ii = 1:row
for jj = ii:col
s = s + A(ii,jj);
end
endfunction s = halfsum(A)
[row col] = size(A);
if row ~= col
error(‘Expecting a square matrix here people…’);
end
s = 0;
for ii = 1:row
for jj = ii:col
s = s + A(ii,jj);
end
end function s = halfsum(A)
[row col] = size(A);
if row ~= col
error(‘Expecting a square matrix here people…’);
end
s = 0;
for ii = 1:row
for jj = ii:col
s = s + A(ii,jj);
end
end homework, soft-lock, no more solutions please!!!!!!, make me cry MATLAB Answers — New Questions