Académique Documents
Professionnel Documents
Culture Documents
Matlab Code
close all
clear all
% system transfer
function num1=[1 8];
den1=poly([0 -2 -10]); % try others values as well
sys1=tf(num1,den1)
t1=[0:.02:10];
% ploting step response of
system ys1=step(sys1,t1);
subplot(2,2,1)
plot(t1,ys1)
title('step response of signal')
% evaluating steady state
error disp('steady state
error') os1=max(ys1)-1
subplot(2,2,2)
% showing root locus of sys1 in 2nd window of
subplot rlocus(sys1)
[k,r]=rlocfind(sys1);
% display gain of system and roots at selected point on root
locus disp('k=')
disp(k)
disp('r=')
disp(r)
% introducing feedback gain in system evaluated at specific point above
% transfer function of modified system
[num2,den2]=feedback(k*num1,den1,1,1,-
1); sys2=tf(num2,den2)
t2=[0:.02:10];
% ploting step response of system
ys2=step(sys2,t2);
subplot(2,2,3)
plot(t2,ys2)
title('step response of signal')
% evaluating steady state
error disp('steady state
error') os2=max(ys2)-1
Figure
os1 =
2.8100
selected_point =
-1.7614 + 7.8049i
k=
70.9610
r= -
8.9319
-1.5340 + 7.8233i
-1.5340 - 7.8233i
Transfer function:
70.96 s + 567.7
------------------------------
s^3 + 12 s^2 + 90.96 s + 567.7
os2 =
0.5768
Matlab Code
close all
clear all
% without PID
Controller n=[1];
d=[1 10 21];
disp('transfer function of system without PID
Controller') q=tf(n,d)
subplot(3,2,1)
step(q)
subplot(3,2,2)
rlocus(q)
% with P Controller
kp=500;
n=[kp];
d=[1 10 20+kp];
disp('transfer function of system with P
Controller') q=tf(n,d) subplot(3,2,3)
step(q)
subplot(3,2,4)
rlocus(q)
% with PI
Controller kp=30;
ki=70;
n=[kp ki];
d=[1 10 20+kp ki];
disp('transfer function of system with PI
Controller') q=tf(n,d)
subplot(3,2,5)
step(q)
subplot(3,2,6)
rlocus(q)
Transfer
function: 1
---------------
s^2 + 10 s + 21
Transfer
function: 500
----------------
s^2 + 10 s + 520
Transfer function:
30 s + 70
------------------------
s^3 + 10 s^2 + 50 s + 70
Lab Tasks
Q. Where will you click on the window to make sure that gain K should be less?
Q. Does the modified system after introduction of gain K have changed in order as compared to
previous one?
Q. How many extra poles/zeros have been added to the original system transfer function by
introduction of I parameter of PID?
Q. Is there any change in roots locus of the original system and the system with P and I?
Modify and change the parameter values in above Matlab codes and provide the figures and
command window output in lab report.