MATLAB: Hi, I want to know how to sum all the matrices in a loop at the end of it

MATLABsumming of matrices

I have a loop in which I define a matrix in each iteration. At the end of it I want to sum all of these matrices. Any help would be appreciated.

Best Answer

Data = zeros(5, 6, 7);
for k = 1:5
Data(k, :, :) = rand(6, 7);
end
Result = sum(Data, 1);
Related Question