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

조회 수: 2 (최근 30일)
Ajay Nair
Ajay Nair 2015년 4월 2일
댓글: Ajay Nair 2015년 4월 2일
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

답변 (1개)

Titus Edelhofer
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).
  • 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
Ajay Nair
Ajay Nair 2015년 4월 2일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by