CS Lab
CS Lab
CS Lab
>> step(feedback(K*G,1),5)
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];
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
5.4374
Wpm =
4.3544
Display the gain and phase margins graphically
margin(hd)
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
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.
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