Find sum of individual matrix of a given array of matrices and store it in a temporary array

1 vue (au cours des 30 derniers jours)
Suppose M[l,m,n] an array of m*n matrices of size l, and then required to find sum of individual matix and store it in a temporary array .
eg: l=2 m=3 n=3
M[1,m,n]={{0,1,1},{0,0,0},{1,1,1}}=sum(M[1,m,n])=5
M[2,m,n]={{0,1,1},{0,1,0},{1,1,1}}=sum(M[2,m,n])=6
Finally,
store final sum values of each matrix in to a temporary array.
temp[1,l]={5,6}
That is,
temp[1,1]=5
temp[1,2]=6

Réponse acceptée

Alex Mcaulley
Alex Mcaulley le 5 Août 2019
Being M your matrix:
sol = sum(sum(M,3),2)

Plus de réponses (0)

Catégories

En savoir plus sur Multidimensional Arrays 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!

Translated by