Filter löschen
Filter löschen

How to deal with for loop

2 Ansichten (letzte 30 Tage)
Jack_111
Jack_111 am 14 Mai 2013
I want to ask about for loop. I have 50 matrices of Z and I want to use for loop to add them and take the average of these Z matrices.

Akzeptierte Antwort

David Sanchez
David Sanchez am 14 Mai 2013
N_matrices = 50; % number of matrices
total = zeros( size(Z(1) ); % initialization of total addition
for k = 1:N_matrices % loop over all the matrices
total = total + Z(k); % update the addition
end % end the loop

Weitere Antworten (1)

David Sanchez
David Sanchez am 14 Mai 2013
N_matrices = 50; % number of matrices total = zeros( size(Z(1) ); % initialization of total addition for k = 1:N_matrices % loop over all the matrices total = total + Z(k); % update the addition end % end the loop

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

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

Start Hunting!

Translated by