MATLAB: Is there a function to sum 1:n matrices of same size

matrix sum

I have,
n=user input
a=sum(matrix 1 to n)=element by element addition for matrices 1 to n to give a matrix of the same size.
I have tried a=sum(matrix{1:n}) with no luck.

Best Answer

Your notation suggests that your matrices are being held in a cell array matrix{i}, i=1...n. If I continue to assume this,
sum(cat(3,matrix{:}),3)
Related Question