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

2 ビュー (過去 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 Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by