Saturday, December 28, 2013

Solving a set of linear equations and finding the echelon form using MATLAB (LU or LR Factorization)

% factorization  of a set of n equations n unknowns...
% u + v + w = 6
% u + 2v + 2w = 11
% 2u + 3v - 4w = 3

A = [1 1 1 6; 1 2 2 11; 2 3 -4 3]
[L U] = lu(A);

% U contains the echelon form, or the upper triangular matrix.

U =

    2.0000    3.0000   -4.0000    3.0000
         0        0.5000    4.0000    9.5000
         0         0            7.0000   14.0000

No comments:

Post a Comment