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

1 次查看(过去 30 天)
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');

回答(1 个)

Abhishek Chakram
Abhishek Chakram 2023-10-11
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

类别

Help CenterFile Exchange 中查找有关 Printing and Saving 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by