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
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개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!