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 good. 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! 🙂
I figured it out myself! What I did was use gcf to get the current figure like so:
output.worldmap = gcfI then passed the object back like so:setappdata(0,'output',output)and grabbed it again inside my callback function like so:getappdata(0,'output')and used the following function to set the axesset(output.worldmap,'CurrentAxes',handles.axes_worldmap)I also made sure that the correct axis was set before I actually ran my mfile which does the processing withaxes(handles.worldmap)