Clear Filters
Clear Filters

importing .fig to GUI

4 views (last 30 days)
Andrea Gil
Andrea Gil on 15 Jul 2011
Hi!
I have a problem with Matlab GUI and I would appreciate it if somebody could help me.
I have designed a program that calculates a diagram and some values. I have different ways to get the diagram:
1)by calculating vectors in the m-file of the GUI and plotting them on the axes of GUI
2) by loading an image on the axes,
3) by loading there a saved in .fig plot from matlab.
For this last case, I have tried everything to locate the .fig on the axes of the GUI, but I don't manage to do it. I get the plot, but it is shown on a new image window. Could anybody please help me? Thanks! :)

Answers (2)

Titus Edelhofer
Titus Edelhofer on 15 Jul 2011
Hi,
usually I would prefer option one. But if you want to go for three, you might do the following:
hFigure = openfig('yoursavedfigure.fig', 'new', 'invisible');
% assuming there is only one axes in your stored figure:
hAxes = get(hFigure, 'CurrentAxes');
% assuming we are in a callback and the tag of your figure is figure1:
hCopy = copyobj(hAxes, handles.figure1);
set(hCopy, 'Position', 'where it shoud be in your GUI')
Titus

Andrea Gil
Andrea Gil on 15 Jul 2011
Thanks Titus,
So you say that instead of saying to the program that I want the fig in the axes I have to look for the position of the axes square related to the gui window? I'm quite new with GUI, how can I look for this position you say? in the property editor of the axes?
Andrea
  1 Comment
Titus Edelhofer
Titus Edelhofer on 15 Jul 2011
Hi Andrea,
yes: when you open guide, and you added somewhere in your gui an axes object, then double click on it and you see the position (and the units, they have to be the same or set before the position). Then remove the axes from your GUI and try to run the code above (or modify the code: handles.axes2 = copyobj(...); delete(handles.axes1))

Sign in to comment.

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!