Modifying sequential filenames with padded numbers
58 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jason
el 7 de En. de 2026 a las 11:06
Hello, I am trying to create some file names to save a setr of images and have so far done this:
>> filenames = "clock_" + string(1:8) + ".jpg";
>> filenames'
ans =
8×1 string array
"clock_1.jpg"
"clock_2.jpg"
"clock_3.jpg"
"clock_4.jpg"
"clock_5.jpg"
"clock_6.jpg"
"clock_7.jpg"
"clock_8.jpg"
I'd like to improve on this and have the numers like this:
"clock_001.jpg"
"clock_002.jpg"
"clock_003.jpg"
and to be able to change the starting value. For example, start at 11 would be:
"clock_011.jpg"
"clock_012.jpg"
"clock_013.jpg"
and as a last request I'd like to prefix the current datetime using now()
Thanks
0 comentarios
Respuesta aceptada
Stephen23
el 7 de En. de 2026 a las 17:17
Editada: Stephen23
el 7 de En. de 2026 a las 17:53
Avoid superfluous type conversion, REPMAT, and concatenation of data into one string array.
dt = datetime('now','Format','d-MMM HH_mm_ss');
nv = 1:48;
ez = compose("IM_SaperaSave_%03d_%s.tif", nv(:),dt)
1 comentario
Más respuestas (0)
Ver también
Categorías
Más información sobre Characters and Strings 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!