Page 204 -
P. 204
7.1.4 MATLAB Representation of the Above Results
MATLAB distinguishes between two kinds of vectors: the column vector and
the row vector. As long as the components of the vectors are all real, the dif-
ference between the two is in the structure of the array. In the column vector
case, the array representation is vertical and in the row vector case, the array
representation is horizontal. This distinction is made for the purpose of
including in a consistent structure the formulation of the dot product and the
definition of matrix multiplication.
Example 7.1
Type and execute the following commands, while interpreting the output at
each step:
V=[1 3 5 7]
W=[1;3;5;7]
V'
U=3*V
Z=U+V
Y=V+W %you cannot add a row vector and a column
%vector
You would have observed that:
1. The difference in the representation of the column and row vectors
is in the manner they are separated inside the square brackets.
2. The single quotation mark following a vector with real components
changes that vector from being a column vector to a row vector,
and vice versa.
3. Multiplying a vector by a scalar simply multiplies each component
of this vector by this scalar.
4. You can add two vectors of the same kind and the components
would be adding by pairs.
5. You cannot add two vectors of different kinds; the computer will
give you an error message alerting you that you are adding two
quantities of different dimensions.
The MATLAB command for obtaining the norm of a vector is norm. Using
this notation, it is a simple matter to define the unit vector in the same direc-
tion as a given vector.
Example 7.2
Find the length of the vector and the unit vector u = [1 5 3 2] and the unit
vector parallel to it.
© 2001 by CRC Press LLC