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 Center および File ExchangeCreating, 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