Effacer les filtres
Effacer les filtres

how to find the sum of matrix?

5 vues (au cours des 30 derniers jours)
BANI tita
BANI tita le 17 Oct 2012
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))

Réponses (2)

Matt J
Matt J le 17 Oct 2012
Modifié(e) : Matt J le 17 Oct 2012
I'm assuming your matrices are the slices of a 3D array
M=A(:,:,k)
If so, just do
sum(A,3);
  2 commentaires
BANI tita
BANI tita le 17 Oct 2012
yes my matrix dimension is 3, A (:,:, k)
BANI tita
BANI tita le 17 Oct 2012
thank you very much

Connectez-vous pour commenter.


Sachin Ganjare
Sachin Ganjare le 17 Oct 2012
If I understand your question correctly:
sum_of_all_matrices = sum(A)
  2 commentaires
Sachin Ganjare
Sachin Ganjare le 17 Oct 2012
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 le 17 Oct 2012
thank you very much

Connectez-vous pour commenter.

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by