循环中每个图的单独句柄
Individual handles for each plot in a loop
我正在准备一个 GUI,我想在一个轴上绘制 2-30 个不同的图,我想在循环迭代中为每个图添加一个数字。
这是我的代码,它给我一个句柄 (handles.handle_plotCD1),但我想要句柄。handle_plotCD1,句柄。handle_plotCD2,句柄。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
我该怎么做???
正如已经讨论过的那样 here,动态命名变量不是一个好主意。试试这个:
for cd=1:length(plotdata)
handle_plot(cd) = ...
end
显然您可以分别修改每个 handle_plot(i)
。
我正在准备一个 GUI,我想在一个轴上绘制 2-30 个不同的图,我想在循环迭代中为每个图添加一个数字。
这是我的代码,它给我一个句柄 (handles.handle_plotCD1),但我想要句柄。handle_plotCD1,句柄。handle_plotCD2,句柄。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
我该怎么做???
正如已经讨论过的那样 here,动态命名变量不是一个好主意。试试这个:
for cd=1:length(plotdata)
handle_plot(cd) = ...
end
显然您可以分别修改每个 handle_plot(i)
。