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?
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!