Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % Given vectors
- A = [5, 3, 1];
- B = [-1, 2, 0];
- % Magnitudes
- mag_A = norm(A);
- mag_B = norm(B);
- % Dot products of A and B
- dot_AB = dot(A, B);
- %Cosine
- cos_theta = dot_AB/(mag_A*mag_B);
- %Angle in degree
- theta = acosd(cos_theta);
- %Result
- fprintf('The angle between vectors A and B is %.2f degrees\n', theta);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement