MATLAB: Obtain SUM for a 3D matrix

3d matrixsum

Hi,
I have a precip matrix 360 x 280 x 365 and I want to obtain the sum for all the values in (:,:,365). For example,
output = sum(precip(360x280x1)+precip(360x280x2)+precip(360x280x3)..+precip(360x280x365)
So, the output matrix should be, output = 360 x 280. Can anyone suggest me a methos in MATLAB?
Thanks in advance.

Best Answer

output = sum(precip,3);