How to add a save feature in GUI? I tried this, but doesn't work

1 visualización (últimos 30 días)
Kuhen Suresh
Kuhen Suresh el 18 de Abr. de 2021
Respondida: Abhishek Chakram el 11 de Oct. de 2023
function save_user_Callback(hObject, eventdata, handles)
% hObject handle to save_user (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
saveas(gcf,'output.jpg');

Respuestas (1)

Abhishek Chakram
Abhishek Chakram el 11 de Oct. de 2023
Hi Kuhen Suresh,
It is my understanding that you want to add a save feature in GUI. Here are the steps to achieve the same:
  1. Add a “uibutton” to the GUI
  2. Add a “ButtonPushed” callback to it.
  3. Use “exportgraphics” function to save it in any format.
Here is a sample code for the same:
function ButtonPushed(app, event)
exportgraphics(app.UIAxes,'LinePlots.jpg')
end
You can refer to the following documentations to know more about the functions used:
Best Regards,
Abhishek Chakram

Categorías

Más información sobre Printing and Saving en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by