%
%   LUDEMO_LESSON6.M  LU Decomposition Demo in Lesson 6 Lecture Notes
%
%   This file just illustrate some of the concepts for LU decomposition as 
%   discussed in the Lecture Notes.  Note that this uses the "revised" system model
%   just so that the permutation matrix will not be the identity matrix.
%
%   File prepared by J. R. White, UMass-Lowell (last update:  Nov. 2017)
%

      clear all,   close all
      format compact
%
%   define matrices for demo
      disp('Matrices for the LU demo'),  A = [0 -1 3;-1 3 -2;3 -2 0],  b = [-5 9 -7]'   
%
%   illustrate use of lu function
      disp('Output from lu(A) function'), [L,U,P] = lu(A)
      disp('Intermediate y solution'), y = L\(P*b)
      disp('Solution vector x for revised system'), x = U\y
%
%   end of program