How do I add leading zeros to a number in Matlab

11 views (last 30 days)
Hi everyone,
I am writing a piece of programme in VEE Pro which can accept MATLAB commands. This programme creates numbers from 1 to 32. Then they are converted to their binary equivalent. what I want is all of those equivalents appear in 6 digits, for example if 32 is 100000 I want 1 as 000001 not 1. Is there any command in MATLAB which does this job? then I can call it into my own progr. I appreciate your help:)
S.

Accepted Answer

Walter Roberson
Walter Roberson on 14 May 2011
dec2bin(1,6)

More Answers (0)

Community Treasure Hunt

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

Start Hunting!