How to add multiple 0s in front of number with numstr?

조회 수: 1 (최근 30일)
Kelsey Ward
Kelsey Ward 2022년 11월 24일
댓글: Jan 2022년 11월 25일
I have been using " num2str(i,'%04d') " which is giving me strings of "0100," "0200," etc. I can't seem to figure out a version of the code that will give me "0001" "0002".
  댓글 수: 3
Kelsey Ward
Kelsey Ward 2022년 11월 24일
yep, thanks, just had an error farther back that was setting it to 100 instead of 1
Jan
Jan 2022년 11월 25일
By the way, num2str calls sprintf internally.You can call this directly also:
sprintf('%04d', i)

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by