You are on page 1of 26

F17/35020/2013

BRIAN G GACHARI

1. TRANSIENT RESPONSE

a) i) Over dumped system


s = tf('s') % Declaring the transfer fuction will be in a funtion of s
sysOd = 9/(s^2+12*s+9) %Over damped second order system.
step(sysOd) %Choosing the step funtion to be test input
grid
figure(1)

s = s Continuous-time transfer function.

sysOd =

--------------

s^2 + 12 s + 9

Continuous-time transfer function.

Published with MATLAB® R2017a


F17/35020/2013
BRIAN G GACHARI

ii) Critically Damped System


s = tf('s') % Declaring the transfer fuction will be in a funtion of s
sysOd = 9/(s^2+6*s+9) %Critically damped second order system.
step(sysOd) %Choosing the step funtion to be test input
grid
figure(2) %generates the plot

>> transient

s = s
Continuous-time transfer function.

sysOd =

9
-------------
s^2 + 6 s + 9

Continuous-time transfer function.

Published with MATLAB® R2017a


F17/35020/2013
BRIAN G GACHARI

iii) Under dumped system


s = tf('s') % Declaring the transfer fuction will be in a funtion of s
sysOd = 9/(s^2+3*s+9) %Under-damped second order system.
step(sysOd) %Choosing the step funtion to be test input
grid
figure(3) %generates the plot

>> transient

s= s

Continuous-time transfer function.

sysOd =

-------------

s^2 + 3 s + 9

Continuous-time transfer function.

Published with MATLAB® R2017a


F17/35020/2013
BRIAN G GACHARI

b) Unit step response and steady state errors


i)
s = tf('s') % Declaring the s will be used as the main variable
sys = 500/((1+0.1*s)*(1+0.5*s)) % The open loop transfer function of the system
h1=1; % The system is of unity feedback
Gs2 = feedback(sys,h1) % Initiating the feedback
step(sys) % The test input is a step input
grid
figure(4) % generating the plot of the transient response
Steady_state_error4 = dcgain(1/(1+sys)) % calculating the steady state error

>> transient

s = s
Continuous-time transfer function.

sys =

500
--------------------
0.05 s^2 + 0.6 s + 1

Published with MATLAB® R2017a


F17/35020/2013
BRIAN G GACHARI

Continuous-time transfer function.

Gs2 =

500
----------------------
0.05 s^2 + 0.6 s + 501

Continuous-time transfer function.

Steady_state_error4 =

0.0020

ii) K=1
% K=1
s = tf('s')
sys = 1/(s*(1+0.1*s)*(1+0.5*s))
h = 1 % The system has unity feedback
Gs2 = feedback(sys,h)
step(Gs2)
grid
figure(5)
Steady_state_error4 = dcgain(1/(1+sys))

>> transient

Published with MATLAB® R2017a


F17/35020/2013
BRIAN G GACHARI

s =

Continuous-time transfer function.

sys =

1
----------------------
0.05 s^3 + 0.6 s^2 + s

Continuous-time transfer function.

h =

Gs2 =

1
--------------------------
0.05 s^3 + 0.6 s^2 + s + 1

Continuous-time transfer function.

Steady_state_error4 = 0

Published with MATLAB® R2017a


F17/35020/2013
BRIAN G GACHARI

K=4
% K=4
s = tf('s')
sys = 4/(s*(1+0.1*s)*(1+0.5*s))
h = 1 % The system has unity feedback
Gs2 = feedback(sys,h)
step(Gs2)
grid
figure(5)
Steady_state_error4 = dcgain(1/(1+sys))

>> transient

Published with MATLAB® R2017a


F17/35020/2013
BRIAN G GACHARI

s= s

Continuous-time transfer function.

sys =

----------------------

0.05 s^3 + 0.6 s^2 + s

Continuous-time transfer function.

h= 1

Gs2 =

--------------------------

0.05 s^3 + 0.6 s^2 + s + 4

Continuous-time transfer function.

Steady_state_error4 = 0

Published with MATLAB® R2017a


F17/35020/2013
BRIAN G GACHARI

