0% found this document useful (0 votes)
24 views16 pages

CS Lab

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 16

Root Locus

1. Plot the root-locus of the following system.

h = tf([2 5 1],[1 2 3]);


rlocus(h)

Use the plot handle to change the title of the plot.


sys = rss(3);
h = rlocusplot(sys);
p = getoptions(h); % Get options for plot.
p.Title.String = 'My Title'; % Change title in options.
setoptions(h,p); % Apply options to plot.

The following MATLAB script plots the root loci for


s = tf('s');
G = 1/(s*(s+7)*(s+11));
rlocus(G);
axis equal;
Clicking at the point of intersection of the root locus with the imaginary axis gives the data
shown in Fig

Fig.3 shows step responses for two values of K


>> K = 860;
>> step(feedback(K*G,1),5)
>> hold;
% Current plot held
>> K = 1460;

>> step(feedback(K*G,1),5)

State Space Analysis


Impulse Response Plot of Second-Order State-Space Model

Plot the impulse response of the second-order state-space model

a = [-0.5572 -0.7814;0.7814
b = [1 -1;0 2];
c = [1.9691 6.4493];
sys = ss(a,b,c,0);
impulse(sys)

0];

Plot the step response of above second-order state-space model.


a = [-0.5572,-0.7814;0.7814,0];
b = [1,-1;0,2];
c = [1.9691,6.4493];
sys = ss(a,b,c,0);
step(sys)

Consider the system shown in Fig.

The plant transfer function G(s) is given as


clear all;
close all;
s = tf('s');
G = (s+1)/(s*(0.1*s-1));
rlocus(G);
axis equal;
sgrid;
title('Root locus for (s+1)/s(0.1s-1)');
[K,p]=rlocfind(G)

Obtain the Bode plot of the system given by the transfer function

num = 1;
den = [2 1];
sys = tf (num,den);
grid;
bode(sys)

Plot the Bode magnitude and phase for the system with transfer function

hd = tf([0.04798 0.0464],[1 -1.81 0.9048],0.1)


hd =
0.04798z + 0.0464
--------------------Z^2 - 1.81 z + 0.9048

Compute the gain and phase margins


[Gm,Pm,Wgm,Wpm] = margin(hd)
Gm =
2.0517
Pm =
13.5711
Wgm =

5.4374
Wpm =
4.3544
Display the gain and phase margins graphically
margin(hd)

G = tf([.5 1.3],[1 1.2 1.6 0]);


T = feedback(G,1);
bode(G), grid

Then, right-click on the plot and select the Characteristics -> Minimum Stability Margins
submenu. Finally, click on the blue dot markers. The resulting plot is shown below

sys = 1/(s^2 + 0.5*s + 1);


bode(sys)

sys = 1/(s^2 + 0.5*s + 1);


w = 0.3;
t = 0:0.1:100;
u = sin(w*t);
[y,t] = lsim(sys,u,t);
plot(t,y,t,u)
axis([50 100 -2 2])

Note that the output (blue) tracks the input (green) fairly well; it is perhaps a few
degrees behind the input as expected. However, if we set the frequency of the input
higher than the bandwidth frequency for the system, we get a very distorted
response (with respect to the input)
sys = 1/(s^2 + 0.5*s + 1);
w = 3;
t = 0:0.1:100;
u = sin(w*t);
[y,t] = lsim(sys,u,t);
plot(t,y,t,u)
axis([90 100 -1 1])

Nyquist Plot

s = tf('s');
sys = 0.5/(s - 0.5);
nyquist(sys)
axis([-1 0 -1 1])

Note that this function has a pole at the origin. We will see the difference between
using the nyquist, nyquist1, and lnyquist commands with this particular function.
sys = (s + 2)/(s^2);
nyquist(sys)

nyquist1(sys)

lnyquist(sys)

Note that the nyquist plot is not the correct one, the nyquist1 plot is correct, but it's
hard to see what happens close to the -1 point, and the lnyquist plot is correct and
has an appropriate scale.

The Nyquist criterion then states that:

= the number of open-loop (unstable) poles of G(s)H(s)

= the number of times the Nyquist diagram encircles -1

clockwise encirclements of -1 count as positive encirclements

counter-clockwise encirclements of -1 count as negative encirclements

= the number of right-half-plane (positive, real) poles of the closed-loop system

roots([1 -8 15])
ans =

5
3
The poles of the open-loop transfer function are both positive. Therefore, we
need two anti-clockwise (N = -2) encirclements of the Nyquist diagram in order
to have a stable closed-loop system (Z = P + N). If the number of
encirclements is less than two or the encirclements are not anti-clockwise,
our system will be unstable.
sys = (s^2 + 10*s + 24)/(s^2 - 8*s + 15);
nyquist(sys)

There are two anti-clockwise encirclements of -1. Therefore, the system is stable for
a gain of 1

You might also like