Create a row vector which contains the sum of each column in a matrix of unknown dimensions – use the matrix shown below as your test data: [2 -5 6 7; -4 8 -5 6] Display the resulting row vector as follows: The sum of column 1 is -2.00 … The sum of column 4 is 13.00
A = [2 -5 6 7; -4 8 -5 6];
v = sum(A);
for i=1:length(v)
fprintf('The sum of column %d is %.2f\n', i, v(i));
end
Comments
Leave a comment