Skip to content

num2str

Convert a number to a string.

str = num2str(A)
str = num2str(A, precision)
str = num2str(A, format)

Returns a string representation of the number(s) in A. With a numeric precision, controls the number of significant digits. With a string format (a sprintf-style format spec like '%6.2f'), uses that exact format.

num2str(pi) % '3.1416'
num2str(pi, 10) % '3.141592654'
num2str(pi, '%8.4f') % ' 3.1416'
  • sprintf — Format data into a string.
  • str2num
  • double — Convert to double-precision floating-point.