I want format integer value by adding leading zeros and display it as string. For example, I have 3 and I want to display it as 003. I want to do i
3
003
Use sprintf():
sprintf()
aa = sprintf('%03d', 3); % aa will be 003
Note that aa here is a string. Check out its documentation for more info.
aa
string
Note that you can also use string formatting in num2str command as well:
num2str( 3, '%03d' );