How to deal with for loop

1 次查看(过去 30 天)
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.

采纳的回答

David Sanchez
David Sanchez 2013-5-14
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

更多回答(1 个)

David Sanchez
David Sanchez 2013-5-14
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

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by