You are on page 1of 4

MATLAB ACTIVITY 6 – Dot Product & Orthogonal in MATLAB

Enter the MATLAB syntax you used and MATLAB output in the space provided

1. Find the length, distance, angle between v=[ 1 4 −1 ] , w=[ 7 2 0 ]

Syntax:>> v1=[1 4 -1]; w1=[7 2 0];

>> v1length=norm(v1)

Output: v1length =

4.2426

Syntax:>> w1length=norm(w1)

Output: w1length =

7.2801

Syntax:>> distance=norm(v1-w1)

Output: distance =

6.4031

Syntax:>> cosine_theta=(dot(v1,w1))/(norm(v1)*norm(w1))

Output: cosine_theta =

0.4856

Syntax:>> theta=acosd(cosine_theta)

Output: theta =

60.9454

The length of vectors v and w are 4.2426 and 7.2801 while the distance between the two
vectors is 6.4031 while the angle between them in terms of degrees is 60.9454°
2 4

2. Determine if
not.
v=
−1
0
6
[] [] , and
w=
2
3
−1 are orthogonal. Explain why they are orthogonal or why

Syntax:>> v2=[2;-1;0;6];w2=[4;2;3;-1];
>> orthogonal=dot(v2,w2)

Output: orthogonal =
0

Bases on the result, the dot product if v and w is 0 wherein two vectors are orthogonal
if the dot product of two vectors is equal to zero. Therefore, in this case the given
vectors are orthogonal.

B. Let a=[ 3 −2 1 ] , Find a value for k so that the dot product of a with b=[ k 1 4 ] is zero. Verify
your result in MATLAB. Enter your solutions and MATLAB output in space provided.

Syntax:>> a=[3 -2 1]; b=[-2/3 1 4];


>> B_answer=dot(a,b)

Output: B_answer =

0
−2
Therefore, the value of k is equal to because it the dot product of a with b is equal
3
to zero.

C. For each of the following vectors v, compute dot(v,v) in MATLAB. Enter the MATLAB syntax you used
and MATLAB output in the space provided

1.

Syntax :>> v=[4 2 -3];

>> v_ans=dot(v,v)

Output: v_ans =

29

The dot product of v with v is 29.

2.

Syntax:>> v=[-9 3 1 0 6];

>> v_ans=dot(v,v)

Output: v_ans =

127

The dot product of v with v is 127.


Syntax:>> v=[1;2;-5;-3];

>> v_ans=dot(v,v)

Output: v_ans =

39

The dot product of v with v is 39.

Describe and differentiate the dot product of each vector

The dot product of the first given vector with itself is equal to 29 while the dot product of the second given
vector with itself is equal to 127 and the dot product of the third given vector with itself is equal to 39. I noticed
that the vector on the first given number has 3 components which means that the vector is in 3-space. I also
noticed that the dimension of the vector matrix is 1x3 which is called as a row vector. On number 2, I noticed
that the vector has five components, so it means that it is in 5-space, just like on number 1, it is a row vector
since the vector matrix is 1x5. However, for the number 3 the dimension is 4x1, so it means that it is a column
vector. I noticed that the first and the second given number has a least dot product since it only has 3
components, and the number of each entry is less than 5. The second given vector has the highest dot product
since it has the greatest number of components among the others. Lastly is the third given vector, I noticed that
has a higher dot product since it has a greater number of components compare to the first vector and the value
of each entry is less than 6.

“I affirm that I shall not give or receive any unauthorized help on this assignment and that all work is my
own”

You might also like