Effacer les filtres
Effacer les filtres

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.

2 vues (au cours des 30 derniers jours)
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 commentaires
darova
darova le 24 Sep 2019
You don't check if your multipliear is inf (I(j,j) == 0) ?
Athul Prakash
Athul Prakash le 9 Oct 2019
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.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Sparse Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by