You are on page 1of 7

Experiment 8

Aim:
To create transfer function and plot its Nyquist response, Bode Plot, Root Locus and Step Response
in MATLAB.

Objective:
To create transfer function and plot its Nyquist response, Bode Plot, Root Locus and Step Response.

Theory:
Create the following transfer function

H(s) = (2s2 + 5s + 1)/ (S2 + 2s + 3)

The Nyquist function can display a grid of M-circles, which are the contours of constant closed-loop
magnitude. M-circles are defined as the locus of complex numbers where the following quantity is a
constant value across frequency.

T(jw) = (|G(jw))/(|1+G(jw)|)

Here, ω is the frequency in radians/Time Unit, where Time Unit is the system time units, and G is the
collection of complex numbers that satisfy the constant magnitude requirement. To display the grid
of M-circles, right-click in the plot and select Grid. Alternatively, use the grid command

MATLAB CODE FOR NYQUIST PLOT


clear all

clc

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

nyquist (GH)

[Gm, Pm, Wcp, Wcg] = margin (GH)

disp (‘Gain Margin is’)

disp (Gm)

disp (‘Phase Margin is’)

disp (Pm)

disp (‘Phase crossover frequency is’)

disp (Wcp)

disp (‘Gain crossover frequency is’)

disp (Wcg)

grid on;

Compare the frequency response of several systems on the same Nyquist plot.
Simulation Result

Create the dynamic systems.


rng (0)

sys1 = tf (3, [1,2,1]);

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

sys3 = rss (4); %Generate randomized continuous-time state-space models.

nyquist (sys1, sys2, sys3)

[Gm1, Pm1, Wcp1, Wcg1] = margin(sys1);

[Gm2, Pm2, Wcp2, Wcg2] = margin(sys2);

[Gm3, Pm3, Wcp3, Wcg3] = margin(sys3);

disp ('Gain Margin for system 1 is')

disp (Gm1)

disp ('Phase Margin for system1 is')

disp (Pm1)
disp ('Phase crossover frequency for system1 is')

disp (Wcp1)

disp ('Gain crossover frequency for system1 is')

disp (Wcg1)

grid on;

disp ('Gain Margin for system 2 is')

disp (Gm2)

disp ('Phase Margin for system2 is')

disp (Pm2)

disp ('Phase crossover frequency for system2 is')

disp (Wcp2)

disp ('Gain crossover frequency for system2 is')

disp (Wcg2)

grid on;

disp ('Gain Margin for system 3 is')

disp (Gm3)

disp ('Phase Margin for system3 is')

disp (Pm3)

disp ('Phase crossover frequency for system3 is')

disp (Wcp3)

disp ('Gain crossover frequency for system3 is')

disp (Wcg3)

grid on;

SIMULATION RESULTS:
MATLAB CODE FOR BODE PLOT
clear all

clc

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

options = bodeoptions;

options.FreqUnits = 'Hz'; % or 'rad/second', 'rpm', etc.

figure (1)

bode (GH,options); % refer to the Matlab help page on bodeoptions for more details … and optional
parameters.

grid

Simulations Results
MATLAB CODE FOR BODE PLOT to access frequency response data directly
clear all

clc

s = tf('s');

G = 1/(s+1);

win = logspace(-2,2,5) % input frequency vector in rad/s,

[mag,phase,wout] = bode(G,win);

grid on

size(wout) % wout is the output frequencies at which the response was evaluated

size(mag) % mag is the magnitude in absolute units (i.e., not in dB), phase is the phase in %degrees
size(phase)

MATLAB CODE FOR ROOT LOCUS


clear all

clc
GH = tf ([0 2 5], [1 2 3]);

rlocus(GH)

grid on

Zeta = 0.7;

Wn = 1.8;

sgrid(Zeta, Wn)

[k, poles] = rlocfind(GH)

Simulation Results

MATLAB CODE FOR STEP RESPONSE


clear all

clc

num = [0 2 5];

denom = [1 2 3];

GH = tf (num, denom);
step (GH)

R = roots(denom)

S = stepinfo (GH, ‘RiseTimeLimits’, [0.00, 1.00])

ltiview (GH)

Simulation Results

CONCLUSION AND DISCUSSION


So here we have seen various plots such as Nyquist Plot, Bode Plot, Root Locus Plot.

We have discussed the MATLAB Codes for all the above mentioned Plots.

You might also like