Exp3 4
Exp3 4
1. OBJECTIVES
✓ To use MATLAB commands for frequency response analysis.
✓ To understand frequency response analysis using Polar Plot.
✓ To find gain and phase margin using Polar Plot.
2. Polar Plot
The most commands used for polar Plot are
nyquist (num,den)
nyquist (num,den,w)
We can also obtain arguments by
[re,im,w]= nyquist (num,den,w)
where the frequency response returns real and imaginary with respective to w.
Example1:
Given a unity feedback control system with open-loop transfer function given by
1
Go (s ) = , Obtain the polar plot
(0.1s + 1)
Solution1:
num= l
den= [. 1 1 ] ;
w=[0:.1:1000);
[re,im , w) = nyqui s t (num,den,w);
[phase,ma g] = cart2pol(re,im);
polar(phase,rnaq);
title ( 'G (s) =1 / [ (0 . l s +l ) l ' )
Ta ble=[w mag rad2deg(phase) );
Exercises:
Find polar plot for below open loop transfer functions
100 1 1 1
G o (s ) = , G1 (s ) = , G 2 (s ) = , G 3 (s ) =
(s 2 + 10s + 100) (s + 1)(s + 2) (s + 1)(s + 2)(s + 3) s (s + 1)(s + 2)
Exp 4: Frequency response using Bode plot
1. OBJECTIVES
✓ To understand frequency response analysis using Bode Plot.
✓ To find gain and phase margin using Bode Plot.
2. Bode Plot
The most commands used for polar Plot are
bode (num,den)
bode (num,den,w)
where num and den is the numerator and denominator of open-loop transfer function
respectively and w (optional) is the frequency range of the response.
We can also obtain arguments by
[mag,phase]= bode (num,den,w)
where the frequency response returns magnitude and phase angle with respective to w.
Example1:
Given a unity feedback control system with open-loop transfer function given by
1
Go (s ) = , Obtain the bode plot
(0.1s + 1)
Solution1:
num=l
den=[ . 1 1];
w=[0: . 1: 1000];
[mag,phase] = bode (num,den , w) ;
format shortG
Tabl.e=[w' 20*log10 (mag) phase] % Store in a Tab'le
bode(num, den, w), grid;
title ( ' G(s)=l/ [ (0 .1s+l)] ')
Exercises:
Find bode plot for below open loop transfer functions
100 1 1 1
G o (s ) = , G1 (s ) = , G 2 (s ) = , G 3 (s ) =
(s 2 + 10s + 100) (s + 1)(s + 2) (s + 1)(s + 2)(s + 3) s (s + 1)(s + 2)
G 3 (s ) to be done by students.
Example3:
Write a code to draw Bode plot for a user defined G(s) and frequencies. Run this code for
two G(s) selected by your module tutor then find Gm,Pm,Wcg,Wcp graphically. Check
for both G(s) using “margin” command.
Solution3:
% G(s) to be given by user
num=input( 'Enter num • );
den=input( 'Enter den ' );
w=input( 'Frequency range' );
[mag,phase] = bode(num,den,w);
format shortG
Table=[w' 20*log10 (mag) phase,] % store in a Table
bode(num,den,w), grid;
Remark: all codes of this experiment were written by the module leader “Dr. Ayman Al-Khazraji”