Problem 6: Write MATLAB programs to do the following a. Calculate the magnitude
ID: 668935 • Letter: P
Question
Problem 6: Write MATLAB programs to do the following a. Calculate the magnitude of any size vector b. Calculate the angles that a 3 - dimensional vector makes with the Cartesian coordinate axes c. Calculate the dot product of any two vectors of any size d. Calculate the cross product of two, 3 - dimensional vectors In your hard copy submission, show some test cases that you ran using your code for every section of this problem. You need to show what inputs you gave the program, and what output it gave you.Explanation / Answer
% vector of size 5
x = linspace(1,5,5);
% angle with Cartesian System;
vec = [5 6 7];
sys = [0 0 0];
angle = atan2(norm(cross(vec,sys)), dot(vec,sys));
% dot product of two vectors
A = [4 -1 2];
B = [2 -2 -1];
C = dot(A,B);
% Cross product of two vectors
A = [4 -1 2];
B = [2 -2 -1];
C = cross(A,B);