usv.m

来自「用matlab写的五种矩阵求逆程序」· M 代码 · 共 19 行

M
19
字号
function inverse = usv(A)
%USV 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

[U, S, V] = svd(A, 0);

for i = 1:size(S, 1)
    S(i, i) = 1 / S(i, i);
end

inverse = V * S * U';

⌨️ 快捷键说明

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