Using 'savefig' with 'datestr' returns error

I am trying to save a figure using 'savefig' like this:
savefig(['Spectrum_',center_freq, datestr(now, 'dd-mmm-yyyy HH:MM:SS')])
However, this returns an error:
Error using save
Unable to open file "Spectrum_100MHz_02-Aug-2017 15:23:\51.fig" for output.
Error in matlab.graphics.internal.figfile.FigFile/write (line 32)
save(obj.Path, obj.MatVersion, '-struct', 'SaveVars');
Error in savefig (line 84)
FF.write();
Error in [FUNCTION NAME] (line 174)
savefig(['Spectrum_',center_freq, datestr(now, 'dd-mmm-yyyy HH:MM:SS')])
Since savefig works without the datestr line, it's obvious to me that it has to do with datestr. Is there a correct way to include a timestamp in a figure filetype that I don't know about?

 Respuesta aceptada

Walter Roberson
Walter Roberson el 2 de Ag. de 2017
savefig(['Spectrum_',center_freq, datestr(now, 'dd-mmm-yyyy HH_MM_SS')])
Colons are not permitted in file names in FAT* or NTFS file systems.

1 comentario

gas5305
gas5305 el 3 de Ag. de 2017
Oh jeez, thank you. I feel like a proper idiot now...

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Interactive Control and Callbacks en Centro de ayuda y File Exchange.

Preguntada:

el 2 de Ag. de 2017

Comentada:

el 3 de Ag. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by