
%  This m-file runs an example of gaussian elimination
%  illustrating the matrix manipulations of MATLAB
%  

clear M
clear N

fprintf(' Hit any key to proceed to the next operation.\n')
pause

fprintf('>> M=[3 -4 -8; 0 2 2]')  % This prints the command about to be performed.
pause

M=[3 -4 -8; 0 2 2]            %  Here the command is entered and performed.
pause

fprintf('>> M=[M;1 -2 -3]')
pause
M=[M;1 -2 -3]
pause

fprintf('>> b=[27 ;-6 ;10]')
pause
b=[27 ; -6 ; 10]
pause

fprintf('>>  M=[M b]')
pause
M=[M b]
pause

fprintf('>>  M(2,:)')
pause
M(2,:)
pause

fprintf('>>  M(:,3)')
pause
M(:,3)
pause

fprintf('>>  M([1 3], :)')
pause
M([1 3], :)
pause

fprintf('>>  N=M')
pause
N=M
pause

fprintf('begin gaussian elimination.\n')
fprintf('subtract 3*(third row) from first.\n ')
pause

fprintf('>>  N(1, :) = N(1,:)-3*N(3, :)')
pause
N(1, :) = N(1,:)-3*N(3, :)
pause

fprintf('interchange first and third rows.\n')
pause

fprintf('>>  N([1 3] , :) =N([3 1], :)')
pause
N([1 3] , :) =N([3 1], :)
pause

fprintf('subtract second row from third.\n ')
pause

fprintf('>>  N(3,:) = N(3,:)-N(2,:)')
pause
N(3,:) = N(3,:)-N(2,:)
pause