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++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -