MATLAB Guide

MATLAB has three features that distinguish it from most other modern programming languages and problem solving environments. We introduce them in this chapter and elaborate on them later in the book.
As we saw in Chapter 2, variables need not be declared prior to being assigned. This applies to arrays as well as scalars. Moreover, MATLAB automatically expands the dimensions of arrays in order for assignments to make sense. Thus, starting with an empty workspace, we can set up a 1-by-3 vector x of zeros with
<span class="unicode">?</span> x(3) = 0 x = 0 0 0
and then expand it to length 6 with
<span class="unicode">?</span> x(6) = 0 x = 0 0 0 0 0 0
MATLAB's automatic allocation of storage is one of its most convenient and distinctive features.
MATLAB contains a large (and user-extendible) collection of functions. They take zero or more input arguments and return zero or more output arguments. MATLAB enforces a clear distinction between input and output: input arguments appear on the right of the function name, within parentheses, and output arguments appear on the left, within square brackets. Functions can support a variable number of input and output arguments, so...