- 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)
3 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Titus Edelhofer
on 2 Apr 2015
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
See Also
Categories
Find more on Subplots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!