Trying to save a Matlab file with a timestamp
50 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Peter Carchia
el 9 de Abr. de 2021
Comentada: Stephen23
el 9 de Abr. de 2021
Hello, I am writing up a code that is producing a basic projectile motion graph. I want each graph to be saved to a folder on my desktop where each file is saved under a timestamp from when it was created. I am new and not sure if this is too challenging. Can anyone help or offer suggestions. Thanks
0 comentarios
Respuesta aceptada
KSSV
el 9 de Abr. de 2021
for i = 1:10
data = rand(100,1) ;
fname = strcat('projjectile',string(datetime('now','Format',"yyyy-MM-dd-HH-mm-ss")),'.mat') ;
save(fname,'data')
end
1 comentario
Stephen23
el 9 de Abr. de 2021
For clarity and efficiency (no superfluous type conversions), prefer sprintf over string concatenation:
sprintf('projjectile_%s.mat',datetime('now','Format',"yyyy-MM-dd-HH-mm-ss"))
Más respuestas (0)
Ver también
Categorías
Más información sobre Entering Commands en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!