Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
例如,
magic(3) x [1,2,3] 给出:
-9 -18 15 1 -2 1 23 -10 -1
听起来您想要做的是计算 3×3 矩阵的每一行与 1×3 向量的叉积。为了使用函数CROSS,两个输入的大小必须相同,因此您必须使用函数REPMAT复制 1×3 向量,使其具有三行。然后沿列执行叉积:
>> A = magic(3); >> B = [1 2 3]; >> C = cross(A,repmat(B,size(A,1),1),2); C = -9 -18 15 1 -2 1 23 -10 -1