Summing matrices in cell array
显示 更早的评论
I have a cell array A that is 9x1 with 9 cells that are all 1x38. I am trying to sum A (sum elements of the 9 cells). I have tried cell2mat,cellfun, sum(cat), and sum, but I keep getting errors with those. Any help is appreciated! Thanks!!
回答(1 个)
Azzi Abdelmalek
2016-6-10
编辑:Azzi Abdelmalek
2016-6-10
A={[1 2 3];[4 5 6];[7 8 9]}
out=cellfun(@sum,A)
If A is like this
A={{1 2 3};{4 5 6};{7 8 9}}
out=cellfun(@(x) sum(x{1}),A)
1 个评论
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!