How to do a "Save" and "Exit" button in Matlab Gui. I need help with the callback function

2 Kommentare

Geoff Hayes
Geoff Hayes am 16 Apr. 2018
Ubaashan - are you creating your GUI with GUIDE, App Designer, or programmatically? When the user presses the save button, presumably you want to save something to a file or...? Please clarify.
Ubaashana Ramesh
Ubaashana Ramesh am 16 Apr. 2018
Geoff, I am using GUIDE. I am doing doing a GUI for Image watermarks. This is how it works, when the user has finished watermarking, the watermarked image has to be saved in the desktop - once the "Save" button is clicked.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Geoff Hayes
Geoff Hayes am 16 Apr. 2018

0 Stimmen

Ubaashana - in the (save) push button callback, you will save the data to file, possibly using imwrite. For example,

 function pushbutton1_Callback(hObject, eventdata, handles)
 % get the image data to save (from an axes or the handles structure)
 imgToSave = ...;
 % save to file
 filename = ...;
 imwrite(imgToSave, filename);

I'm assuming that you can easily get the watermarked image from the handles structure and that the filename is known (or are you asking the user for the filename?).

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by