0

I am creating a GUI in Matlab's Guide which should display a video and a plot saved in a .fig file. I am currently trying to open the plot in an axes element and while I know axes cannot be a container, the possibility of saving the plot in a another object and feeding that object to axes seems like a solution, but I don't know how to do that due to limited Matlab knowledge. Here is the only code I have for the button at the moment which allows me to open a file from my local directory.

% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
  axes(handles.axes1);
  [file,path] = uigetfile('*.fig');
  • I'm not 100% sure what you're asking, but if you're trying to 'open' a GUI window created via GUIDE, by clicking a button, then you should know that this is not as simple as 'loading' the generated '.fig' file. See the comments in this question for more details: https://stackoverflow.com/a/47437896/4183191 – Tasos Papastylianou Jul 22 '19 at 12:53

1 Answers1

0

[file,path] = uigetfile('*.fig'); only gets the path and name of the file that was selected, it doesn't load the file. To load the file you want to use,

hfig = openfig(fullfile(path,file));

However, since you don't really want to see the figure you most likely want to use the optional input

hfig = openfig(fullfile(path,file),'invisible');

to load the figure but make it invisible.

Then you'll need to move the image from the axes in hfig to the axes in your UI. This can be achieved in multiple ways, one of which is the use of copyobj.

Phil Goddard
  • 10,571
  • 1
  • 16
  • 28