Hi, I want to know how to sum all the matrices in a loop at the end of it

3 Ansichten (letzte 30 Tage)
I have a loop in which I define a matrix in each iteration. At the end of it I want to sum all of these matrices. Any help would be appreciated.
  2 Kommentare
Walter Roberson
Walter Roberson am 5 Feb. 2016
How are you storing the individual matrices?
Stephen23
Stephen23 am 5 Feb. 2016
Bearbeitet: Stephen23 am 5 Feb. 2016
Easy: save the data matrices together in one array, then you just need sum at the end.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Jan
Jan am 5 Feb. 2016
Data = zeros(5, 6, 7);
for k = 1:5
Data(k, :, :) = rand(6, 7);
end
Result = sum(Data, 1);

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by