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

1 次查看(过去 30 天)
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?

采纳的回答

JULIEN BARBAUD
JULIEN BARBAUD 2019-4-22
编辑:JULIEN BARBAUD 2019-4-22
Try to use something like
img_name=sprintf('img%03d',num)
instead of the strcat line

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

标签

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by