Professional Documents
Culture Documents
Ece340 MATLAB Soln6 s13
Ece340 MATLAB Soln6 s13
MP6p1, % Execute the commands for Matlab Problem Set #6, Problem #1. % MP6p1.m % % Matlab Problem Set #6 % Problem #1. % % Define the matrices from Problem 10.2-1. % I will create my own output matrix (see the solutions) to explicitly % identify the voltage across the capacitor and the current through the % inductor. A=[-12/5,6/5;-3/5,-6/5], % System matrix. A = -2.4000 -0.6000 1.2000 -1.2000
B=[2/5;3/5], % Input matrix. B = 0.4000 0.6000 C=[1,0;0,1], % My own Output matrix to plot the variables of interest. C = 1 0 0 1
sys1=ss(A,B,C,[0;0]), % State Space Object in Matlab. a = x1 x2 b = x1 x2 c = y1 y2 d = u1 x1 1 0 x2 0 1 u1 0.4 0.6 x1 -2.4 -0.6 x2 1.2 -1.2
y1 y2
0 0
Continuous-time model. figure(1) step(sys1) % Plot the step response for this system. xlabel('Time'),ylabel('Response Variables') title('Step Response for Matlab Set #6 Problem #1') % Recall the first output was defined to be the capacitor voltage and the % second output was defined to be the inductor current. % % In the steady-state for this constant input, the inductor will short out % and the capacitor will open up. Thus, the limiting circuit will be a one % ohm resistor in series with a two ohm resistor. The 1 volt input will be % divided among the two resistors with a voltage drop of (1/(1+2)) volts % across the 1 ohm resistor and a current (which is the inductor current) % of 1/(1+2) amperes. Both output values approach the same final value of % 1/3 even though one is a voltage and the other variable is a current. % % The eigenvalues of "A" or the poles of the system will provide insight % into the speed of the system response (or how quickly the system will % reach a steady-state value). eA=eig(A), % Display the eigenvalues of the system matrix. eA = -1.8000 + 0.6000i -1.8000 - 0.6000i p1=pole(sys1), % Or equivalently, display the poles of the system. p1 = -1.8000 + 0.6000i -1.8000 - 0.6000i echo off diary off
Figure 1 (below):
0.3
To: Out(1) Response Variables To: Out(2)
0.2
0.1
0 0.4
0.3
0.2
0.1
0.5
2.5
3.5
Problem #2.
MP6p2, % Execute the commands for Matlab Problem Set #6, Problem #2. % MP6p2.m % % Matlab Problem Set #6 % Problem #2. % % Define the matrices from Problem 10.2-2. A=[-10,-2;1,-1], % System matrix. A = -10 1 -2 -1
Continuous-time model. figure(2) step(sys2) % Plot the step response for this system. xlabel('Time'),ylabel('Output') title('Step Response for Matlab Set #6 Problem #2')
legend('Inductor Voltage') % sys2tf=tf(sys2), % Display the transfer function for this circuit. Transfer function: 6 s --------------s^2 + 11 s + 12 % p2=pole(sys2tf), % Display the poles of the system. p2 = -9.7720 -1.2280 z2=zero(sys2tf), % Display the zeros of the system. z2 = 0 % figure(3) bode(sys2), % Have Matlab plot the Bode plot for this system. % % This system exhibits a band-pass filter behavior as seen from the Bode % plot. echo off diary off
Figure 2 (below):
Step Response for Matlab Set #6 Problem #2 0.5 Inductor Voltage 0.45 0.4 0.35 0.3
Output
0.5
1.5
3.5
4.5
Figure 3 (below):
10
-1
10
10
10
10
Frequency (rad/sec)
Problem #3:
MP6p3, % Execute the command for Matlab Problem Set #6, Problem #3. % MP6p3.m % % Matlab Problem Set #6 % Problem #3. % % I will first check my state space representation by finding the transfer % function from my state space matrices. % I will then use that T.F. to produce the answers for Problem #3. % Define the matrices. A=[-7,1;-12,0], % System matrix. A = -7 -12 1 0
Continuous-time model. sys3tf=tf(sys3), % Find the T.F. and compare with the original T.F.
Transfer function: 3 s + 10 -------------s^2 + 7 s + 12 figure(4) step(sys3tf) % Plot the step response for this system. xlabel('Time'),ylabel('Output') title('Step Response for Matlab Set #6 Problem #3') % % p3=pole(sys3tf), % Display the poles of the system. p3 = -4 -3 z3=zero(sys3tf), % Display the zeros of the system. z3 = -3.3333 % figure(5) bode(sys3), % Have Matlab plot the Bode plot for this system. echo off diary off
Figure 4 (below):
Step Response for Matlab Set #6 Problem #3 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0
Output
0.5
1 Time (sec)
1.5
2.5
Figure 5 (below):
Bode Diagram 0
-10
-20
-30
-40 0
-45
-90 10
-1
10
10 Frequency (rad/sec)
10