MATLAB: How to fix error done by pressing “Cancel” button

cancelerrorsaveas

Hi everybody!
I wrote a simple function to save my axes using saveas funct. but if I click on "Cancel" in the opened window, I have an error in my Matlab… There's a way to interrupt the operation of saving if users press "Cancel" without an error??

Best Answer

Hi,
the uiputfile dialog returns 0 for the filename if the user presses cancel:
filename = uiputfile;
if filename==0
% user pressed cancel
return
end
% go on with saving your data ...
Titus