Summing matrices in cell array
Afficher commentaires plus anciens
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!!
Réponses (1)
Azzi Abdelmalek
le 10 Juin 2016
Modifié(e) : Azzi Abdelmalek
le 10 Juin 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 commentaire
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!