How to use y1 y2 y3... variables in for loop?
4 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I need to autoplot several graphs at once. Variables I have are y1, y2, y3,..., y8.
How should I change the following code, so y1 will be changing to y2, y3 and etc.?
for j=1:8,
subplot(1,8,j);bar3(y1);view(-90,0);
end
Thank you
0 件のコメント
採用された回答
TAB
2013 年 2 月 6 日
編集済み: TAB
2013 年 2 月 6 日
Y = {y1;y2;y3;y4;y5;y6;y7;y8};
for j=1:8,
subplot(1,8,j);bar3(Y{j});view(-90,0);
end
3 件のコメント
Jan
2013 年 2 月 6 日
A general method is to avoid to include an index in the name of a variable. Better use y{1}, y{2}..., than cat(1, y{:}) creates the matrix directly.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Discrete Data Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!