sum the elements in the cell array
3 ビュー (過去 30 日間)
古いコメントを表示
Gopalakrishnan venkatesan
2015 年 11 月 6 日
コメント済み: the cyclist
2015 年 11 月 6 日
a = { 1 2 3; 4 5 6; 7 8 9}
How to use the cellfun to sum the element row wise?
0 件のコメント
採用された回答
the cyclist
2015 年 11 月 6 日
Is there a specific reason you are using a cell array? This is easy with a numeric array:
a = [ 1 2 3; 4 5 6; 7 8 9 ];
sum(a,1) % Sum down columns
sum(a,2) % Sum across rows
2 件のコメント
the cyclist
2015 年 11 月 6 日
Well you have to tell MATLAB somehow that the content of the cell are a numeric variable that can be summed, otherwise it could try to sum the cell array
a = {'red','donald trump',-Inf}
If the data are already in a cell array, then I don't think there is a better way than cell2mat to do this conversion.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Cell Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!