How to sum same size cell blocks?
15 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Xiaohan Du
le 21 Déc 2016
Réponse apportée : John BG
le 22 Déc 2016
Hi all,
I have a cell which contains same size matrices, like this:
inpt =
[13x13 double] [13x13 double] [13x13 double] [13x13 double]
Is there a function to sum blocks within a cell? So the result would be a [13*13] matrix with elements of same entry summations of inpt.
Many thanks!
0 commentaires
Réponse acceptée
Guillaume
le 21 Déc 2016
sum(cat(3, inpt{:}), 3)
is one way to do it. Basically, concatenate your matrices along an extra dimension and sum along that dimension.
0 commentaires
Plus de réponses (1)
John BG
le 22 Déc 2016
Hi Xiaohan
first get the size of inpt
[sz1 sz2]=size(inpt)
and sum the cell2mat version of inpt
sum(reshape(cell2mat(inpt),13,13,sz2),3)
if you find my answer useful would you please mark it as Accepted Answer?
thanks in advance for time and attention
John BG
0 commentaires
Voir également
Catégories
En savoir plus sur Chebyshev dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!