You are on page 1of 5

By: Nima Fouladinejad Mat. No: MM081053 Email: Nima.Fouladinejad@gmail.

com

How to draw Bode Diagram, Polar Plot and Nyquist Diagram for Control Systems via
MATLAB

Nima Fouladinejad

Faculty of Mechanical Engineering, Universiti Teknologi Malaysia


Nima.fouladinejad@gmail.com

1. Example (6.8)

To draw the bode diagram in MATLAB we simply write these in the command window of MATLAB.

s=tf('s') %to identify the transfer function variable.

Transfer function:

h=(10*(1+.5*s))/(s*(1+10*s)*(1+2*s)) %write the transfer function in MATLAB (sys name = h)

Transfer function:

5 s + 10

-------------------------

20 s^3 + 12 s^2 + s

bode(h) %command to Draw the bode diagram

And here is the MATLAB Bode diagram for this exercise. You can see the Gain Margin, Phase
Margin, correspond frequency and the stability of the system in the figure.
By: Nima Fouladinejad Mat. No: MM081053 Email: Nima.Fouladinejad@gmail.com

Exercise 6.1:

Draw the polar plot of the frequency response diagram for the system shown bellow.

u y

The transfer function is like this.

We can simply use this transfer function and draw the Nyquist diagram in MATLAB as follow.
>> s=tf('s') %to identify the transfer function variable
Transfer function:
s
>> G=(1/s)*(10/(1+0.1*s))*(1/(1+0.02*s)) %write the transfer function in MATLAB
Transfer function:
10
------------------------------
By: Nima Fouladinejad Mat. No: MM081053 Email: Nima.Fouladinejad@gmail.com

0.002 s^3 + 0.12 s^2 + s


>> nyquist(G) %command to Draw the Nyquist diagram

And here is the MATLAB Nyquist diagram for this exercise. You can see the Gain Margin, Phase
Margin, correspond frequency and the stability of the system in the figure.

Exercise 6.2:
For the control system shown below, plot the Nyquist diagram for K=1, and obtain the gain margin
and phase margin. Verify the answer by calculation.

The transfer function is like this.

We can simply use this transfer function and draw the Nyquist diagram in MATLAB as follow.
>> s=tf('s') %to identify the transfer function variable
Transfer function:
s
>> G=10/((s*(1+0.1*s)*(1+0.02*s))+10) %write the transfer function in MATLAB
Transfer function:
By: Nima Fouladinejad Mat. No: MM081053 Email: Nima.Fouladinejad@gmail.com

10
------------------------------
0.002 s^3 + 0.12 s^2 + s+10
>> nyquist(G) %command to Draw the Nyquist diagram

And here is the MATLAB Nyquist diagram for this exercise. You can see the Gain Margin, Phase
Margin, correspond frequency, Minimum Stability Margin, Peak Gain and the stability of the system
in the figure.

Exercise 6.3:
For the control system shown bellow, draw the Bode diagram for K=1. From the bode diagram, obtain
the gain and phase margin.

u y

The transfer function is like this.

We can simply use this transfer function and draw the Bode diagram in MATLAB as follow.
>> s=tf('s') %to identify the transfer function variable
Transfer function:
s
>> >> G=40/((s*(s+4)*(s+5))+40) %write the transfer function in MATLAB
By: Nima Fouladinejad Mat. No: MM081053 Email: Nima.Fouladinejad@gmail.com

Transfer function:
40

----------------------------

s^3 + 9 s^2 + 20 s + 40

>> bode(G) %command to Draw the bode diagram

And here is the MATLAB Bode diagram for this exercise. You can see the Gain Margin, Phase
Margin, correspond frequency, Peak Gain and the stability of the system in the figure.