There are three common ways:

  1. Type the name of a variable without a trailing semi-colon.
  2. Use the “disp” function.
  3. Use the “fprintf” function, which accepts a C printf-style formatting string.

Here are examples:

> x = [1 2 3 4];
> x
x =

   1   2   3   4

> disp(x)
   1   2   3   4
> fprintf('%i\n', x)
1
2
3
4

Notes:

  • “disp” excludes the variable name from the output
  • “fprintf” uses the formatting string on each element of the variable.  In the example above, applying “\n” to each element had the net effect of printing a row vector as if it were a column vector.