K=25
% K=25
s = tf('s')
sys = 25/(s*(1+0.1*s)*(1+0.5*s))
h = 1 % The system has unity feedback
Gs2 = feedback(sys,h)
step(Gs2)
grid
figure(5)
Steady_state_error4 = dcgain(1/(1+sys))

s =

Continuous-time transfer function.

sys =

25
----------------------
Published with MATLAB® R2017a
F17/35020/2013
BRIAN G GACHARI

0.05 s^3 + 0.6 s^2 + s

Continuous-time transfer function.

h =

Gs2 =

25
---------------------------
0.05 s^3 + 0.6 s^2 + s + 25

Continuous-time transfer function.

Steady_state_error4 =

Published with MATLAB® R2017a


F17/35020/2013
BRIAN G GACHARI

k=100
% K=100
s = tf('s')
sys = 100/(s*(1+0.1*s)*(1+0.5*s))
h = 1 % The system has unity feedback
Gs2 = feedback(sys,h)
step(Gs2)
grid
figure(5)
Steady_state_error4 = dcgain(1/(1+sys))

s =

Continuous-time transfer function.

sys =

100
----------------------
0.05 s^3 + 0.6 s^2 + s

Continuous-time transfer function.

h =

Gs2 =

100
----------------------------
0.05 s^3 + 0.6 s^2 + s + 100

Continuous-time transfer function.

Steady_state_error4 =

Published with MATLAB® R2017a


F17/35020/2013
BRIAN G GACHARI

iii)

K=0.5
%K = 0.5
s = tf('s') % Declaring variable s will be used in the tranfer functio
oltf = 5/(s*(s^2+4*s+200)) % The open loop tansfer function provided in the qestion
h = 1 % The system has unity feedback
Gs3 = feedback(oltf,h)
step(Gs3)
grid
figure(1)
Steady_state_error4 = dcgain(1/(1+oltf)) %calculates the steady state error of the system

s =

Continuous-time transfer function.

oltf =

Published with MATLAB® R2017a


F17/35020/2013
BRIAN G GACHARI

5
-------------------
s^3 + 4 s^2 + 200 s

Continuous-time transfer function.

h =

Gs3 =

5
-----------------------
s^3 + 4 s^2 + 200 s + 5

Continuous-time transfer function.

Steady_state_error4 =

Published with MATLAB® R2017a


F17/35020/2013
BRIAN G GACHARI

K=2
%K = 2
s = tf('s') % Declaring variable s will be used in the tranfer functio
oltf = 20/(s*(s^2+4*s+200)) % The open loop tansfer function provided in the qestion
h = 1 % The system has unity feedback
Gs3 = feedback(oltf,h)
step(Gs3)
grid
figure(1)
Steady_state_error4 = dcgain(1/(1+oltf)) %calculates the steady state error of the system

s =

Continuous-time transfer function.

oltf =

20
-------------------
Published with MATLAB® R2017a
F17/35020/2013
BRIAN G GACHARI

s^3 + 4 s^2 + 200 s

Continuous-time transfer function.

h =

Gs3 =

20
------------------------
s^3 + 4 s^2 + 200 s + 20

Continuous-time transfer function.

Steady_state_error4 =

Published with MATLAB® R2017a


F17/35020/2013
BRIAN G GACHARI

K = 10
%K = 10
s = tf('s') % Declaring variable s will be used in the tranfer functio
oltf = 100/(s*(s^2+4*s+200)) % The open loop tansfer function provided in the qestion
h = 1 % The system has unity feedback
Gs3 = feedback(oltf,h)
step(Gs3)
grid
figure(1)
Steady_state_error4 = dcgain(1/(1+oltf)) %calculates the steady state error of the system

s =

Continuous-time transfer function.

oltf =

100
-------------------
s^3 + 4 s^2 + 200 s

Continuous-time transfer function.

h =

Gs3 =

100
-------------------------
s^3 + 4 s^2 + 200 s + 100

Continuous-time transfer function.

Steady_state_error4 =

Published with MATLAB® R2017a


F17/35020/2013
BRIAN G GACHARI

