Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 4 Write a user-defined MATLAB function that determines the dot product o

ID: 3593074 • Letter: P

Question

Problem 4 Write a user-defined MATLAB function that determines the dot product of two vectors. For the function name and arguments use D7 = da rofmu. The input arguments to the function are two vectors. The output D is the result (a scalar). Do not use dot building function. Make sure to use for loop. Use the function dotpro for determining the dot product of a. Vectors a = 3it 1 1) and b = 14i-73j b. Vectors c =-Gi + 14.2j + 3k and d = 631-8-5.6k , al and b = [ h, b> , bu is defin D1 abi ed as a,b= Dot product: The dot product of two vectors a = [a,, a,, 2,-1] a 2) + (-5)(-1) = 4-6 + 5-3 r example a=

Explanation / Answer

Dot Product of Real Vectors

Try this Example

Create two simple, three-element vectors.

Calculate the dot product of A and B.

The result is 8 since

C = A(1)*B(1) + A(2)*B(2) + A(3)*B(3)

Dot Product of Complex Vectors

Try this Example

Create two complex vectors.

Calculate the dot product of A and B.

The result is a complex scalar since A and B are complex. In general, the dot product of two complex vectors is also complex. An exception is when you take the dot product of a complex vector with itself.

Find the inner product of A with itself.

The result is a real scalar. The inner product of a vector with itself is related to the Euclidean length of the vector, norm(A).

Dot Product of Matrices

Try this Example

Create two matrices.

Find the dot product of A and B.

The result, C, contains three separate dot products. dot treats the columns of A and B as vectors and calculates the dot product of corresponding columns. So, for example, C(1) = 54 is the dot product of A(:,1) with B(:,1).

Find the dot product of A and B, treating the rows as vectors.

In this case, D(1) = 46 is the dot product of A(1,:) with B(1,:).

Dot Product of Multidimensional Arrays

Try this Example

Create two multidimensional arrays.

Calculate the dot product of A and B along the third dimension (dim = 3).

The result, C, contains four separate dot products. The first dot product, C(1,1) = 106, is equal to the dot product of A(1,1,:) with B(1,1,:).

Input Arguments

collapse all

A,B — Input arrays
numeric arrays

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote