MATLAB: I am trying to implement this function so that it returns the sum of all the values in the m-by-n matrix A without using the buit in function sum

functionmatrix arraymatrix manipulation

function s = totalsum(A)
%A is an m-by-n matrix
%s is the sum of all the values in A
I dont know where to start.

Best Answer

t = cumsum(A(:));
s = t(end);