cross( ) command or function gives the cross product of vectors or matrices or arrays, after reading this MATLAB cross product topic, you will know the theory and examples.
Syntax:
dot(a,b)
- a and b are two vectors.
Example: To find the cross product of two vectors.
A=[3,20,34] B=[13,2,3] cross(A,B)
Output:
A = 3 20 34 B = 13 2 3 ans = -8 433 -254
Example: To find the cross product of two matrices.
A=[3,20,34;2,3,4;1,2,3] B=[13,2,3;3,4,5;2,6,8] cross(A,B)
Output:
A = 3 20 34 2 3 4 1 2 3 B = 13 2 3 3 4 5 2 6 8 ans = 1 10 17 7 -116 -263 -17 74 158
Explanation:
- Here, the cross product value calculates for the first, second and third corresponding columns of the matrices A and B.