Assign figure to axes gui

조회 수: 2 (최근 30일)
Georg Söllinger
Georg Söllinger 2016년 12월 2일
답변: Geoff Hayes 2016년 12월 4일
Hi everybody,
again I need your help with matlab programming: I am trying to implement a code, which is composed of several functions, into a GUI. It works fine but I have my difficulties with assigning the figures, which are created in functions, to the axes in GUI. Can anyone tell me, how to correctly assign the figure from the function to the axes? I tried to return the figure from the function into the axes handle (handles.axes1 = myfunction(bla1, bla2) ), but this one doesn't work.
Help is very appreciated, thanks in advance.
Georg
  댓글 수: 1
Adam
Adam 2016년 12월 2일
You need to give more information as it isn't obvious what you are doing.
Axes are children of a figure. You don't normally assign a figure to a pre-existing axes.
handles.axes1 = myfunction(bla1, bla2)
is not a good idea if that is in a GUIDE GUI which I assume it is given you are using handles. axes1 is the default name of the first axes created in GUIDE (though I usually change its name) and if this is the case you should never be reassigning something to it in the code.

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

답변 (1개)

Geoff Hayes
Geoff Hayes 2016년 12월 4일
Georg - if your function is plotting or drawing some data on to an axes, then if you want to draw it to a specific axes (like the one from your GUI) then you should pass the handle of the axes that you wish to draw to. For example, from within your GUI code, you would call your function as
myfunction(bla1, bla2, handles.axes1);
where handles.axes1 is the handle to the axes that you wish to draw or plot the data to. You would then need to update the body of this function so that when it calls whatever MATLAB function to draw the data, you pass in the handle to the axes.

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by