Code for pushbutton in gui to close the .fig.
7 views (last 30 days)
Show older comments
I have a pushbutton in my .fig, shown above. The main purpose of this pushbutton is to close the .fig file. Can anyone help me what code to add in the callback function or createfcn, that after the button is pushed, the .fig file will close. Thanks.
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
function pushbutton1_CreateFcn(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
0 Comments
Answers (1)
Walter Roberson
on 30 Aug 2019
.fig files do not stay open if you use load() or uiimport() or openfig()
A .fig file would only stay open if you use fopen()
If you have have done an openfig then the .fig is automatically closed. What is left open is a figure object. You can close() or delete() figure objects. If you use close() then you can even close by figure Name property.
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!