循环中每个绘图的单独句柄

时间:2017-09-27 21:15:46

标签: matlab matlab-guide

我正在准备一个GUI,我想在一个轴上绘制2-30个不同的图,我想在循环迭代中为每个图添加一个数字。

这是我的代码,它给了我一个句柄(handles.handle_plotCD1),但我想要handle.handle_plotCD1,handles.handle_plotCD2,handles.handle_plotCD3等:

set(handles.axes1, 'NextPlot', 'add');
for cd=1:length(plotdata)
    handles.handle_plotCD1 = plot(plotdata{cd,1}(:,1),plotdata{cd,1}(:,4),'visible','off','LineWidth',2, ...
                            'color', [0 0 0],'linestyle', '--', 'parent', handles.axes1);    
end

我该怎么做?

1 个答案:

答案 0 :(得分:0)

正如已经讨论here,动态命名的变量不是一个好主意。相反,试试这个:

for cd=1:length(plotdata)
    handle_plot(cd) = ...
end

显然,您可以单独修改每个handle_plot(i)

相关问题