Do not use the MATLAB functions or the matrix multiplication operator (*). Let a
ID: 3004673 • Letter: D
Question
Do not use the MATLAB functions or the matrix multiplication operator (*). 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].
Explanation / Answer
%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
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.