How to deal with for loop
    3 ビュー (過去 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!

