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

조회 수: 1 (최근 30일)
Kuhen Suresh
Kuhen Suresh 2021년 4월 18일
답변: Abhishek Chakram 2023년 10월 11일
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