You are on page 1of 1

Linear Equation Solver Using LU Factorization

Ax=c
Given A and c, find x
% Generic Linear Equation Solver
% MATLAB does all of the work, you just enter the data.
% CHANGE, c( ), a( ) as necessary to suit your problem.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
c = [2;8;1;2];
a = [2,-1,0,1;-2,2,0,-3;4,1,3,-1;0,-1,-2,5];
% LU factorization to find solution:
w = a\c;
w

Linear Equation Solver Using Inverse Matrix


Ax=c
Given A and c, find x
% Generic Linear Equation Solver
% MATLAB does all of the work, you just enter the data.
% CHANGE, c( ), a( ) as necessary to suit your problem
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
c = [2;8;1;2];
a = [2,-1,0,1;-2,2,0,-3;4,1,3,-1;0,-1,-2,5];
% Inverse matrix to find solution LU factorization:
w = inv(a)*c;
w
end

You might also like