There are three common ways:
- Type the name of a variable without a trailing semi-colon.
- Use the “disp” function.
- 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.