You can use the sprintf
function to format the elements of your vector as a string with leading zeros. Here's an example code snippet:
main.m60 chars4 lines
Output:
main.m10 chars2 lines
Note that %02d
specifies a decimal integer with minimum width 2 and leading zeros. The space after %02d
adds a space after each element of the vector. If you don't want the trailing space, you can use a_padded(1:end-1)
to remove the final character.
gistlibby LogSnag