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!