如何编写可以计算两个向量的叉积的代码?

时间:2019-09-24 02:35:44

标签: matlab

如何编写可以计算两个向量的叉积的代码?这两个向量都是1×5向量 起初,我编写类似

的代码
a=randn(1,5);
b=randn(1,5); 
cross_c=cross(a,b)

a=randn(1,5);
b=randn(1,5);
cross_c=cross(a,b,5)

但是窗口总是向我显示

A and B must be of length 3 in the
dimension in which the cross
product is taken.

我该如何编写代码来计算这两个1 x 5向量的叉积?

我的matlab版本是2015b

1 个答案:

答案 0 :(得分:2)

两个向量a和b的叉积仅在三维空间中定义,并由a×b表示。 https://en.wikipedia.org/wiki/Cross_product