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 ExchangeSparse 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