MATLAB: Saving problems, desired name

save

I'm trying to save anything under the name I want, for example: savename= input('Save as:','s'); save(savename);
but this doesnt seem to be working. Please help, thank you 🙂

Best Answer

Try this:
% Get the name of the file that the user wants to save.
% Note, if you're saving an image you can use imsave() instead of uiputfile().
startingFolder = userpath % Or "pwd" or wherever you want.
defaultFileName = fullfile(startingFolder, '*.*');
[baseFileName, folder] = uiputfile(defaultFileName, 'Specify a file');
if baseFileName == 0
% User clicked the Cancel button.
return;
end
fullFileName = fullfile(folder, baseFileName)
% Now save whatever variables you want into a mat file
save(fullFileName, 'yourVariable1', 'yourVariable2');
Related Question