- Create and lay out the axes in guide.
- Give them tags like "axes_1", "axes_2", ..., "axes_10"
- Instead of calling subplot or axes(...) simply call plot with the handle:
how to subplot in loop using axes(handles.axes1)
2 次查看(过去 30 天)
显示 更早的评论
function pushbutton_callback(hobject,eventdata,handles)
for j = 1:2 axes(handles.axes1); for filt = 1:10 subplot(5,2,filt); plot(rand(5)); end end
first time in loop it is plotting in axes1 .. second time in loop am getting error Invalid object handle axes(handles.axes1);
i need to plot it in same axes1 but am getting error; plz help
0 个评论
回答(1 个)
Titus Edelhofer
2015-4-2
Hi,
if you have "handles.axes1" I assume you created your UI with GUIDE? Then the easiest is to create not one axes in GUIDE but 5x2 axes (since that's what you try to do with subplot). Mixing both will not work (at least not easily).
hax = sprintf('axes_%d', filt);
plot(handles.(hax), rand(5));
Titus
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Subplots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!