Borrar filtros
Borrar filtros

How to make sure number of digits remain same, padded if required

1 visualización (últimos 30 días)
I am assigning names in a loop of the form img000.png,img001.png and so on. I’m using strcat as follows:
%num=000 %strcat(‘img’,num2str(num),’.png’) %num=+1
How do I make the assignment of num so that it always remains 3 digits?

Respuesta aceptada

JULIEN BARBAUD
JULIEN BARBAUD el 22 de Abr. de 2019
Editada: JULIEN BARBAUD el 22 de Abr. de 2019
Try to use something like
img_name=sprintf('img%03d',num)
instead of the strcat line

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by