disp

Displays a value in the command window without printing its name.

Category: Data Import and Analysis > Data Import and Export

Syntax

disp(X)

Prints the value of X, with no X = label and no extra blank lines.

Description

disp formats numbers like the command window does, but leaves out the variable name, which makes it handy for messages. Text is printed as is, and an empty array prints nothing.

For formatted numbers inside a sentence, use fprintf or sprintf. To capture what a display would print as a string, use formattedDisplayText.

Input arguments

X
Any value: numeric array, text, cell array, struct, table, and so on.

Example

Different kinds of values

disp(pi)
disp('hello')
disp([1.5 2; 3 4])
disp({1, 'a'})
disp(int8(5))
Output
    3.1416
hello
    1.5000    2.0000
    3.0000    4.0000
    {[1]}    {'a'}
   5

See also

fprintf display formattedDisplayText sprintf