You are on page 1of 32

WAQAS ASGHAR

2005/FC-MCE-02

WAJID PERVAIZ
2005/FC-MCE-09

FAISALABAD CAMPUS UNIVERSITY OF ENGINEERING AND TECHNOLOGY, LAHORE
10/23/08 MATLAB Control Toolbox 1

Outline
 MATLAB  MATLAB and Toolboxes  MATLAB and Control  Control System Toolbox  Solution to some problems
10/23/08 MATLAB Control Toolbox 2

MATLAB
• MATLAB® 7 r14 is provided by The MathWorks. (www.mathworks.com) • High-level technical computing language and interactive environment • Has computational and graphical tools • Handles real and complex scalars, vectors and matrices
10/23/08 MATLAB Control Toolbox 3

MATLAB Worldwide
 Aerospace and Defense  Automotive  Biotech, Medical, and Pharmaceutical  Chemical and Petroleum  Communications  Computers and Office Equipment  Education  Electronics and Semiconductor  Financial Services  Industrial Equipment and Machinery  Instrumentation  Utilities and Energy
10/23/08 MATLAB Control Toolbox 4

MATLAB Toolboxes
MATLAB

Math and optimization

Signal Processing and communications

Simulink Product Family

…..

Control System Design and Analysis

Toolboxes Optimization Symbolic Math Partial Diff. Eq. …

Toolboxes Signal Processing Communications Filter Design Filter Design HDL Coder …

Simulink® Simulink Accelerator Simulink Report Generator

Toolboxes Simulink Control Design Simulink Response Simulink Parameter …

10/23/08

MATLAB Control Toolbox

5

MATLAB and Control
MATLAB-Toolboxes for Control

Linear Control

Nonlinear Control

Identification

Control System Toolbox Simulink® Mu Toolbox

Nonlinear Control Toolbox Fuzzy Toolbox Simulink®

Identification Toolbox Frequency-Domain ID Toolbox Simulink®

10/23/08

MATLAB Control Toolbox

6

MATLAB and Control
• Modeling Tools

10/23/08

MATLAB Control Toolbox

7

Control System Toolbox
Core Features
 Tools to manipulate LTI models  Classical analysis and design
    Bode, Nyquist, Nichols diagrams Step and impulse response Gain/phase margins Root locus design

 Modern state-space techniques
 Pole placement  LQG regulation

10/23/08

MATLAB Control Toolbox

8

Control System Toolbox
LTI Objects (Linear Time Invariant)
 4 basic types of LTI models
    Transfer Function (TF) Zero-pole-gain model (ZPK) State-Space models (SS) Frequency response data model (FRD)

 Conversion between models  Model properties (dynamics)
10/23/08 MATLAB Control Toolbox 9

Control System Toolbox
Transfer Function
p1 s n  p 2 s n 1  ...  p n 1 H (s )  q1 s m  q1 s m 1  ...  q m 1 where p1 , p 2 ... p n 1 q1 , q1 ... q m 1

numerator coefficients denominator coefficients

10/23/08

MATLAB Control Toolbox

10

Control System Toolbox
Transfer Function
• Consider a linear time invariant (LTI) singleinput/single-output system

y '' 6 y ' 5 y  4u ' 3u

• Applying Laplace Transform to both sides with zero initial conditions

Y (s) 4s  3 G( s)   2 U ( s) s  6s  5
MATLAB Control Toolbox

10/23/08

11

Control System Toolbox
Transfer Function
>> num = [4 3]; >> den = [1 6 5]; >> sys = tf(num,den)
Transfer function: 4s+3 ----------------s^2 + 6 s + 5
10/23/08

>> [num,den] = tfdata(sys,'v') num = 0 4 3 den = 1 6 5

MATLAB Control Toolbox

12

Control System Toolbox
Zero-pole-gain model (ZPK)
(s  p1 )(s  p 2 )  ...  (s  p n ) H (s )  K (s  q1 )(s  q 2 )  ...  (s  q m ) where p1 , p 2 ... p n 1 q1 , q1 ... q m 1
10/23/08

the zeros of H(s) the poles of H(s)
MATLAB Control Toolbox 13

Control System Toolbox
Zero-pole-gain model (ZPK)

Consider a Linear time invariant (LTI) singleinput/single-output system

y '' 6 y ' 5 y  4u ' 3u

Applying Laplace Transform to both sides with zero initial conditions

Y (s) 4s  3 4( s  0.75) G(s)   2  U ( s ) s  6 s  5 ( s  1)( s  5)
10/23/08 MATLAB Control Toolbox 14

Control System Toolbox
Zero-pole-gain model (ZPK)
>> sys1 = zpk(-0.75,[-1 -5],4) Zero/pole/gain: 4 (s+0.75) ----------(s+1) (s+5)
>> [ze,po,k] = zpkdata(sys1,'v') ze = -0.7500 po = -1 -5 k= 4

