VT Logo MATLAB Logo

Home

Basics

Variables

Inputs and Outputs

Repetition Structures

Selection Structures

disp and display


There a two basic functions to output the values of variables, disp and display. disp and display can be also used to display simple numbers and text and are not exclusively used with variables.

Contents

 

disp


disp is the simpler version of the two. It will only output the value of variable, and not the variable name. To use the disp function, put the name of the variable to be outputted in parentheses immediatelly following disp. In the following screenshot, the value of the scalar variable x is outputted using the disp function.

Disp Scalar Example

 

disp can also be used to display vector values. The following screenshot shows the output of the vector variable y.

Disp Vector Example

 

If you want to display text using disp, place the text inside apostrophes.

Disp with Text

 

display


display will output both the variable name and the value of the variable. Using the above scalar and vector examples, the output using the display function would be as follows.

Display Example