how to find the sum of matrix?

hello, I have a loop as results of K = 1:19, a matrix A (k), my question is how to find the sum (M )of all matrix for each value of k, ie: find M = sum(A (k))

답변 (2개)

Matt J
Matt J 2012년 10월 17일
편집: Matt J 2012년 10월 17일

0 개 추천

I'm assuming your matrices are the slices of a 3D array
M=A(:,:,k)
If so, just do
sum(A,3);

댓글 수: 2

BANI tita
BANI tita 2012년 10월 17일
yes my matrix dimension is 3, A (:,:, k)
BANI tita
BANI tita 2012년 10월 17일
thank you very much

댓글을 달려면 로그인하십시오.

Sachin Ganjare
Sachin Ganjare 2012년 10월 17일

0 개 추천

If I understand your question correctly:
sum_of_all_matrices = sum(A)

댓글 수: 2

Sachin Ganjare
Sachin Ganjare 2012년 10월 17일
For Example:
a1 = [1 2 3]; a2 = [1 2 3]; a3 = [1 2 3]; a123 = [a1 a2 a3]; sum_out = sum(a123);
sum_out is sum of elements of matrix
BANI tita
BANI tita 2012년 10월 17일
thank you very much

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Sparse Matrices에 대해 자세히 알아보기

태그

질문:

2012년 10월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by