
Second Section
2. Manipulating Vectors and Matrices
A matrix or an array is the basic element on which Matlab can operate. A 1-
by-1 matrix forms a scalar or a single number, whereas a matrix with only
one row or column forms a row or column vector respectively. This section
exhibits the mathematical manipulation of vectors (arrays) and of two-
dimensional matrices.
2.1 Row Vectors
A vector is a list of numbers separated by either space or commas. Each
different number/entry located in the vector is termed as either element or
component. The number of the vector elements/components determines the
l
l
e
e
n
n
g
g
t
t
h
h of the vector. In Matlab, square brackets “[ ]” are used to both define
a vector and a matrix. For instance, the following command returns a row
vector with 5 elements:
Matlab’s command:
>> y=[ 5 exp(2) sign(-5) sqrt(9) pi]
Matlab’s response:
y =
5 7.3891 -1 3 3.1416
Note that the definition of the row vector, the user it free to use any built-in
function as long as this is used properly. In the above definition,
e
e
x
x
p
p is the
exponential,
s
s
i
i
g
g
n
n returns the sign,
s
s
q
q
r
r
t
t is the square root and
p
p
i
i represents
p. General speaking and except some special cases, when a function is
applied to a 1-by-1 scalar, the result is a scalar, when applied to a row or
column vector is a row or column vector and when applied to a matrix the
output is again a matrix. This happens because Matlab applied the build-in
Kommentare zu diesen Handbüchern