⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 complement.m

📁 用matlab写的五种矩阵求逆程序
💻 M
字号:
function inverse = complement(A)
%COMPLEMENT compute the inverse of the input matrix
SIZE = size(A);
if SIZE(1) ~= SIZE(2)
    error('the matrix must be square.');
end

if det(A) == 0
    error('the matrix should be nonsingular.');
end

determinant = det(A);
inverse = zeros(SIZE(1), SIZE(2));

for i = 1:SIZE(1)
    for j = 1:SIZE(2)
        C = A;
        C(i, 1:SIZE(2)) = 0;
        C(1:SIZE(1), j) = 0;
        C(i, j) = 1;
        inverse(i, j) = det(C);
    end
end

inverse = (inverse / determinant)';

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -