Saving a .txt with Month/Day in filename
Show older comments
Hello MW forum!
I'd like to save a big matrix to an ascii file as double, but I'd like the date (preferably the month/day) added to the filename before the '.txt'...
I was using something like:
save('good_series.txt', matrix_variable, '-ascii', 'double')
and Ive tried a few other things where I try to pass the date in as an argument to a filename, but it was unsuccessful. I'd like to avoid using solutions with f* anything.. fid, fopen, etc.
Thank you in advance for your suggestions and help.
Sincerely,
Michael
4 Comments
Matt Kindig
on 21 Oct 2013
Why not something like this:
filename = sprintf('good_series%s.txt', datestr(now,'dd-mmm-yyyy'));
save(filename, matrix_variable, '-ascii', 'double');
Michael
on 21 Oct 2013
Matt Kindig
on 21 Oct 2013
Edited: Matt Kindig
on 21 Oct 2013
Is 'matrix_variable' the actual name of the variable to save, or is it a string containing the name of the variable? Because if it is the former, you need to wrap it in quotes, like:
filename = sprintf('good_series%s.txt', datestr(now,'dd-mmm-yyyy'));
save(filename, 'matrix_variable', '-ascii', 'double');
Michael
on 22 Oct 2013
Accepted Answer
More Answers (0)
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!