MATLAB Answers

0

How to add zero infront of number

Asked by Muhammad Haziq on 1 Mar 2019
Latest activity Answered by Honglei Chen
on 1 Mar 2019
Hi,
I have to add 0 before a number let say num = 2. I want to show as num=02

  0 Comments

Sign in to comment.

Tags

Products


Release

R2018a

1 Answer

Answer by Honglei Chen
on 1 Mar 2019
 Accepted Answer

I don't think you can pad zero for a numeric number but you can do it when printing. For example
fprintf('num = %02d\n',2)
Is this what you want? HTH

  0 Comments

Sign in to comment.