Simple xlswrite question.

1 Ansicht (letzte 30 Tage)
Francois Desmeules
Francois Desmeules am 20 Okt. 2016
Beantwortet: Image Analyst am 20 Okt. 2016
Hello,
I have a few matrices that I want to export in excel. Every time I run my code, I want to export few outputs in Excel. From what i've found I have to hardcode the file name, by doing that I am always writing in the same file. I need to find a way to always create a new file or clear the content of the same file before writing in it.
Thanks

Antworten (1)

Image Analyst
Image Analyst am 20 Okt. 2016
Try uiputfile() and let the user specify the name by typing it in:
% 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)
Or you can create the filename from values of some of your variables if you use sprintf().

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by