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

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.

 Réponse acceptée

Kodavati Mahendra
Kodavati Mahendra le 5 Juin 2018
Modifié(e) : Kodavati Mahendra le 5 Juin 2018
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 commentaires

Not yet. I need file name that is "message(such as Test_)" + "Date & Time".
File name is: Test_2018-06-05 10-01-40-954.png
Thank you for your reply.
You can just add your message string to the strcat function
@Junwon Park: using sprintf is often clearer than concatenating strings:
filename = sprintf('Test_%s.png',datestr(now,'yyyy-mm-dd HH-MM-SS-FFF'));

Connectez-vous pour commenter.

Plus de réponses (1)

Catégories

En savoir plus sur Images dans Centre d'aide et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by