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일
편집: 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
Kodavati Mahendra
Kodavati Mahendra 2018년 6월 5일
You can just add your message string to the strcat function
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에서 Hypothesis Tests에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by