K = 60
%K = 60
s = tf('s') % Declaring variable s will be used in the tranfer functio
oltf = 600/(s*(s^2+4*s+200)) % The open loop tansfer function provided in the qestion
h = 1 % The system has unity feedback
Gs3 = feedback(oltf,h)
step(Gs3)
grid
figure(1)
Steady_state_error4 = dcgain(1/(1+oltf)) %calculates the steady state error of the system

s =

Continuous-time transfer function.

oltf =

600
-------------------
Published with MATLAB® R2017a
F17/35020/2013
BRIAN G GACHARI

s^3 + 4 s^2 + 200 s

Continuous-time transfer function.

h =

Gs3 =

600
-------------------------
s^3 + 4 s^2 + 200 s + 600

Continuous-time transfer function.

Steady_state_error4 =

Published with MATLAB® R2017a


F17/35020/2013
BRIAN G GACHARI

2. ROOT LOCI
a)
% Root Locus of an Oltf with unity feedback
s = tf('s') % Declaring variable s will be used in the tranfer functio
Gs=((s+9)^2)/((s+1)^3) % The open loop tansfer function provided in the qestion
rlocus(Gs) % This command generates the root locus diagram that is displayed.
grid
figure(1)

s =

Continuous-time transfer function.

Gs =

s^2 + 18 s + 81
---------------------
s^3 + 3 s^2 + 3 s + 1

Continuous-time transfer function.

Published with MATLAB® R2017a


F17/35020/2013
BRIAN G GACHARI

b)
s = tf('s') % Declaring variable s will be used in the tranfer functio
Gs = 1/(s*(s+4)) % The open loop tansfer function provided in the qestion
rlocus(Gs) % This command generates the root locus diagram that is displayed.
grid
figure(1)

s =

Continuous-time transfer function.

Gs =

1
---------
s^2 + 4 s

Continuous-time transfer function.

Published with MATLAB® R2017a


F17/35020/2013
BRIAN G GACHARI

3. BODE PLOT
a)
%Bode plot
s = tf('s') % Declaring variable s will be used in the tranfer function
Gs = (30*(s+0.5))/((s^2)*(s+5)*(s+3)) % The open loop tansfer function provided in the qestion
bode(Gs) % This command generates the Bode Plot diagram that is displayed.
grid
figure(1)

s =

Continuous-time transfer function.

Gs =

Published with MATLAB® R2017a


F17/35020/2013
BRIAN G GACHARI

30 s + 15
--------------------
s^4 + 8 s^3 + 15 s^2

Continuous-time transfer function.

4. NYQUIST PLOT
a) b=2
%Nyquist Plot
s = tf('s') % Declaring variable s will be used in the tranfer function
Gs = (s+2)/(s*(s+1)^2) % The open loop tansfer function provided in the qestion
nyquist(Gs) % This command generates the Nyquist Plot diagram that is displayed.
grid
figure(1)

s =
Published with MATLAB® R2017a
F17/35020/2013
BRIAN G GACHARI

Continuous-time transfer function.

Gs =

s + 2
---------------
s^3 + 2 s^2 + s

Continuous-time transfer function.

b) b = 6
%Nyquist Plot
s = tf('s') % Declaring variable s will be used in the tranfer function
Gs = (s+6)/(s*(s+1)^2) % The open loop tansfer function provided in the qestion
nyquist(Gs) % This command generates the Nyquist Plot diagram that is displayed.
grid
figure(1)

Published with MATLAB® R2017a


F17/35020/2013
BRIAN G GACHARI

s =

Continuous-time transfer function.

Gs =

s + 6
---------------
s^3 + 2 s^2 + s

Continuous-time transfer function.

c) b = 9
%Nyquist Plot
s = tf('s') % Declaring variable s will be used in the tranfer function
Gs = (s+9)/(s*(s+1)^2) % The open loop tansfer function provided in the qestion
nyquist(Gs) % This command generates the Nyquist Plot diagram that is displayed.

Published with MATLAB® R2017a


F17/35020/2013
BRIAN G GACHARI

grid
figure(1)

s =

Continuous-time transfer function.

Gs =

s + 9
---------------
s^3 + 2 s^2 + s

Continuous-time transfer function.

Published with MATLAB® R2017a


F17/35020/2013
BRIAN G GACHARI

Published with MATLAB® R2017a

You might also like