Skip to content

num2str

Converting a numeric array to a character array

num2str(A)

  • This is the same as num2str(A, 4). See the description of num2str(A, n) below.

num2str(A, n)

  • A should be a numeric or logical array.
  • n should be a positive integer.
  • It returns a character array by converting entries of A to characters with n digits.
  • For example, if we set A = [1 2] and n = 3, the output would be the character array '1.00 2.00'.
  • If A is multi-dimensional, it is first reshaped to a matrix (i.e., 2D array) having the same number of rows.
  • If A is a character array, A would be unchanged.
  • If A is empty, it returns an empty array.