Code for pushbutton in gui to close the .fig.

23 visualizaciones (últimos 30 días)
Maria Pati
Maria Pati el 30 de Ag. de 2019
Comentada: Maria Pati el 2 de Sept. de 2019
Screenshot001.jpg
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

Respuestas (1)

Walter Roberson
Walter Roberson el 30 de Ag. de 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.
  1 comentario
Maria Pati
Maria Pati el 2 de Sept. de 2019
% --- 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)
close
I only add close in this function. Thanks Walter Roberson.

Iniciar sesión para comentar.

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by