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

1 Ansicht (letzte 30 Tage)
Kelsey Ward
Kelsey Ward am 24 Nov. 2022
Kommentiert: Jan am 25 Nov. 2022
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 Kommentare
Kelsey Ward
Kelsey Ward am 24 Nov. 2022
yep, thanks, just had an error farther back that was setting it to 100 instead of 1
Jan
Jan am 25 Nov. 2022
By the way, num2str calls sprintf internally.You can call this directly also:
sprintf('%04d', i)

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by