% - File name : linear_1.m (Generated by Hee Jung : fall/1999)
% - Solve linear algebric equations using MATLAB's backslash(\) command
% - Source of help on this command can be found in several places:  
%    1) Pratap's MATLAB 5 book
%    2) type help mldivide in the matlab command window
%
% - Problem to solve: find the solution of following set of linear equations
%                        3 * x1 + 5 * x2 + 2 * x3 = 3
%                            x1 +          7 * x3 = 2
%                                     x2 + 3 * x3 = 5
% - How to solve? 
%    : express system of linear equations in the form of Ax = b and then
%    solve with \ command in matlab
% 

clear   % removes all variables from the workspace

% Define A matrix 
A = [3  5  2;
     1  0  7;
	 0  1  3 ];

% Define B vector
b = [3; 2; 5];

% Solve the problem using backslash. you type : 
x = A\b

% You'll get
%   x = [-3.7647; 2.5294; 0.8235] 
%   that means x1 = -3.7647, x2 = 2.5294, x3 = 0.8235

% You can check your solution by typing

A*x

% and noting that you get back the three numbers on the
% right hand side of the equations.



