Assign figure to axes gui

2 次查看(过去 30 天)
Georg Söllinger
Georg Söllinger 2016-12-2
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 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by