필터 지우기
필터 지우기

importing .fig to GUI

조회 수: 4 (최근 30일)
Andrea Gil
Andrea Gil 2011년 7월 15일
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! :)

답변 (2개)

Titus Edelhofer
Titus Edelhofer 2011년 7월 15일
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 2011년 7월 15일
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
Titus Edelhofer
Titus Edelhofer 2011년 7월 15일
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))

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by