%Exa = 1;

switch Exa
case {1}
  % define the matrix and RHS vector
  A = [1 2 3; 4 5 6; 7 8 10]
  b = [1; 2; 4]

  % solve the system
  x1 = A\b
  % verify the solution
  difference = A*x1 - b

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case {2}
  % compute LU factorization
  [L,U,P] = lu(A)
  % solve the system
  x2 =  U\(L\(P*b))

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case {3}
  A = [1 2 3; 4 5 6; 7 8 9]
  b = [1; 2; 4]
  x3 = A\b
  % verify
  difference = A*x3 -b

  [L,U,P] = lu(A)
  %% find RHS for U*x = y
  y = L\(P*b)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case {4}
% 4 equations for 2 unknowns, system is over-determined
  A = [1 2;
       4 5;
       9 8;
       3 6]
  b = [1; 2; 4; 0]

  x4 = A\b
case {5}
% 2 equation for 3 unknowns, system is under-determined
  A = [1 2 1; 3 4 5]
  b = [1;1]

  x5 = A\b
% find all solutions of the homogeneous problem
  n = null(A)
end%switch
