How to Sum each nth Pages of a Three Dimensional Matrix?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
ehsan
le 27 Sep 2018
Commenté : Simbarashe Chidzambwa
le 23 Nov 2022
Hello all,
I have a matrix with the size of 21x23x246. I would like to sum all arrays of the first, second, third ... and 8th pages and then sum the ninth, 10th ... and 16th pages and so on. In other words, I would like to sum each 8th pages of the matrix.
In the end, I would have a matrix with the dimension of 21x23x31.
Thank you in advance.
0 commentaires
Réponse acceptée
Fangjun Jiang
le 27 Sep 2018
Modifié(e) : Fangjun Jiang
le 27 Sep 2018
the size of your original matrix, say A, needs to be 21x23x248, right?
sz=size(A)
B=reshape(A,sz(1),sz(2),8,[]);
squeeze(sum(B,3))
7 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices 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!