MATLAB: Gui Screen Shot Button

figuresguiimagesMATLAB

Hello all,
I have a GUI that i created using guide and I am trying to create a push button that can be used to save a screen shot of the GUI window. I want to be able to select the location it is saving to and have it same with the same resolution. I got it working using the saveas function, but it saves, but the images come out very low quality. The save as code is as follows:
function pushbutton1_Callback(hObject, eventdata, handles)
[name,path,index] = uiputfile
saveas(Sections,[path name],'jpg');
I am not sure if there is a way to do this with the print command or not, but any help is appreciated.

Best Answer

Try this snippet to get a valid filename.
% Note, if you're saving an image you can use imsave() instead of uiputfile().
startingFolder = userpath
defaultFileName = fullfile(startingFolder, '*.*');
[baseFileName, folder] = uiputfile(defaultFileName, 'Specify a file');
if baseFileName == 0
% User clicked the Cancel button.
return;
end
fullFileName = fullfile(folder, baseFileName)
Then use fullFileName instead of "Sections" in saveas(), or better yet export_fig.
Related Question