Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %% Angle Between Vectors
- % Uses the dot product to calculate the angle between vectors
- a = input('Use brackets to enter the first vector\n');
- b = input('Use brackets to enter the second vector\n');
- MagA = sqrt(sum(a.^2));
- MagB = sqrt(sum(b.^2));
- thetad = acosd(dot(a,b)/(MagA*MagB));
- thetar = acos(dot(a,b)/(MagA*MagB));
- fprintf('The angle between the vectors is %.4f deg and %.4f rad', thetad, thetar);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement