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.
0 个评论
采纳的回答
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
0 个评论
更多回答(1 个)
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!