Transcript MATLAB
MATLAB Determinants and Matrices 1 From Format Mesh Analysis 11I1 - 3I2 - 8I3 = 15 -3I1 + 10I2 - 5I3 = 0 -8I1 - 5I2 + 23I3 = 0 2 Solve by determinants (Set up Matrix A & B) %Defines the coefficient matrix A A=[11,-3,-8;-3,10,-5;-8,-5,23;] A= 11I1 - 3I2 - 8I3 = 15 -3I1 + 10I2 - 5I3 = 0 -8I1 - 5I2 + 23I3 = 0 11 -3 -8 -3 10 -5 -8 -5 23 %defines the vector B B=[15;0;0] B= 15 0 0 3 Solve by determinants (Set up Denominator matrix) %defines the I1 determinant D1=A; D1(:, 1)=B D1 = %defines the I1 determinant D3=A; D3(:, 3)=B D3 = 15 -3 -8 0 10 -5 0 -5 23 11 -3 -3 10 -8 -5 15 0 0 %defines the I2 determinant D2=A; D2(:, 2)=B D2 = 11 -3 -8 15 -8 0 -5 0 23 4 Solve By Determinants (Calculate Currents) %Calculates I1 I1=det(D1)/det(A) I1 = 2.6327 %Calculates I2 I2=det(D2)/det(A) I2 = 1.3998 %Calculates I2 I3=det(D3)/det(A) I3 = 1.2200 5 Total Determinant Program 11I1 - 3I2 - 8I3 = 15 -3I1 + 10I2 - 5I3 = 0 -8I1 - 5I2 + 23I3 = 0 I1 = 2.6327 I2 = 1.3998 I3 = 1.2200 %This program solves for I1, I2, and I3 diary EENG1920e.dat %Defines the coefficient matrix A A=[11,-3,-8;-3,10,-5;-8,-5,23;]; %defines the vector B B=[15;0;0]; %defines the I1 determinant D1=A; D1(:, 1)=B; %defines the I2 determinant D2=A; D2(:, 2)=B; %defines the I3 determinant D3=A; D3(:, 3)=B; %Calculates I1 I1=det(D1)/det(A) %Calculates I2 I2=det(D2)/det(A) %Calculates I2 I3=det(D3)/det(A) diary 6 Solve By Matrices %Defines the A Matrices A=[11,-3,-8;-3,10,-5;-8,-5,23;]; A= 11 -3 -8 -3 10 -5 -8 -5 23 %Defines the B Matrices B=[15;0;0] B= % solve for the loop currents I1 and I2 I = inv(A)*B I= 2.6327 1.3998 1.2200 15 0 0 7 Total Matrices Program 11I1 - 3I2 - 8I3 = 15 -3I1 + 10I2 - 5I3 = 0 -8I1 - 5I2 + 23I3 = 0 %This program solves for I1, I2 and I3 diary EENG1920d.dat %Defines the A Matrices A=[11,-3,-8;-3,10,-5;-8,-5,23;] %Defines the B Matrices B=[15;0;0] % solve for the loop currents I1 and I2 I = inv(A)*B diary I= 2.6327 1.3998 1.2200 8