10/23/08

MATLAB Control Toolbox

15

State-Space Model (SS)
x  A x B u y C x D u where x u and y A , B ,C and D
.

Control System Toolbox

state vector input and output vectors state-space matrices

10/23/08

MATLAB Control Toolbox

16

Control System Toolbox
State-Space Models
• Consider a Linear time invariant (LTI) singleinput/single-output system

y '' 6 y ' 5 y  4u '' 3u
• State-space model for this system is

 x1 '   0 1   x1   0   x '   5 6   x    1  u   2    2  
 x1  y   3 4    x2 
10/23/08 MATLAB Control Toolbox

 x1 (0)   0  x (0)    0     2 

17

Control System Toolbox
State-Space Models
>> sys = ss([0 1; -5 -6],[0;1],[3,4],0) a= c= x1 x2 x1 x2 x1 0 1 y1 3 4 x2 -5 -6

b= u1 x1 0 x2 1

d= u1 y1 0

10/23/08

MATLAB Control Toolbox

18

Control System different Conversion betweenToolbox models
tf2ss Transfer function ss2tf zp2tf tf2zp ss2zp zp2ss State Space

Zero-pole-gain

10/23/08

MATLAB Control Toolbox

19

Control System Toolbox
Time Responses of Systems
• • • • Impulse Response (impulse) Step Response (step) General Time Response (lsim) gensig - Generate input signal for lsim.

10/23/08

MATLAB Control Toolbox

20

Control System Toolbox
Time Response of Systems

The impulse response of a system is its output when the input is a unit impulse. The step response of a system is its output when the input is a unit step. The general response of a system to any input can be computed using the lsim command.

10/23/08

MATLAB Control Toolbox

21

Control System Toolbox
Time Response of Systems
Problem Given the LTI system
G( s ) = 3s + 2 2 s 3 + 4s 2 + 5 s + 1

Plot the following responses for:

The impulse response using the impulse command. The step response using the step command.

10/23/08

MATLAB Control Toolbox

22

Time Response of Systems

Control System Toolbox

10/23/08

MATLAB Control Toolbox

23

Frequency Response: Bode and Control System Toolbox Nyquist Plots
• Typically, the analysis and design of a control system requires an examination of its frequency response over a range of frequencies of interest. • The MATLAB Control System Toolbox provides functions to generate two of the most common frequency response plots: Bode Plot (bode command) and Nyquist Plot (nyquist command).

10/23/08

MATLAB Control Toolbox

24

Frequency Response: Bode Plot
Problem • Given the LTI system

Control System Toolbox

1 G( s )  s( s  1) Draw the Bode diagram for 100 values of frequency 10 1 10  interval in the .

10/23/08

MATLAB Control Toolbox

25

Control System Toolbox
Frequency Response: Bode Plot
>>bode(tf(1, [1 1 0]), logspace(-1,1,100));

10/23/08

MATLAB Control Toolbox

26

Control System Toolbox
Frequency Response: Nyquist Plot
 

The loop gain Transfer function G(s) The gain margin is defined as the multiplicative amount that the magnitude of G(s) can be increased before the closed loop system goes unstable Phase margin is defined as the amount of additional phase lag that can be associated with G(s) before the closed-loop system goes unstable

10/23/08

MATLAB Control Toolbox

27

Frequency Response: Nyquist Plot
Problem Given the LTI system Draw the bode and nyquist plots for 100 values of frequencies in the interval . In addition, find the gainand phase margins.  10 4 103 

Control System Toolbox

G( s ) =

1280 s + 640 s 4 + 24.2 s 3 + 1604.81s 2 + 320.24s + 16

10/23/08

MATLAB Control Toolbox

28

Control System Toolbox
Frequency Response: Nyquist Plot
w=logspace(-4,3,100); sys=tf([1280 640], [1 24.2 1604.81 320.24 16]); bode(sys,w) [Gm,Pm,Wcg,Wcp]=margin(sys) %Nyquist plot figure nyquist(sys,w)

10/23/08

MATLAB Control Toolbox

29

Control System Toolbox
Frequency Response: Nyquist Plot

The values of gain and phase margin and corresponding frequencies are Gm = 29.8637 Pm = 72.8960 Wcg = 39.9099 Wcp = 0.9036
MATLAB Control Toolbox 30

10/23/08

Control System Plots Toolbox Frequency Response
bode - Bode diagrams of the frequency response. bodemag - Bode magnitude diagram only. sigma - Singular value frequency plot. nyquist - Nyquist plot. nichols - Nichols plot. margin - Gain and phase margins. allmargin - All crossover frequencies and related gain/phase margins. freqresp - Frequency response over a frequency grid. evalfr - Evaluate frequency response at given frequency. interp - Interpolates frequency response data.
10/23/08 MATLAB Control Toolbox 31

10/23/08

MATLAB Control Toolbox

32