When I make a 1×10 matrix in MATLAB, such as a=[1:10], it returns:
a =
1 2 3 4 5 6 7 8 9 10
i. e., it ignores zero-digit from numbers 1 to 9. I’d like to have a matrix like that:
a =
01 02 03 04 05 06 07 08 09 10.
If you want to display numbers in a specific format, you can overload the
dispfunction for the specific type of number. In that function, you’ll need to create a string with leading zeros.If you want to create strings that contain numbers with leading zeros, you can use
sprintf. For example, if you want to haveyou can create a file name with leading zeros like this: