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

(a) Create a input defined function that asks the user to input a three dimensio

ID: 2268346 • Letter: #

Question

(a) Create a input defined function that asks the user to input a three dimensional vector named V.

(b) Create another input defined function that asks the user to input a second three dimensional vector named W.

(c) Compute the Dot product of the two vectors and calculate the angle between the two vectors. Make sure to convert the angle from radians to degrees after the calculation. (Hint: when calculating the magnitudes, you may have to use indexing). (

d) Compute the cross product V × W and W × V . (Hint: look up the function cross()).

(e) Compute the vector and scalar projections of V onto W and of W onto V.

(f) Display the vectors and the answers such that the user can understand what each answer means and use a precision field of 2 digits for every answer displayed. This is, two digits after the decimal point. Do not change the width field. Include a comment on each answer using the fprintf() function. Do not forget units for the angles. Make sure that the angle that you display is in degrees. (Hint: look up fprintf() in MATLAB to see how to display a vector of three dimensions in one line. You will also have to use linefeed in order to have a decent presentation of your results).

(g) Comment on what is the difference between the two cross products done in Part (d)?

Explanation / Answer

matlab code

%for getting inputs
clear all;clc;
%digits(3);%precision field of 2 digits
disp('Enter vector V and W');
v=input('Enter vector V ');%for part a
w=input('Enter vector W ');%for part b
%for part c
dp=dot(v,w);%dot product of V amd W
mv=norm(v,2);%magnitude of vector a
mw=norm(w,2);%magnitude of vector a
theta=acosd(dp/(mv*mw));
%for part d
c1=cross(v,w);%cross product of V and W
c2=cross(w,v);%cross product of W and V
%for part e
pv=(dp/(mw^2)).*w;%vector projection of V on W
mpv=norm(pv,2);%scalr projection of V on W
pw=(dp/(mv^2)).*v;%vector projection of W on V
mpw=norm(pw,2);%scalr projection of W on V
%for part f result
fprintf('vector V = (%0.2f, %0.2f, %0.2f). ',v);
fprintf('vector W = (%0.2f, %0.2f, %0.2f). ',w);
fprintf('vectors dot product of V and W = %.2f. ',dp);
fprintf('Angle between vector V and W = %.2f. ',theta);
fprintf('vectors cross product of V and W = (%0.2f, %0.2f, %0.2f). ',c1);
fprintf('vectors cross product of W and V = (%0.2f, %0.2f, %0.2f). ',c2);
fprintf('vector projection of V on W = (%0.2f, %0.2f, %0.2f). ',pv);
fprintf('vector projection of W on V = (%0.2f, %0.2f, %0.2f). ',pw);
fprintf('scalr projection of V on W = %.2f. ',mpv);
fprintf('scalr projection of W on V %.2f. ',mpw);

g) magnitude of two cross product is equal but their directions are opposite to each other this is the only difference between two cross products.