% This code illustrates row operations and % Gauss elimination. disp('Solution of Ax = d via Gauss elimination') disp('Press a key to continue,') A = [2 6 8;4 15 19;2 0 3] pause d = [ 16 38 6]' pause Aug_mat = [A d] pause E21 = eye(3); E21(2,1) = -2 pause disp('E21 [A d] = ') disp(E21*[A d]) pause E31 = eye(3); E31(3,1) = -1 pause disp('E31 (E21 [A d]) = ') disp(E31*E21*[A d]) pause E32 = eye(3); E32(3,2) = 2 pause disp('E32 (E31 (E21 [A d])) = ') disp(E32*E31*E21*[A d]) UU = E32*E31*E21*[A d] disp('This completes the row operation step of Gauss-El.') pause disp('The backward substitution step can be done by \') pause disp('UU(1:3,1:3)\UU(1:3,4)') pause sol = UU(1:3,1:3)\UU(1:3,4) disp('Also \ can do both steps of Gauss-El.') disp('A\d') pause sol = A\d pause disp('The solution of the steady-state two mixing tank is as follows:') Atank = [-1/3 1/12; 1/3 -1/3] pause dtank = [-1 -2]' pause disp('soltank = Atank\dtank ') soltank = Atank\dtank pause disp('The solution of the two loop resistor ciruit is as follows:') disp('Let R1 = 1, R2 = 2 , R3 = 3, E1 = 10 and E2 = 20.') Acircuit = [1 -1 1;1 0 -3;0 -2 -3] pause dcircuit = [0 10 20]' pause disp('solcircuit = Acircuit\dcircuit ') solcircuit = Acircuit\dcircuit pause disp('The solution of single node structure is as follows:') theta = pi/6 c = cos(theta); s = sin(theta); Anode1 = [c 1; -s 0] pause dnode1 = [0 -100]' pause disp('solnode1 = Anode1\dnode1 ') solnode1 = Anode1\dnode1