>> t=0:.2:12;
>> G=tf(1,[2 1])
%time constant = 2, pole at -1/2
Transfer function:
1
-------
2 s + 1
>> y1=step(G,t);
>> G=tf(1,[1 1]) %time constant = 1, pole at -1
Transfer function:
1
-----
s + 1
>> y2=step(G,t);
>> G=tf(1,[1/2 1]) %time constant = 1/2, pole at -2
Transfer function:
1
---------
0.5 s + 1
>> y3=step(G,t);
>> G=tf(1,[1/4 1]) %time constant = 1/4, pole at -4
Transfer function:
1
----------
0.25 s + 1
>> y4=step(G,t);
>> plot(t,y1,t,y2,t,y3,t,y4)
>> legend('pole at -1/2','pole at -1','pole
at -2','pole at -4')
Transfer function:
0.5
---------
1.5 s + 1
>> y1=step(G,t);
>> G=tf(1,[1.5 1]) %Steady state gain = 1
Transfer function:
1
---------
1.5 s + 1
>> y2=step(G,t);
>> G=tf(2,[1.5 1]) %Steady state gain = 2
Transfer function:
2
---------
1.5 s + 1
>> y3=step(G,t);
>> plot(t,y1,t,y2,t,y3)
>> legend('K = 0.5','K = 1','K = 2')
Transfer function:
1
---------------
s^2 + 0.4 s + 1
>> damp(G)
Eigenvalue
Damping Freq. (rad/s)
-2.00e-01 + 9.80e-01i 2.00e-01
1.00e+00
-2.00e-01 - 9.80e-01i 2.00e-01
1.00e+00
>> %The Eigenvalue is the pole of G
>> y1=step(G,t); %Save this step response for plotting later
>> %Repeat calculation wtih other damping ratios
>> G=tf(1,[1 0.8 1])
%damping ratio = 0.4
Transfer function:
1
---------------
s^2 + 0.8 s + 1
>> damp(G)
Eigenvalue
Damping Freq. (rad/s)
-4.00e-01 + 9.17e-01i 4.00e-01
1.00e+00
-4.00e-01 - 9.17e-01i 4.00e-01
1.00e+00
>> y2=step(G,t);
>> G=tf(1,[1 2 1]) %Critically damped
Transfer function:
1
-------------
s^2 + 2 s + 1
>> pole(G)
ans =
-1
-1
>> y3=step(G,t);
>> G=tf(1,[1 4 1])
%Overdamped
Transfer function:
1
-------------
s^2 + 4 s + 1
>> pole(G)
ans =
-3.7321
-0.2679
>> y4=step(G,t);
>> plot(t,y1,t,y2,t,y3,t,y4)
>> legend('zeta = 0.2','zeta = 0.4','zeta
= 1','zeta = 2')
Chapter 3 Review Problems
>> %Review problem 9
>> td=3;
>> P1=tf([-td/2 1],[td/2 1]);
>>
>> %Plotting deviates from text so we can superimpose
the step input
>> t=0:.2:10;
>> y=step(P1,t);
>> plot(t,y) %Note
how the response starts from negative values
>> hold
Current plot held
>> plot([0 3 3 9],[0 0 1 1])
%Plot a step input with a dead time of 3
>> title('Compare a first order Pade approx
with a real time delay')
>> t=0:0.1:50;
>> taup=10;
>> G1=tf(1,[taup 1]);
>>
>> %y1 is first order with Pade approx of dead
time
>> y1=step(G1*P1,t);
>> %y2 is just the function. Will be plotted
with a shifted time axis
>> y2=step(G1,t);
>> t2=t+td;
>> plot(t,y1, t2,y2);
>> hold
Current plot held
>> plot([0 20],[0 0]);
>> legend('Using Pade approx','Theoretical
time delay')
>> %Note how the Pade approx has a dip at the
beginning
ans =
-10.0000
-2.0000
-1.0000
-0.3333
>> G2=tf(q,p2);
% Second order reduced model
>> G4=tf(q,p4);
%The original full order function
>> t=0:0.2:18;
>>
>> %Plotting here deviates from text for a better
image
>> y4=step(G4,t);
>> td=0.1+0.5;
>> P1=tf([-td/2 1],[td/2 1]);
>> y2=step(P1*G2,t);
%Second order with dead time approx.
>> plot(t,y4,t,y2)
>> %We'll do this again below with the first order
approximation
>>
>> %We now do the more common first order with
dead time approximation
>> td=1+0.1+0.5;
>> P1=tf([-td/2 1],[td/2 1]);
>> G1=tf(q,[3 1]);
% First order approximation
>> y1=step(P1*G1,t);
>> plot(t,y4,t,y2,t,y1)
>> legend('Full model','2nd order with
dead time','1st order with dead time')
>> %Review Problem 11 - observe the effects of
multicapacity models
>> tau=3;
>> G=tf(1,[tau 1]);
>> step(G); %First
order function
>> hold
Current plot held
>> step(G*G); %Second
order function
>> step(G*G*G) %Third
oder function
>> step(G*G*G*G)
%Fourth order function
>> step(G*G*G*G*G)
%Fifth order function
Transfer function:
1
--------
12 s + 1
>> y1=step(G1,t);
%Using a time shift axis to do the first order
>> t1=t+3; %
with dead time plot
>> plot(t,y5, t1,y1)
>> %Review Problem 12
>> tz=3;
>> G=tf([tz 1],[5 1]);
>> step(G);
>> %But we can do better and recreate Fig.
3.4
>> G=tf([4 1],[2 1])
Transfer function:
4 s + 1
-------
2 s + 1
>> step(G)
>> hold
Current plot held
>> G=tf([3 1],[2 1])
Transfer function:
3 s + 1
-------
2 s + 1
>> step(G)
>> G=tf([2 1],[2 1]) %Case of pole-zero cancellation
Transfer function:
2 s + 1
-------
2 s + 1
>> step(G) %This is the horizontal line at y=1
>> G=tf([-1 1],[2 1])
Transfer function:
-s + 1
-------
2 s + 1
>> step(G)
>> G=tf([-2 1],[2 1])
Transfer function:
-2 s + 1
--------
2 s + 1
>> step(G)
>> G=tf([-4 1],[2 1])
Transfer function:
-4 s + 1
--------
2 s + 1
>> step(G)
>> %Review Problem 13 - parallel functions
>> k1=3;
>> k2= -1; %k2 is negative
>> tau1=2; tau2=0.5;
>> %To repeat calculations with different
values as in the text,
>> %it is best to put the following
statements in an M-file.
>> %Or copy-and-paste from a scratch file.
>> k=k1+k2;
>> tz=(k1*tau2+k2*tau1)/k;
>> G=tf(k*[tz 1],
conv([tau1 1],[tau2 1]) );
>> step(G);
>> -1/tz
%Calculate the zero
ans =
4
>> G1=tf(k1, [tau1 1]);
>> G2=tf(k2, [tau2 1]);
>> G=G1+G2;
>> step(G,'-', G1,'--',G2,'--')
>> %Style: '-' means solid,
'--' means dashed