I am trying to solve the inverse of a matrix A, using the equation AX=I and LU factorization. My lufact function worked originally, but when using to compute the inverse, A and X both end up as identity matrices.

1 次查看(过去 30 天)
I am trying to solve the inverse of a matrix A, using the equation AX=I and LU factorization. My lufact function worked originally, but when using to compute the inverse, A and X both end up as identity matrices.
function [A, X] = lufact(I)
% LUFACT LU factorization
% Gaussian elimination
for j = 1:n-1
for i = j+1:n
A(i,j) = I(i,j) / I(j,j); % row multiplier
I(i,:) = I(i,:) - A(i,j)*I(j,:);
end
end
X = rand(n,n);
end
  2 个评论
Athul Prakash
Athul Prakash 2019-10-9
Not sure that I follow your approach..
You want to find X such that AX=I, but when you factorize I, won't it produce any 2 factors which multiply to I (instead of one of them being A and the other X)?
Also, please share the dimensions of your matrix A.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Linear Algebra 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by