Contents

Aaron Klapheck

% In class 28-Feb-08
clear, clc, home
fprintf('The date and time: %s \n', datestr(now))
The date and time: 18-Mar-2008 14:45:31 

Notes

Plotting Systems of Equations

go to voyager > pick up box, to get Plot3D.pdf and Graph3D_Circuits.m Talked about Plot3D.pdf

solve the following system of equations for circuit

30I1 - 20I2 - 10I3 = 0 .... (1). -20I1 + 55I2 - 10I3 = 0 ... (2). -10I1 -10I2 + 50I3 = -200 .. (3).

Use graphical approach

 see cell 2. for solution

Use gaussian method

 Ax = b
 see cell 3. for solution

go to voyager > pick up box, to get Different_formats.m

1. 3D Plotting

clear, clc, home
fprintf('The date and time: %s \n \n', datestr(now))

disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('%                                               %')
disp('%         3D Plotting                           %')
disp('%                                               %')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')

x = [0:1:10]; y = [0:10:100];

[X,Y] = meshgrid(x,y);
Z = 3*X + 5*Y;

mesh(X,Y,Z)
The date and time: 18-Mar-2008 14:45:31 
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                               %
%         3D Plotting                           %
%                                               %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

2. Teachers Example of 3D Plotting to Solve 3 Equations

clear, clc, home
fprintf('The date and time: %s \n \n', datestr(now))

disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('%                                               %')
disp('%         Plotting circuit equations            %')
disp('%                                               %')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')


% solve the following system of equations

% 30I1 - 20I2 - 10I3 = 0 .... (1)
% -20I1 + 55I2 - 10I3 = 0 ... (2)
% -10I1 -10I2 + 50I3 = -200 .. (3)

x = [-6:.2:1]; y = [-6:.1:1];
[I2, I3] = meshgrid(x,y);

%  solve all three equations for one variable. Coppied from Graph3D_Circuits.m

solveMatrix([30, -20, -10; -20, 55, -10; -10, -10, 50], [0;0;-200]);

E1 = (20*I2 + 10*I3)/30;
E2 = (-10*I3 + 55*I2)/20;
E3 = (200 - 10*I2 + 50*I3)/10;

surf(I2,I3,E1)
hold on
% view(2) %% this command gives you the top view.
mesh(I2,I3,E2)
surf(I2,I3,E3)
title('Circuit Analysis')
xlabel('i_2 (amps)'), ylabel('i_3 (amps)')
The date and time: 18-Mar-2008 14:45:32 
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                               %
%         Plotting circuit equations            %
%                                               %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Rank of A is:  3 
Rank of [A b] is:  3 
Number of unknows:  3 
system is consistent. 
system is unique. 
Solution is: -3.000000 
Solution is: -2.000000 
Solution is: -5.000000 

3. Use Gaussian Method

clear, clc, home
fprintf('The date and time: %s \n \n', datestr(now))

disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('%                                                       %')
disp('%   Solve Simultanious Equations using Gaus Method      %')
disp('%                                                       %')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')

A = zeros(3);
A = [10, -20, -10; -20, 55, -10; -10, -10, 50];
b = [0; 0; 200];

x = A^-1*b
x = A\b
The date and time: 18-Mar-2008 14:45:33 
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                       %
%   Solve Simultanious Equations using Gaus Method      %
%                                                       %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

x =

  -50.0000
  -20.0000
  -10.0000


x =

  -50.0000
  -20.0000
  -10.0000