首页 > 解决方案 > 如何找到四个矩阵的行列式

问题描述

A=[1 2;3 4];
B=[5 6;7 8];
C=[8 7;6 5];
D=[4 3;2 1];

E=[det(A(1) B(1);C(1) D(1)) det(A(2) B(2);C(2) D(2));det(A(3) B(3);C(3) D(3)) det(A(4) B(4);C(4) D(4))]

我想得到一个等于的矩阵E

如果A B C D非常大,这手写起来很麻烦。我怎样才能自动做到这一点?

标签: matlabmatrixlinear-algebradeterminants

解决方案


如果A, B, C, 和D, 变大, 但没有更多的矩阵被添加到这个列表中, 下面应该做:

A = rand(20);
B = rand(20);
C = rand(20);
D = rand(20);
E = zeros(size(A)); % initialise E as big as the others
for ii = 1:numel(A) % loop over linear indices
    E(ii) = det([A(ii) B(ii);C(ii) D(ii)]); % build determinant
end

推荐阅读