Skip to content

disp

Displaying array without showing its variable name

disp(A)

  • A should be an (numeric, character, or logical) array.
  • Escape characters, such as \n, are not supported.
  • It displays A without showing its variable name.
  • It displays nothing when A is an empty array.

Example 1: Use num2str() for displaying a number.

disp(['The interest rate is' blanks(1) num2str(3.0) '%'])
The interest rate is 3.000%

Example 2: Displaying a numeric array.

disp(randi(10,1,5))
8.000   4.000   10.00   9.000   10.00

Example 3: Displaying logic values.

disp(true(1,5))
1  1  1  1  1