how to format integer numbers to start with filling zeros?
Show older comments
I would like to transform n = 1:12 to '01','02',...,'11','12'
Accepted Answer
More Answers (1)
Walter Roberson
on 15 Dec 2015
cellstr(num2str((1:12).', '%02d'))
or
arrayfun(@(x) sprintf('%02d', x), 1:12, 'Uniform', 0);
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!