MATLAB: Calculate sum of cell

sum

I have precipitation data for 1 month for 11 years. Each cell show the data of each year.
JUN =
1×11 cell array
Columns 1 through 4
[360×280 double] [360×280 double] [360×280 double] [360×280 double]
Columns 5 through 8
[360×280 double] [360×280 double] [360×280 double] [360×280 double]
Columns 9 through 11
[360×280 double] [360×280 double] [360×280 double]
and I want to calculate sum of all value in JUN, how can I do?

Best Answer

Choose which of the below suits you the best:
Jun=cat(3,JUN{:});
sum(Jun,3)
%or
squeeze(sum(sum(Jun))) % since 2018b it's just sum(Jun,[1,2])
squeeze(sum(Jun,1))
% ^ or 2