MATLAB: How to add zero infront of number

MATLAB

Hi,
I have to add 0 before a number let say num = 2. I want to show as num=02

Best 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