Linear Equations -- JHU MATLAB Help Page
LINEAR EQUATIONS
Creating a Matrix
Substituting Within a Symbolic Matrix
Manipulating Regular Matrices
Vectors
Scalar Multiplication
Addition of Matrices
Gauss-Jordan Elimination
Reduced Row-Echelon Form
Dot Product
Rank
Number of Solutions
Dot Product
How to
Examples
Exercise
How to:
Finding the dot product in MATLAB is quite easy, no matter what size vector we are dealing with:
dot(first vector, second vector)
MATLAB returns a scalar that is the answer to the dot product. We need not worry whether we have row or column vectors, so long as they have the same number of entries.
Examples:
Let's find the dot product of vectors
v1 = [1 -1 5]
and
v2 = [3 3 0]
, and store it in variable 'd' to use later:
d = dot(v1, v2)
MATLAB tells us that 'd = 0'. This is a special case of the dot product. When our answer is zero, that means that our vectors are
perpendicular
to one another.
We need not store our vectors in variables before we use the dot product. This notation is just fine:
d = dot([1; 2; 3], [3; 2; 1])
Exercise: