importing .fig to GUI
4 views (last 30 days)
Show older comments
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! :)
0 Comments
Answers (2)
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
0 Comments
Andrea Gil
on 15 Jul 2011
1 Comment
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))
See Also
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!