num2strCNT(i,[n,txt])
i : | index | |
n : | maximal number of indices | |
txt : | optional leading string |
num2strCNT(2,12); % if counter runs from 1 to 12
num2strCNT(2,12,'F'); % if counter runs from 1 to 12 with leading 'F"
num2strCNT(1,4999); % if counter runs to 4999
This function, num2strCNT
, is designed to create a formatted string representation of a number with leading zeros, often used for automatic frame name creation. It is part of the SolidGeometry library.
getfuncparams
is used to retrieve the value of n
from the input arguments. If n
is not provided, it defaults to the value of i
.n
, using the formula nn = floor(log10(n) + 1)
. This determines how many leading zeros are needed.txt
using getfuncparams
. If not provided, it defaults to an empty string.fstr
using sprintf
to specify the format for the output string. The format string includes the leading string, leading zeros, and the number itself.nstr
using sprintf
with the format string fstr
, the leading string txt
, and the index i
.num2strCNT(2,12);
- Converts the number 2 into a string with leading zeros, assuming a maximum of 12.num2strCNT(2,12,'F');
- Converts the number 2 into a string with leading zeros and a leading 'F', assuming a maximum of 12.num2strCNT(1,4999);
- Converts the number 1 into a string with leading zeros, assuming a maximum of 4999.