How to use y1 y2 y3... variables in for loop?

1 次查看(过去 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

采纳的回答

TAB
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
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.
José-Luis
José-Luis 2013-2-6
Please accept an answer if it helped you.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Discrete Data Plots 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by