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 can also be used to display vector values. The following screenshot shows the output of the vector variable y.
If you want to display text using disp, place the text inside apostrophes.
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.