0% found this document useful (0 votes)
358 views

Experiment No.1 Time Response of First Order System: 1.matlab Program

The document describes several experiments related to analyzing system dynamics and stability using MATLAB. Experiment 1 generates a step response for a first order system. Experiment 2 does the same for a second order system. Experiment 3 examines reducing steady state error using feedback. Experiment 4 analyzes stability based on pole position. Experiment 5 covers root locus analysis and feedback controller design. Experiment 6 obtains Bode plots to assess stability. The document provides MATLAB code examples for each experiment.

Uploaded by

Darshan Deepu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
358 views

Experiment No.1 Time Response of First Order System: 1.matlab Program

The document describes several experiments related to analyzing system dynamics and stability using MATLAB. Experiment 1 generates a step response for a first order system. Experiment 2 does the same for a second order system. Experiment 3 examines reducing steady state error using feedback. Experiment 4 analyzes stability based on pole position. Experiment 5 covers root locus analysis and feedback controller design. Experiment 6 obtains Bode plots to assess stability. The document provides MATLAB code examples for each experiment.

Uploaded by

Darshan Deepu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

EXPERIMENT NO.

1
Time response of First order system
1.MATLAB PROGRAM

% Write a MATLAB code to plot Response


% input unit step input
% R=1 ohm, L=1 H
%The transfer function is 1/(s+1)
num=[1]
den=[1 1]
step(num ,den)
grid title(’The unit step response of transfer function 1/(s+1’)

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 command to calculate pole value.


----------------------------------------------------------------------------------------------------------------
s = tf('s');
G = 1/(s^2+2*s+5)
pole(G)

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])

MATLAB code to plot step response of G3.


----------------------------------------------------------------------------------------------------------------
step(G3)
axis([0 1.5 0 1.5])

MATLAB code to plot pole-zero map for undamped system( zeta=0)


-------------------------------------------------------------------------------------------------------------
zeta = 0;
G4 = k_dc*w_n^2/(s^2 + 2*zeta*w_n*s + w_n^2);
pzmap(G4)
axis([-1 1 -15 15])
EXPERIMENT 5
Root Locus Analysis
Aim:
i. Create root locus for a given transfer function using MATLAB
ii. To demonstrate how to design feedback controller using root locus that satisfy certain
performance criteria.
Key MATLAB commands used in this tutorial are: feedback, rlocus, step,

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)

MATLAB command to find TF of closed loop system.


----------------------------------------------------------------------------------------------------------------
K = 350;
sys_cl = feedback(K*sys,1)

To Check out the step response of your closed-loop system:


----------------------------------------------------------------------------------------------------------------
step(sys_cl)

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);

You might also like