Saving problems, desired name

3 views (last 30 days)
Jose Sousa
Jose Sousa on 28 Dec 2015
Commented: Jose Sousa on 28 Dec 2015
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 :)

Accepted Answer

Image Analyst
Image Analyst on 28 Dec 2015
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');
  1 Comment
Jose Sousa
Jose Sousa on 28 Dec 2015
yes, that worked :) What if, instead of saving, i want to load? with a name chosen by the user?

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!