Get figure handle from different mfile and plot in GUI

2 visualizaciones (últimos 30 días)
Nick
Nick el 28 de Sept. de 2012
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?

Respuestas (1)

Daniel Shub
Daniel Shub el 28 de Sept. de 2012
You should have a read through the FAQ, especially FAQ:5.16
  1 comentario
Nick
Nick el 28 de Sept. de 2012
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

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by