Posted By:
31 Mar, 2013 8:54 am PDT

LU factorization to find inverse of a matrix in Matlab

I have a set of following linear equations:
10x + 2y - z = 27
-3x - 6y + 2z = -61.5
x + y +5z = 21.5

I want to use the lu function to perform LU factorization on A such that LU=A.
how can I use L and U matrices to find the inverse of A.

Attachment:None


% 10x + 2y - z = 27
% -3x - 6y + 2z = -61.5
% x + y +5z = 21.5

% LU factorization
A=[10 2 -1;
    -3 -6 2;
    1 1 5];
 b = [27;
     -61.5;
     21.5];


% perform LU factorization using matlab function
 [L U]=lu(A);

 % solving Ax=[1; 0; 0], Ax=[0; 1; 0], and Ax=[0; 0; 1]
 d=L\[1;0;0];
 col1 = U\d;
 d=L\[0;1;0];
 col2 = U\d;
 d=L\[0;0;1];
 col3 = U\d;
[col1 col2 col3]
 Please watch the video for details
Attachment: LU_factorization.m
Was it useful?  




Please login to reply to this problem.