MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
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 | fprintf | num2str | sprintf

Related Examples



  • “Convert from Character Arrays to Numeric Values” on page 6-63

  • “Convert from Numeric Values to Character Array” on page 6-61


6 Characters and Strings

Free download pdf