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

Do not use the MATLAB functions or the matrix multiplication operator (*) or tra

ID: 3723336 • Letter: D

Question

Do not use the MATLAB functions or the matrix multiplication operator (*) or transpose operator ( ) for the following problem. You can use * to multiply scalars.

7. Let a and b be three-dimensional vectors that are entered from input statements. Write a MATLAB script that performs: 1. the dot product between the two vectors; and 2. the cross product a × b. Do not use the built-in MATLAB functions.

The output should be:

The dot product of [xx.xx, xx.xx, xx.xx] and [xx.xx, xx.xx, xx.xx] is xx.xx.

The cross product of [xx.xx, xx.xx, xx.xx] and [xx.xx, xx.xx, xx.xx] is [xx.xx, xx.xx, xx.xx].

The cross product of vectors (a1, a2, a3) and (b1, b2, b3) can be calculated as:

(a2b3 – a3b2)i + (a3b1 – a1b3)j + (a1b2 – a2b1)k or [(a2b3 – a3b2), (a3b1 – a1b3), (a1b2 – a2b1)]

Explanation / Answer

SourceCode:

%input v1= [a1,b1,c1];v2= [a2,b2,c2]

%for dot product

d1=a1*a2+b1*b2+c1*c2;

%For cross product we have output v3

v3 = [a3,b3,c3];

a3 = b1*c2-c1*b2;

b3 = a2*c1-a1*c2;

c3 = a1*b2-b1*a2;

% Answers are in d1 for dot product and v3 for cross product

%you can either write a1 or v[0] for it as it is like an array defined in matlab.

%So if required u can change in d1 function a1=v[0] ,a2=v[1]. a3 =v[2]. Also This is generic function so you should give input with some numbers like v = [1,2,3] for examples. Please check that you are giving inputs as numbers/ Real Numbers.

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