How to deal with for loop

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일

0 개 추천

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일

0 개 추천

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

카테고리

도움말 센터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!

Translated by