Saving figure

2 次查看(过去 30 天)
Syed Abbas
Syed Abbas 2012-1-27
Hi,
I have an m file which generates a figure. I run this m file daily. But each day, I have to name and manually save the figure. Is there a way to automatically save the figure with todays date as the file name? I know how to automatically save the figure but I am not sure how to use todays date as the file name. Thanks.

采纳的回答

Image Analyst
Image Analyst 2012-1-28
Use datestr() but be sure to change the colons to a valid character!!!
Try this:
% Get date-time string.
baseFileName = datestr(now)
% Colons aren't allowed in filenames.
% Replace them with underlines
baseFileName = strrep(baseFileName, ':', '_');
% Add extension.
baseFileName = [baseFileName '.png']
Then call export_fig() as usual.

更多回答(1 个)

Honglei Chen
Honglei Chen 2012-1-27
You can use imwrite and date
doc imwrite
doc date
  3 个评论
Walter Roberson
Walter Roberson 2012-1-27
today = date();
thisfile = ['C:\docs\' today];
saveas(thisfile)
Syed Abbas
Syed Abbas 2012-1-31
Thanks!

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by