How to make filename that message + date&time using [imwrite function].

1 次查看(过去 30 天)
The MATLAB code is {imwrite(red, datestr(now,'yyyy-mm-dd HH-MM-SS-FFF'),'png');}
I want to make file name "test_yyyy-mm-dd HH-MM-SS-FFF".png
Please, Let me know the method.
Thanks.

采纳的回答

Kodavati Mahendra
编辑:Kodavati Mahendra 2018-6-5
filename = strcat(datestr(now,'yyyy-mm-dd HH-MM-SS-FFF'),'.png');
imwrite(red, filename);
Solved? Problem was with the syntax for imwrite :-)
Edit 1:
filename = strcat('Test_',datestr(now,'yyyy-mm-dd HH-MM-SS-FFF'),'.png');
imwrite(red, filename);
Now?
  3 个评论
Stephen23
Stephen23 2018-6-5
编辑:Stephen23 2018-6-5
@Junwon Park: using sprintf is often clearer than concatenating strings:
filename = sprintf('Test_%s.png',datestr(now,'yyyy-mm-dd HH-MM-SS-FFF'));

请先登录,再进行评论。

更多回答(1 个)

Junwon Park
Junwon Park 2018-6-5
Thank you so much. It's solved. :)

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by