Formatting Operator Description
%3$*6$.*7$f 3$ specifies the third input argument, pi,
as the value
*6$ specifies the sixth input argument, 6 ,
as the field width
.*7$ specifies the seventh input argument,
4 , as the precision
Restrictions on Using Identifiers
If any of the formatting operators include an identifier field, then all the operators in the
format specifier must include identifier fields. If you use both sequential and
nonsequential ordering in the same function call, then the output is truncated at the first
switch between sequential and nonsequential identifiers.
Valid Syntax Invalid Syntax
sprintf('%d %d %d %d',...
1,2,3,4)
ans =
'1 2 3 4'
sprintf('%d %3$d %d %d',...
1,2,3,4)
ans =
'1 '
If your function call provides more input arguments than there are formatting operators
in the format specifier, then the operators are reused. However, only function calls that
use sequential ordering reuse formatting operators. You cannot reuse formatting
operators when you use numbered identifiers.
Valid Syntax Invalid Syntax
sprintf('%d',1,2,3,4)
ans =
'1234'
sprintf('%1$d',1,2,3,4)
ans =
'1'
If you use numbered identifiers when the input data is a vector or array, then the output
does not contain formatted data.
Formatting Text