Error in XData=get(​get(gca,'c​hildren'),​'XData)

Hie guys, i have an error with the command above.
XData=get(get(gca,'children'),'XData');
YData=get(get(gca,'children'),'YData');
y_BPFO = interp1(XData,YData,BPFO);
I used this codes in my GUI. It works well when i have 1 axes in my GUI. But when i have 2 axes, it prompt me this error log,
??? Error using ==> interp1 at 121
X must be a vector.
Error in ==> maingui>updateAxes at 130
y_BPFO = interp1(XData,YData,BPFO);
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> maingui at 42
gui_mainfcn(gui_State, varargin{:});
??? Error while evaluating uicontrol Callback

 채택된 답변

Paulo Silva
Paulo Silva 2011년 3월 19일

0 개 추천

Instead of gca you should use the handle for the axes that contains the data you want.
If you really want to use gca you can choose what's the current axes before, example:
axes(handles.axes2);
Your code doesn't ensure that there are children and that they contain useful data for interp1.

댓글 수: 4

Ean Soo
Ean Soo 2011년 3월 19일
XData=get(get(gca,'children'),'XData');
Can i know how to choose the axes im using with the command above.
Thanks
Paulo Silva
Paulo Silva 2011년 3월 19일
I assume you are using guide, first find out the name of the axe (axesX) you want to get data from and replace gca by handles.axesX where axesX is the name of your axes. If you are not using guide replace gca by the handle of the axe.
Ean Soo
Ean Soo 2011년 3월 19일
Hie there, can i know if this command correct?
y=get(handles.axes3,'ylim');
plot(handles.axes3,[BPFI BPFI],y,'-r');
Paulo Silva
Paulo Silva 2011년 3월 19일
y=get(handles.axes3,'ylim');
axes(handles.axes3); %make axes3 the current axes
line([BPFI BPFI],y,'LineStyle','--','Color',[1 0 0]) %draw the line

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Tables에 대해 자세히 알아보기

태그

질문:

2011년 3월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by