Get figure handle from different mfile and plot in GUI

2 次查看(过去 30 天)
I am tasked to design a GUI and I need to use variables and plots from a different mfile which I created earlier. I'm pretty confident about getting variables from the processing mfile but I'm not sure how to get the plots/figures.
So basically my question is whether I can get() a figure from my mfile and then set() an axes to that figure inside my GUI.
Note: The reason I am doing this is because I want to keep the processing of data separate from the GUI mfile. I could just dump all the processing in the callback of my process button but that's not what i want. I would also appreciate good coding practices for my case since I have never worked with GUI's before (only scripting with PHP and MATLAB)
Note2 (rundown of what has to be done): In the GUI we basically are supposed to load 2 files, we then press the "process" button and then 4 plots have to appear. All the processing code already exists in a previously written mfile (by me).
Thanks! :) ============================================ EDIT:
So i managed to get this working by passing each plot to a variable using p=plot() and then passing that variable to my handle.
However, in my callback function, I am not sure how to set those axes to the right objects. I tried a lot of different things and they always end up in the wrong places or with just don't appear at all.. Current setup:
input.fullpath_wind = get(handles.edit_wind, 'String');
input.fullpath_gps = get(handles.edit_gps, 'String');
axes(handles.axes_worldmap)
setappdata(0,'input',input)
run opgave3
getappdata(0,'output')
set(output.worldmap,handles.axes_worldmap)
How would I add another axes?

回答(1 个)

Daniel Shub
Daniel Shub 2012-9-28
You should have a read through the FAQ, especially FAQ:5.16
  1 个评论
Nick
Nick 2012-9-28
thank you captain hindsight. I already figured it out on my own. I didn't know I could pass plots as objects as well. I just did p=plot() and put that in my handle and that worked

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by