How to pad zeros in the front of the number using 'num2str'
608 views (last 30 days)
Show older comments
MathWorks Support Team
on 25 Aug 2016
Answered: MathWorks Support Team
on 27 Sep 2016
How to pad zeros in the front of the number using 'num2str' ?
Accepted Answer
MathWorks Support Team
on 25 Aug 2016
For example, you have 47 and you want the output to be 047
Please use the following command:
>> num = 47;
>> num2str(num,'%03.f');
The '%03.f' format specifier indicates that there would totally 3 digits before the decimal point prepended with 0 depending on the digits in the number.
0 Comments
More Answers (0)
See Also
Categories
Find more on Logical 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!