use "for loop" to create pattern
3 ビュー (過去 30 日間)
古いコメントを表示
I would like to know how to modify my "second for loop" to obtain the "a" result as below picture.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/802354/image.png)
Thank you very much!
clc
clear
plynumber=3;
stackply=3;
plysym=1;
total=plynumber*stackply*plysym;
for i=1:plynumber % first for loop
a(1,i)=input('a=')
end
for i=1+plynumber:total % second for loop
2 件のコメント
Image Analyst
2021 年 11 月 16 日
OK, so that is your desired final a, but is supposed to depend on your a from loop 1 at all? Or you just want that a regardless of what a was from the first loop? Because I think to get your desired a, it's basically going to totally ignore the a from your first loop.
採用された回答
David Hill
2021 年 11 月 16 日
Why not just use repmat() instead of a for-loop?
a=repmat(a,1,3);
5 件のコメント
その他の回答 (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!