Activity 2 Vectors1 - TUGADE
Activity 2 Vectors1 - TUGADE
Activity 2 Vectors1 - TUGADE
Dasmariñas, Cavite
COLLEGE OF ENGINEERING, ARCHITECTURE, AND TECHNOLOGY
MATLAB BASICS
ACTIVITY 2
VECTORS
OBJECTIVES
To Learn about vector and array properties in MATLAB, methods to create row and
column vectors, mathematical functions with vectors, and element-by-element vector
operations.
PROCEDURE
MATLAB has two types of vectors (row and column) and offers several methods for creating
vectors for use. We will use a naming convention that vector variable names contain only lower
case letters.
Enter the following at the Command Line prompt (use single quote key)
» vec1tr = vec1'
vec1tr =
3
9
-4
The row vector is transposed to a column vector.
Enter the following at the Command Line prompt (use single quote key)
» vec1trtr = vec1tr'
vec1trtr =
3 9 -4
EXERCISES:
1. Equation of a line. The equation of a line is given by y mx b where m is the slope (a
scalar)
and b is the intercept (also a scalar).
2. Vector multiplication, division, and exponentiation. Create a vector, g, with 10 evenly spaced
elements starting at 1 and ending at 10. Compute the following with vector operations:
3. Parametric equation for a circle. The parametric equation for a circle is x r cos(Ø) and y
r sin(Ø)where r is the radius and Øis the angle of rotation counter-clockwise from the
positive x-axis. Defined this way, x and y satisfy the equation x2 y2 r 2 . Show this using
MATLAB. Use linspace to create an angle vector, theta, with values (0, π/3, 2π/3, π, 4π/3,
5π/3, 2π).
Compute the corresponding x- and y-vectors for r = 5. Show that the x- and y-vectors satisfy
the equation of a circle.
1A-
1B-
1C-
1D-
2A-
2B-
2C-
3A-