If you use numbered identifiers when the input data is a vector or array, then the output does not
contain formatted data.
Valid Syntax
Invalid Syntax
v = [1.4 2.7 3.1];
sprintf('%.4f %.4f %.4f',v)
ans =
'1.4000 2.7000 3.1000'
v = [1.4 2.7 3.1];
sprintf('%3$.4f %1$.4f %2$.4f',v)
ans =
1×0 empty char array
See Also
compose | sprintf | fprintf | num2str
Related Examples
•
“Convert Text to Numeric Values” on page 6-49
•
“Convert Numeric Values to Text” on page 6-45
Formatting Text
6-31
contain formatted data.
Valid Syntax
Invalid Syntax
v = [1.4 2.7 3.1];
sprintf('%.4f %.4f %.4f',v)
ans =
'1.4000 2.7000 3.1000'
v = [1.4 2.7 3.1];
sprintf('%3$.4f %1$.4f %2$.4f',v)
ans =
1×0 empty char array
See Also
compose | sprintf | fprintf | num2str
Related Examples
•
“Convert Text to Numeric Values” on page 6-49
•
“Convert Numeric Values to Text” on page 6-45
Formatting Text
6-31
