matlab - Sum of a cell array along the column -


i have cell array <1x74 cell> , each element of cell matrix of 4 x 4. how sum have final matrix of 4 x 4. did in following manner:

total = in{1,1}+in{1,2}+in{1,3}+in{1,4}+in{1,5}+in{1,6}+in{1,7}+in{1,8}+in{1,9}+in{1,10}+.....in{1,74}; 

total = zeros(2,2);  i=1:size(in,2)     total = total+in{1,i}; end display('this result: ') total 

as mentioned in comments, if don't want define total in prior, this

for i=1:size(in,2)     if i~=1      total = total + in{1,i}; % executes numbers equal or larger 2     else     total = in{1,i}; %executes on i=1     end end 

Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -