Summing matrices in cell array
Show older comments
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!!
Answers (1)
Azzi Abdelmalek
on 10 Jun 2016
Edited: Azzi Abdelmalek
on 10 Jun 2016
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 Comment
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!