how to subplot in loop using axes(handles.axes1)

2 vues (au cours des 30 derniers jours)
Ajay Nair
Ajay Nair le 2 Avr 2015
Commenté : Ajay Nair le 2 Avr 2015
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

Réponses (1)

Titus Edelhofer
Titus Edelhofer le 2 Avr 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).
  • 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:
hax = sprintf('axes_%d', filt);
plot(handles.(hax), rand(5));
Titus
  1 commentaire
Ajay Nair
Ajay Nair le 2 Avr 2015
Hi,
thanks for reply.
but in my gui i have 3 axes , each axes having 10 subplots thus to create 30 axes is not easy to handle.
i just want to run each axes inside loop like first time in loop it is plotting correctly second time in loop axes1 is deleted thus giving error since am using subplot m getting error but if i use only plot its working fine.
but i need to use subplot
plz help

Connectez-vous pour commenter.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by