1.0

1.0 | 1 rating Rate this file 15 Downloads (last 30 days) File Size: 1.55 KB File ID: #26775

LU decomposition

by Timothee

 

24 Feb 2010

This program obtains the LU decomposition of a matrix using Crout’s Method

| Watch this File

File Information
Description

This program will obtain the LU decomposition for any square matrix. The LU decomposition method consists of finding the L and U matrices that will satisfy the equation A=L*U, A being a square matrix.

Once L and U found, in order to solve for x, we can rewrite the equation A*x=B as L*x_star=b (Eq.1) where x_star=U*x (Eq.2).

Then we can find x_start by using forward substitution on Equation 1 and finally solve for x using backward substitution on Equation 2.

MATLAB release MATLAB 7.9 (2009b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
24 Feb 2010 Stefan

Some comments:

- insufficient H1 line

These lines:

check=int8 (L*U)

if check==A
    disp(sprintf (' the equation L*U=A is correct '))
else
    disp(sprintf ('error'))
end

will almost always state an error, because of the casting. Why did you do it that way?

With this sample data:

A=[0 2;3 4];
B=[5;6];

your function gives:

x_soln =

   NaN
   NaN

There is just no pivoting. You didn't limit the usage to strictly regular matrices A. No error check supplied.

Regards,
Stefan

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
mathematics Timothee 24 Feb 2010 09:34:46

Contact us at files@mathworks.com