matlab
MATLAB Tip of the Day: Counting in the Command Window
This is actually a two-fer: padding a number with a variable number of leading zeros or spaces and updating text in the Command Window without creating a bunch of new lines. Variable number padding The sprintf function includes in its documentation the instructions for padding a number with leading zeros.