loop for measuring values in different cases
    1 回表示 (過去 30 日間)
  
       古いコメントを表示
    
Hi,
If I want to measure the value of something in different cases, how I do it?
because in this loop it will show previous values:
n=3; for i=1:n y(i) = i + 2 end
y = 3 y = 3 4 y = 3 4 5
I don't want to be like that above. I want the results show as follows:
y1 = 3 y2 = 4 y3 = 5
how I can do that?
Thanks
0 件のコメント
採用された回答
  Matt J
      
      
 2013 年 4 月 12 日
         n=3; 
 y=nan(1,n); %PREALLOCATE!!!
 for i=1:n 
   y(i) = i + 2; 
 end;  
 sprintf('y%d = %d ', [1:n;y])
0 件のコメント
その他の回答 (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!

