Automatically Change Variable in a Plot
6 次查看(过去 30 天)
显示 更早的评论
Hi Guys,
I have some variables (D1,D2,D3,...) and I want to draw the graph for them .Since, number of variables are so much, I want to define the plot funtion in such a way that the variable changes automatically. My initial suggestion was to use eval function as follows: plot(eval(['D' num2str(j)])(:,11),D11(:,1),'linewidth',1) But id doesnt work. Could you please let me know any suggestion to solve it.
Cheers,
0 个评论
采纳的回答
Azzi Abdelmalek
2014-4-22
for k=1:3
eval(sprintf('plot(D%d)',k))
hold on
end
3 个评论
Azzi Abdelmalek
2014-4-22
Jamaledin, using several variables is not a good idea. you can create one variable
v=[D1;D2;...]
or a cell array
v={D1 D2 ...]
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!