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

조회 수: 1 (최근 30일)
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

채택된 답변

Alex Mcaulley
Alex Mcaulley 2019년 8월 5일
Being M your matrix:
sol = sum(sum(M,3),2)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by