Experiment No.1 Time Response of First Order System: 1.matlab Program
Experiment No.1 Time Response of First Order System: 1.matlab Program
1
Time response of First order system
1.MATLAB PROGRAM
EXPERIMENT-2
Time response of Second order system
MATLAB code:
% Write a MATLAB code to plot Response
% input unit step input
% R=1 ohm, L=1 H,C=1F
%The transfer function is
num=[1];
den=[1 1 1];
step(num ,den)
grid title(’The unit step response of transfer function S/(s+1)
Experiment 3
Steady-State Error
Aim:
To reduce steady state error of a system.
Key MATLAB commands used are: lsim,feedback
s = tf('s');
G = ((s+3)*(s+5))/(s*(s+7)*(s+8));
T = feedback(G,1);
t = 0:0.1:25;
u = t;
[y,t,x] = lsim(T,u,t);
plot(t,y,'y',t,u,'m')
xlabel('Time (sec)')
ylabel('Amplitude')
title('Input-purple, Output-yellow')
Let's see the ramp input response for K = 37.33 by entering the following code in the
MATLAB command window.
----------------------------------------------------------------------------------------------------------------
K = 37.33 ;
s = tf('s');
G = (K*(s+3)*(s+5))/(s*(s+7)*(s+8));
sysCL = feedback(G,1);
t = 0:0.1:50;
u = t;
[y,t,x] = lsim(sysCL,u,t);
plot(t,y,'y',t,u,'m')
xlabel('Time (sec)')
ylabel('Amplitude')
title('Input-purple, Output-yellow')
From our tables, we know that a system of type 2 gives us zero steady-state error for a ramp
input. Therefore, we can get zero steady-state error by simply adding an integrator (a pole at
the origin). Let's view the ramp input response for a step input if we add an integrator and
employ a gain K = 1.
s = tf('s');
P = ((s+3)*(s+5))/(s*(s+7)*(s+8));
C = 1/s;
sysCL = feedback(C*P,1);
t = 0:0.1:250;
u = t;
[y,t,x] = lsim(sysCL,u,t);
plot(t,y,'y',t,u,'m')
xlabel('Time (sec)')
ylabel('Amplitude')
title('Input-purple, Output-yellow')
----------------------------------------------------------------------------------------------------------------
EXPERIMENT 4
Stability Analysis Based on Pole position
MATLAB code to plot pole-zero map for under damped system( zeta<1)
----------------------------------------------------------------------------------------------------------------
k_dc = 1;
w_n = 10;
zeta = 0.2;
s = tf('s');
G1 = k_dc*w_n^2/(s^2 + 2*zeta*w_n*s + w_n^2);
pzmap(G1)
axis([-3 1 -15 15])
MATLAB code to plot pole-zero map for over damped system( zeta>1)
----------------------------------------------------------------------------------------------------------------
zeta = 1.2;
G2 = k_dc*w_n^2/(s^2 + 2*zeta*w_n*s + w_n^2);
pzmap(G2)
axis([-20 1 -1 1])
MATLAB code to plot pole-zero map for critically damped system( zeta=1)
----------------------------------------------------------------------------------------------------------------
zeta = 1;
G3 = k_dc*w_n^2/(s^2 + 2*zeta*w_n*s + w_n^2);
pzmap(G3)
axis([-11 1 -1 1])
How do we design a feedback controller for the system by using the root locus method? Say
our design criteria are 5% overshoot and 1 second rise time. Make a MATLAB file
called rl.m. Enter the transfer function, and the command to plot the root locus:
MATLAB program to plot root locus of transfer function H(s)=(s+5)/s(s+5)(s+15)(s+20)
tf('s');
sys = (s + 7)/(s*(s + 5)*(s + 15)*(s + 20));
rlocus(sys)
axis([-22 3 -15 15])
Continuation of above MATLAB prog. The following instructions plot lines of constant
damping ratio and natural frequency on pole zero map or root locus.
----------------------------------------------------------------------------------------------------------------
Zeta = 0.7;
Wn = 1.8;
sgrid(Zeta,Wn)
EXPERIMENT-6
Stability Analysis of system using Bode Plot
Aim:
To obtain bode plot for a given transfer function of the system using MATLAB and to
find stability of system.
Key MATLAB commands used in this tutorial are: bode(num,den).
MATLAB program to simulate bode plot for –
----------------------------------------------------------------------------------------------
num=[0 0 0 4.2];
den=[1 4 5 0];
bode(num,den);