GUI - Figure Browser

5 views (last 30 days)
Ulrich
Ulrich on 25 Apr 2012
Commented: pietro on 14 Nov 2015
I have a folder with ca 50 plots (.fig) and I want to display them in a simple GUI with has a next and previouse button to display one figure at a time in certain area of the GUI.
I am able to replace the axes (handles.axes_disp) in GUI once with one of figure files but when I press one of the buttons for the second time, I cannot access the handle anymore.
[Merged information from comment]
GUI handles:
Button: handles.load_btn
Display axes: handles.axes2
'fig2.fig' is supposed to appear in the display area. But after the line copyobj I am losing the handle.
function load_btn_Callback(hObject, eventdata, handles)
ImportFig=hgload('fig2.fig',struct('visible','on')); % Open fig file and get handle
ImportFigAxes=get(ImportFig,'Children'); % Get handle to axes
% Get subplot axes info
NewFig=get(handles.axes2,'Parent'); % Get new (subplot) figure handle
SubplotPos=get(handles.axes2,'Position'); % Get position of subplot axes
delete(handles.axes2); % Delete blank subplot axes
% Copy axes over to subplot
NewSubplotAxes=copyobj(ImportFigAxes,NewFig); % Copy import fig axes to subplot
set(NewSubplotAxes,'Position',SubplotPos) % Set position to orginal subplot axes
% Delete figure
delete(ImportFig); % Delete imported figure
  2 Comments
Jan
Jan on 25 Apr 2012
Without seeing the code it is impossible to guess where the error is.
The tag "matlab" is not helpful in this forum, because *all* messages have to concern Matlab.
Walter Roberson
Walter Roberson on 25 Apr 2012
We need to see the callback of the button you are pressing, and you need to tell us which handle is disappearing and which line of the code you are detecting that at.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 25 Apr 2012
You delete handles.axes2 but you do not set it to any new value ?
(Also remember to use guidata(hObject, handles) after you update it with a new value.)
  2 Comments
Ulrich
Ulrich on 26 Apr 2012
Thank you for your help (especially the line guidata(hObject, handles) helped me a lot), now the GUI is working as it was supposed to. I am assining the copied figure directly to a new Handle and copy it on top of my existing GUI axes (axes2). When I load the next .fig it search for the previouse created Object, delete it and re-do the first step.
pietro
pietro on 14 Nov 2015
Hi, do you have in mind to share the figure browser tool?

Sign in to comment.

More Answers (0)

Categories

Find more on Specifying Target for Graphics Output 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!