How can I use an answer from a prompt as a file name?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Nathan Costin
le 4 Juil 2016
Commenté : Nathan Costin
le 5 Juil 2016
I am currently trying to use an answer from a prompt given as a file name for a table that gives the location of cells on an image. However I keep getting error messages or am only able to save the table as one name. Below is the codes that I am using:
prompt1 = 'What would you like the data file to be called?';
filename = input(prompt1,'s');
writetable(centroiddata, filename)
I have tried several solutions to resolving this, including changing the filename in the 3rd line to 'filename' and specifying the file path.
If anyone can help me out I would be very grateful!
Thanks in advance!
0 commentaires
Réponse acceptée
Plus de réponses (1)
Image Analyst
le 4 Juil 2016
Why not simply use the function meant for asking the user for a filename?
Why are you not using uiputfile()???
3 commentaires
Image Analyst
le 4 Juil 2016
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)
Voir également
Catégories
En savoir plus sur Convert Image Type dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!