필터 지우기
필터 지우기

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