®

Computation

Visualization

Programming

Control System

Toolbox

User’s Guide

Version 4.2

How to Contact The MathWorks:

508-647-7000 Phone

508-647-7001 Fax

The Mat hWor ks, Inc. Mail

24 Pr ime Par k Way

Nat ick, MA 01760-1500

http://www.mathworks.com Web

ftp.mathworks.com Anonymous FTP ser ver

comp.soft-sys.matlab Newsgr oup

support@mathworks.com Technical suppor t

suggest@mathworks.com Pr oduct enhancement suggest ions

bugs@mathworks.com Bug r epor t s

doc@mathworks.com Document at ion er r or r epor t s

subscribe@mathworks.com Subscr ibing user r egist r at ion

service@mathworks.com Or der st at us, license r enewals, passcodes

info@mathworks.com Sales, pr icing, and gener al infor mat ion

Control S ystem Toolbox User’s Guide

© COPYRIGHT 1992 - 1999 by The Mat hWor ks, Inc.

The soft war e descr ibed in t his document is fur nished under a license agr eement . The soft war e may be used

or copied only under t he t er ms of t he license agr eement . No par t of t his manual may be phot ocopied or r epr o-

duced in any for m wit hout pr ior wr it t en consent fr om The Mat hWor ks, Inc.

U.S. GOVERNMENT: If Licensee is acquir ing t he Pr ogr ams on behalf of any unit or agency of t he U.S.

Gover nment , t he following shall apply: (a) For unit s of t he Depar t ment of Defense: t he Gover nment shall

have only t he r ight s specified in t he license under which t he commer cial comput er soft war e or commer cial

soft war e document at ion was obt ained, as set for t h in subpar agr aph (a) of t he Right s in Commer cial

Comput er Soft war e or Commer cial Soft war e Document at ion Clause at DFARS 227.7202-3, t her efor e t he

r ight s set for t h her ein shall apply; and (b) For any ot her unit or agency: NOTICE: Not wit hst anding any

ot her lease or license agr eement t hat may per t ain t o, or accompany t he deliver y of, t he comput er soft war e

and accompanying document at ion, t he r ight s of t he Gover nment r egar ding it s use, r epr oduct ion, and disclo-

sur e ar e as set for t h in Clause 52.227-19 (c)(2) of t he FAR.

MATLAB, Simulink, St at eflow, Handle Gr aphics, and Real-Time Wor kshop ar e r egist er ed t r ademar ks and

Tar get Language Compiler ar e t r ademar ks of The Mat hWor ks, Inc.

Ot her pr oduct or br and names ar e t r ademar ks or r egist er ed t r ademar ks of t heir r espect ive holder s.

Pr int ing Hist or y: J uly 1992 Fir st pr int ing

December 1996 Second pr int ing Revised for MATLAB 5

J anuar y 1998 Thir d pr int ing Revised for MATLAB 5.2

J anuar y 1999 Four t h pr int ing Revised for Ver sion 4.2 (Release 11)

¤

PHONE

FAX

u

MAIL

INTERNET

@

i

Contents

Preface

Installati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Ge tt i ng Starte d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Typographi c Conve nti ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

1

Qui ck Start

LTI Mode ls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3

MIMO Syst ems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4

Model Conver sion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5

LTI Ar r ays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6

LTI Properti es . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7

Mode l Charact eris t ics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-10

Operati ons on LTI Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-11

Cont i nuous/Di screte Conversi ons . . . . . . . . . . . . . . . . . . . . . 1-13

Ti me and Frequency Response . . . . . . . . . . . . . . . . . . . . . . . . 1-14

The LTI Vi ewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-17

i i Contents

System Int erconnecti ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-19

Control De si gn Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-20

The Root Locus Desi gn GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-23

2

LTI Models

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2

LTI Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2

Using LTI Models in t he Cont r ol Syst em Toolbox . . . . . . . . . . . 2-3

Ot her Uses of FRD Models . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3

LTI Object s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3

Cr eat ing an LTI Object : An Example . . . . . . . . . . . . . . . . . . . 2-4

LTI Pr oper t ies and Met hods . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4

Pr ecedence Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5

Viewing LTI Syst ems As Mat r ices . . . . . . . . . . . . . . . . . . . . . . . 2-5

Command Summar y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6

Creat i ng LTI Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8

Tr ansfer Funct ion Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8

SISO Tr ansfer Funct ion Models . . . . . . . . . . . . . . . . . . . . . . . 2-8

MIMO Tr ansfer Funct ion Models . . . . . . . . . . . . . . . . . . . . . 2-10

Pur e Gains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11

Zer o-Pole-Gain Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12

SISO Zer o-Pole-Gain Models . . . . . . . . . . . . . . . . . . . . . . . . . 2-12

MIMO Zer o-Pole-Gain Models . . . . . . . . . . . . . . . . . . . . . . . 2-13

St at e-Space Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-14

Descr ipt or St at e-Space Models . . . . . . . . . . . . . . . . . . . . . . . . . 2-16

Fr equency Response Dat a (FRD) Models . . . . . . . . . . . . . . . . . 2-17

Discr et e-Time Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-20

Discr et e-Time TF and ZPK Models . . . . . . . . . . . . . . . . . . . 2-21

Discr et e Tr ansfer Funct ions in DSP For mat . . . . . . . . . . . . 2-22

Dat a Ret r ieval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-24

i i i

LTI Properti es . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-26

Gener ic Pr oper t ies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-26

Model-Specific Pr oper t ies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-28

Set t ing LTI Pr oper t ies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-30

Accessing Pr oper t y Values Using get . . . . . . . . . . . . . . . . . . . . 2-31

Dir ect Pr oper t y Refer encing . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-33

Addit ional Insight int o LTI Pr oper t ies . . . . . . . . . . . . . . . . . . . 2-34

Sample Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-34

Input Names and Out put Names . . . . . . . . . . . . . . . . . . . . . 2-36

Input Gr oups and Out put Gr oups . . . . . . . . . . . . . . . . . . . . 2-37

Model Conve rsi on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-42

Explicit Conver sion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-42

Aut omat ic Conver sion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-43

Caut ion About Model Conver sions . . . . . . . . . . . . . . . . . . . . . . 2-43

Time De lays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-45

Suppor t ed Funct ionalit y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-45

Specifying Input /Out put Delays . . . . . . . . . . . . . . . . . . . . . . . . 2-46

Dist illat ion Column Example . . . . . . . . . . . . . . . . . . . . . . . . 2-47

Specifying Delays on t he Input s or Out put s . . . . . . . . . . . . . . . 2-50

Input Delay and Out put Delay Pr oper t ies . . . . . . . . . . . . . . . 2-51

Specifying Delays in Discr et e-Time Models . . . . . . . . . . . . . . . 2-52

Mapping Discr et e-Time Delays t o Poles at t he Or igin . . . . 2-53

Ret r ieving Infor mat ion About Delays . . . . . . . . . . . . . . . . . . . . 2-54

Conver sion of Models wit h Delays t o St at e Space . . . . . . . . . . 2-54

Padé Appr oximat ion of Time Delays . . . . . . . . . . . . . . . . . . . . . 2-55

Si muli nk Block for LTI Syst ems . . . . . . . . . . . . . . . . . . . . . . . 2-57

Re ference s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-59

i v Contents

3

Operati ons on LTI Models

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2

Precedence and Property Inheri tance . . . . . . . . . . . . . . . . . . 3-3

Extracti ng and Modi fyi ng Subsyste ms . . . . . . . . . . . . . . . . . . 3-5

Refer encing FRD Models Thr ough Fr equencies . . . . . . . . . . . . . 3-7

Refer encing Channels by Name . . . . . . . . . . . . . . . . . . . . . . . . . 3-8

Resizing LTI Syst ems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9

Ari thmet i c Operati ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11

Addit ion and Subt r act ion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11

Mult iplicat ion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13

Inver sion and Relat ed Oper at ions . . . . . . . . . . . . . . . . . . . . . . 3-13

Tr ansposit ion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-14

Per t r ansposit ion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-14

Oper at ions on St at e-Space Models wit h Delays . . . . . . . . . . . . 3-15

Model Interconnecti on Funct i ons . . . . . . . . . . . . . . . . . . . . . 3-16

Concat enat ion of LTI Models . . . . . . . . . . . . . . . . . . . . . . . . . . 3-17

Feedback and Ot her Int er connect ion Funct ions . . . . . . . . . . . 3-18

Cont i nuous/Di screte Conve rsi ons of LTI Mode ls . . . . . . . . 3-20

Zer o-Or der Hold . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20

Fir st -Or der Hold . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-22

Tust in Appr oximat ion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-22

Tust in wit h Fr equency Pr ewar ping . . . . . . . . . . . . . . . . . . . . . 3-23

Mat ched Poles and Zer os . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-23

Discr et izat ion of Syst ems wit h Delays . . . . . . . . . . . . . . . . . . . 3-24

Delays and Cont inuous/Discr et e Model Conver sions . . . . . . . 3-25

v

Re sampli ng of Di scre te -Ti me Mode ls . . . . . . . . . . . . . . . . . . . 3-27

Re ference s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-28

4

Arrays of LTI Models

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2

When t o Collect a Set of Models in an LTI Ar r ay . . . . . . . . . . . 4-2

Rest r ict ions for LTI Models Collect ed in an Ar r ay . . . . . . . . . . 4-2

Wher e t o Find Infor mat ion on LTI Ar r ays . . . . . . . . . . . . . . . . . 4-3

The Concept of an LTI Array . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4

Higher Dimensional Ar r ays of LTI Models . . . . . . . . . . . . . . . . 4-6

Di mensi ons, Si ze, and Shape of an LTI Array . . . . . . . . . . . . 4-7

size and ndims . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-9

r eshape . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-11

Bui ldi ng LTI Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12

Gener at ing LTI Ar r ays Using r ss . . . . . . . . . . . . . . . . . . . . . . . 4-12

Building LTI Ar r ays Using for Loops . . . . . . . . . . . . . . . . . . . . 4-12

Building LTI Ar r ays Using t he st ack Funct ion . . . . . . . . . . . . 4-15

Building LTI Ar r ays Using t f, zpk, ss, and fr d . . . . . . . . . . . . . 4-17

Specifying Ar r ays of TF models t f . . . . . . . . . . . . . . . . . . . . . 4-17

The Size of LTI Ar r ay Dat a for SS Models . . . . . . . . . . . . . . 4-18

Inde xi ng Int o LTI Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-20

Accessing Par t icular Models in an LTI Ar r ay . . . . . . . . . . . . . 4-20

Single Index Refer encing of Ar r ay Dimensions . . . . . . . . . . 4-21

Ext r act ing LTI Ar r ays of Subsyst ems . . . . . . . . . . . . . . . . . . . 4-21

Reassigning Par t s of an LTI Ar r ay . . . . . . . . . . . . . . . . . . . . . . 4-22

LTI Ar r ays of SS Models wit h Differ ing Number s of St at es 4-23

Delet ing Par t s of an LTI Ar r ay . . . . . . . . . . . . . . . . . . . . . . . . . 4-23

Operati ons on LTI Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-25

Example: Addit ion of Two LTI Ar r ays . . . . . . . . . . . . . . . . . . . 4-26

vi Contents

Dimension Requir ement s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-27

Special Cases for Oper at ions on LTI Ar r ays . . . . . . . . . . . . . . 4-27

Examples of Oper at ions on LTI Ar r ays wit h

Single LTI Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-28

Examples: Ar it hmet ic Oper at ions on LTI Ar r ays

and SISO Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-29

Ot her Oper at ions on LTI Ar r ays . . . . . . . . . . . . . . . . . . . . . . . . 4-30

5

Model Analysi s Tools

General Model Characteri st i cs . . . . . . . . . . . . . . . . . . . . . . . . . 5-2

Model Dynami cs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4

St at e -Space Re ali zati ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-7

Time and Frequency Response . . . . . . . . . . . . . . . . . . . . . . . . . 5-9

Time Responses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-9

Fr equency Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-11

Plot t ing and Compar ing Mult iple Syst ems . . . . . . . . . . . . . . . 5-13

Cust omizing t he Plot Display . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17

Model Orde r Reduct i on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20

6

The LTI Vi ewer

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2

Funct ionalit y of t he LTI Viewer . . . . . . . . . . . . . . . . . . . . . . . . . 6-2

Ge tt ing Started Usi ng the LTI Viewer: An Example . . . . . . 6-4

Init ializing t he LTI Viewer wit h Mult iple Plot s . . . . . . . . . . . . 6-5

Right -Click Menus: Set t ing Response Char act er ist ics . . . . . . . 6-7

vi i

Displaying Response Char act er ist ics on a Plot . . . . . . . . . . . . . 6-9

Impor t ing Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-11

Zooming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-12

The LTI Vi ewer Me nus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-15

The File Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-15

Impor t ing a New Model int o t he LTI Viewer Wor kspace . . 6-15

Opening a New LTI Viewer . . . . . . . . . . . . . . . . . . . . . . . . . . 6-16

Refr eshing Syst ems in t he LTI Viewer Wor kspace . . . . . . . 6-16

Pr int ing Response Plot s . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-16

Get t ing Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-16

St at ic Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-16

Int er act ive Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-17

The Ri ght-Cli ck Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-18

The Right -Click Menu for SISO Models . . . . . . . . . . . . . . . . . . 6-18

Select ing a Menu It em . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-20

The Right -Click Menu for MIMO Models . . . . . . . . . . . . . . . . . 6-21

The Axes Gr ouping Submenu . . . . . . . . . . . . . . . . . . . . . . . . 6-23

The Select I/Os Menu It em . . . . . . . . . . . . . . . . . . . . . . . . . . 6-26

The Right -Click Menu for LTI Ar r ays . . . . . . . . . . . . . . . . . . . 6-28

The Model Select or for LTI Ar r ays . . . . . . . . . . . . . . . . . . . . . . 6-31

Indexing int o t he Ar r ay Dimensions of an LTI Ar r ay . . . . . 6-32

Indexing int o t he LTI Ar r ay Using Design

Specificat ion Cr it er ia . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-35

The LTI Vi ewer Tools Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-39

Viewer Configur at ion Window . . . . . . . . . . . . . . . . . . . . . . . . . 6-39

Response Pr efer ences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-40

Set t ing Response Time Dur at ions and Fr equency Ranges . 6-41

Cust omizing St ep Response Specificat ions . . . . . . . . . . . . . 6-43

Changing t he Fr equency Domain Plot Unit s . . . . . . . . . . . . 6-44

Linest yle Pr efer ences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-44

Changing t he Response Cur ve Linest yle Pr oper t ies . . . . . . 6-46

The Or der in which Line Pr oper t ies ar e Assigned . . . . . . . . 6-47

Si muli nk LTI Vi ewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-48

Using t he Simulink LTI Viewer . . . . . . . . . . . . . . . . . . . . . . . . 6-48

A Sample Analysis Task . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-49

Opening t he Simulink LTI Viewer . . . . . . . . . . . . . . . . . . . . . . 6-50

vi i i Contents

Specifying t he Simulink Model Por t ion for Analysis . . . . . . . . 6-53

Adding Input Point or Out put Point Blocks t o t he Diagr am 6-53

Removing Input Point s and Out put Point s . . . . . . . . . . . . . 6-56

Specifying Open- Ver sus Closed-Loop Analysis Models . . . 6-56

Set t ing t he Oper at ing Condit ions . . . . . . . . . . . . . . . . . . . . . . . 6-57

Modifying t he Block Par amet er s . . . . . . . . . . . . . . . . . . . . . . . . 6-61

Per for ming Linear Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-61

Impor t ing a Linear ized Analysis Model t o t he LTI Viewer . 6-62

Analyzing t he Bode Plot of t he Linear ized Analysis Model 6-63

Specifying Anot her Analysis Model . . . . . . . . . . . . . . . . . . . 6-63

Compar ing t he Bode Plot s of t he Two

Linear ized Analysis Models . . . . . . . . . . . . . . . . . . . . . . . . 6-63

Saving Analysis Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-65

7

Control Desi gn Tools

Root Locus Desi gn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-3

Pole Placement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-5

St at e-Feedback Gain Select ion . . . . . . . . . . . . . . . . . . . . . . . . . . 7-5

St at e Est imat or Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-5

Pole Placement Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-6

LQG Des i gn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-8

Opt imal St at e-Feedback Gain . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-9

Kalman St at e Est imat or . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-9

LQG Regulat or . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-10

LQG Design Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-10

i x

8

The Root Locus Desi gn GUI

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2

A Servomechani sm Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-4

Controlle r Desi gn Usi ng the Root Locus Desi gn GUI . . . . . 8-6

Opening t he Root Locus Design GUI . . . . . . . . . . . . . . . . . . . . . 8-6

Impor t ing Models int o t he Root Locus Design GUI . . . . . . . . . . 8-7

Opening t he Impor t LTI Design Model Window . . . . . . . . . . 8-9

Choosing a Feedback St r uct ur e . . . . . . . . . . . . . . . . . . . . . . 8-10

Specifying t he Design Model . . . . . . . . . . . . . . . . . . . . . . . . . 8-11

Changing t he Gain Set Point and Zooming . . . . . . . . . . . . . . . 8-13

Dr agging Closed-loop Poles t o Change t he Gain Set Point . 8-14

Zooming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-15

St or ing and Ret r ieving Axes Limit s . . . . . . . . . . . . . . . . . . . 8-19

Displaying Syst em Responses . . . . . . . . . . . . . . . . . . . . . . . . . . 8-20

Designing a Compensat or t o Meet Specificat ions . . . . . . . . . . 8-22

Specifying Design Region Boundar ies on t he Root Locus . . 8-24

Placing Compensat or Poles and Zer os:

Gener al Infor mat ion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-26

Placing Compensat or Poles and Zer os

Using t he Root Locus Toolbar . . . . . . . . . . . . . . . . . . . . . . 8-27

Edit ing Compensat or Pole and Zer o Locat ions . . . . . . . . . . 8-31

Saving t he Compensat or and Models . . . . . . . . . . . . . . . . . . . . 8-36

Addi ti onal Root Locus Desi gn GUI Features . . . . . . . . . . . . 8-38

Specifying Design Models: Gener al Concept s . . . . . . . . . . . . . . 8-38

Cr eat ing Models Manually Wit hin t he GUI . . . . . . . . . . . . . 8-38

Designat ing t he Model Sour ce . . . . . . . . . . . . . . . . . . . . . . . 8-39

Get t ing Help wit h t he Root Locus Design GUI . . . . . . . . . . . . 8-39

Using t he Help Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-40

Using t he St at us Bar for Help . . . . . . . . . . . . . . . . . . . . . . . 8-40

Toolt ips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-40

Er asing Compensat or Poles and Zer os . . . . . . . . . . . . . . . . . . . 8-41

List ing Poles and Zer os . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-41

Pr int ing t he Root Locus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-44

Dr awing a Simulink Diagr am . . . . . . . . . . . . . . . . . . . . . . . . . . 8-44

Conver t ing Bet ween Cont inuous and Discr et e Models . . . . . . 8-45

x Contents

Clear ing Dat a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-46

Re ference s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-48

9

Desi gn Case Studi es

Yaw Damper for a 747 J et Transport . . . . . . . . . . . . . . . . . . . . 9-3

Open-Loop Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-6

Root Locus Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-9

Washout Filt er Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-14

Hard-Di sk Read/Wri te He ad Controller . . . . . . . . . . . . . . . . 9-20

LQG Regulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-31

Pr ocess and Dist ur bance Models . . . . . . . . . . . . . . . . . . . . . . . . 9-31

Model Dat a for t he x-Axis . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-34

Model Dat a for t he y-Axis . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-34

LQG Design for t he x-Axis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-34

LQG Design for t he y-Axis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-42

Cr oss-Coupling Bet ween Axes . . . . . . . . . . . . . . . . . . . . . . . . . . 9-43

MIMO LQG Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-47

Kalman Fi lteri ng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-50

Discr et e Kalman Filt er . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-50

St eady-St at e Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-51

Time-Var ying Kalman Filt er . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-57

Time-Var ying Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-58

Refer ences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-63

xi

10

Reli able Computati ons

Condi ti oni ng and Numerical St abi li ty . . . . . . . . . . . . . . . . . 10-4

Condit ioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-4

Numer ical St abilit y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-6

Choi ce of LTI Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-8

St at e Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-8

Tr ansfer Funct ion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-8

Zer o-Pole-Gain Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-14

Scali ng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-15

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-17

Re ference s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-18

11

Reference

Category Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-3

Modal For m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-27

Companion For m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-27

Example 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-30

Example 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-31

Cont inuous Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-57

Discr et e Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-57

H

2

Nor m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-152

Infinit y Nor m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-152

Cr eat ion of St at e-Space Models . . . . . . . . . . . . . . . . . . . . 11-211

Conver sion t o St at e Space . . . . . . . . . . . . . . . . . . . . . . . . . 11-212

Example 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-213

Example 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-213

Cr eat ion of Tr ansfer Funct ions . . . . . . . . . . . . . . . . . . . . . 11-224

Tr ansfer Funct ions as Rat ional Expr essions in s or z . . . 11-225

xi i Contents

Conver sion t o Tr ansfer Funct ion . . . . . . . . . . . . . . . . . . . 11-226

Example 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-226

Example 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-227

Example 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-227

Example 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-228

Cr eat ion of Zer o-Pole-Gain Models . . . . . . . . . . . . . . . . . . 11-238

Zer o-Pole-Gain Models as Rat ional Expr essions in s or z 11-240

Conver sion t o Zer o-Pole-Gain For m . . . . . . . . . . . . . . . . . 11-240

Example 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-241

Example 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-241

Example 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-242

Pr eface

Installati on . . . . . . . . . . . . . . . . . . . . . 3

Ge tt i ng Starte d . . . . . . . . . . . . . . . . . . . 4

Typographi c Conve nti ons . . . . . . . . . . . . . . . 5

Preface

2

MATLAB

®

has a r ich collect ion of funct ions immediat ely useful t o t he cont r ol

engineer or syst em t heor ist . Complex ar it hmet ic, eigenvalues, r oot -finding,

mat r ix inver sion, and FFTs ar e just a few examples of MATLAB’s impor t ant

numer ical t ools. Mor e gener ally, MATLAB’s linear algebr a, mat r ix

comput at ion, and numer ical analysis capabilit ies pr ovide a r eliable foundat ion

for cont r ol syst em engineer ing as well as many ot her disciplines.

The Cont r ol Syst em Toolbox uses MATLAB mat r ix st r uct ur es and builds upon

t he foundat ions of MATLAB t o pr ovide funct ions specialized t o cont r ol

engineer ing. The Cont r ol Syst em Toolbox is a collect ion of algor it hms,

expr essed most ly in M-files, which implement s common cont r ol syst em design,

analysis, and modeling t echniques.

Cont r ol syst ems can be modeled as t r ansfer funct ions or in zer o-pole-gain or

st at e-space for m, allowing you t o use bot h classical and moder n t echniques.

You can manipulat e bot h cont inuous-t ime and discr et e-t ime syst ems.

Conver sions bet ween var ious model r epr esent at ions ar e pr ovided. Time

r esponses, fr equency r esponses, and r oot loci can be comput ed and gr aphed.

Ot her funct ions allow pole placement , opt imal cont r ol, and est imat ion. Finally,

and most impor t ant ly, t ools t hat ar e not found in t he t oolbox can be cr eat ed by

wr it ing new M-files.

Installation

3

Installation

Inst r uct ions for inst alling t he Cont r ol Syst em Toolbox can be found in t he

MATLAB Installation Guide for your plat for m. We r ecommend t hat you st or e

t he files fr om t his t oolbox in a dir ect or y named control off t he main matlab

dir ect or y. To det er mine if t he Cont r ol Syst em Toolbox is alr eady inst alled on

your syst em, check for a subdir ect or y named control wit hin t he main t oolbox

dir ect or y or folder .

Five demonst r at ion files ar e available. The demonst r at ion M-file called

ctrldemo.m r uns t hr ough some basic cont r ol design and analysis funct ions and

t he demonst r at ion files jetdemo.m, diskdemo.m, milldemo.m, and kalmdemo.m

go t hr ough t he design case st udies descr ibed in Chapt er 9. To st ar t a demo,

t ype ctrldemo, for example, at t he MATLAB pr ompt .

Preface

4

Getting Started

If you are a ne w use r, begin wit h Chapt er s 2 t hr ough 5 t o lear n:

•How t o specify and manipulat e linear t ime-invar iant models

•How t o analyze such models and plot t heir t ime and fr equency r esponse

If you are an e xperi enced toolbox use r, see:

•The New Features Guide for det ails on t he lat est r elease

•Chapt er 1 for an over view of some pr oduct feat ur es

•Chapt er 4 t o lear n about LTI ar r ays

•Chapt er 6 for an int r oduct ion t o t he LTI Viewer GUI

•Chapt er 8 for an int r oduct ion t o t he Root Locus Design GUI

All toolbox use rs should use Chapt er 11 for r efer ence infor mat ion on funct ions

and t ools. For funct ions, r efer ence descr ipt ions include a synopsis of t he

funct ion’s synt ax, as well as a complet e explanat ion of opt ions and oper at ion.

Many r efer ence descr ipt ions also include helpful examples, a descr ipt ion of t he

funct ion’s algor it hm, and r efer ences t o addit ional r eading mat er ial. For

GUI-based t ools, t he descr ipt ions include opt ions for invoking t he t ool.

Typographic Conventions

5

Typographic Conventions

To Indicate This Guide Uses Example

Example code Monospace type To assign t he value 5 t o A,

ent er

A = 5

Funct ion

names

Monospace type The cos funct ion finds t he

cosine of each ar r ay

element .

Funct ion

synt ax

Monospace type for t ext

t hat must appear as

shown.

Monospace italics for

component s you can

r eplace wit h any var iable.

The magic funct ion uses

t he synt ax

M = magic(n)

Keys Boldface Pr ess t he Re turn key.

Mat hemat ical

expr essions

Var iables in italics.

Funct ions, oper at or s, and

const ant s in st andar d

t ype.

This vect or r epr esent s t he

polynomial

p = x

2

+ 2x + 3

MATLAB

out put

Monospace type MATLAB r esponds wit h

A =

5

Menu names,

menu it ems,

and cont r ols

Boldface Choose t he File menu.

New t er ms italics An array is an or der ed

collect ion of infor mat ion.

Preface

6

1

Quick St ar t

LTI Mode ls . . . . . . . . . . . . . . . . . . . . . 1-3

MIMO Syst ems . . . . . . . . . . . . . . . . . . . 1-4

Model Conver sion . . . . . . . . . . . . . . . . . . 1-5

LTI Ar r ays . . . . . . . . . . . . . . . . . . . . . 1-6

LTI Properti es . . . . . . . . . . . . . . . . . . . 1-7

Mode l Charact eri s ti cs . . . . . . . . . . . . . . . 1-10

Operati ons on LTI Mode ls . . . . . . . . . . . . . . 1-11

Cont i nuous/Di screte Conversi ons . . . . . . . . . . 1-13

Ti me and Frequency Response . . . . . . . . . . . 1-14

The LTI Vi ewer . . . . . . . . . . . . . . . . . . 1-17

System Int erconnect ions . . . . . . . . . . . . . . 1-19

Control Des i gn Tools . . . . . . . . . . . . . . . . 1-20

The Root Locus Desi gn GUI . . . . . . . . . . . . . 1-23

1 Quick Start

1-2

This chapt er pr ovides a quick over view of some feat ur es of t he Cont r ol Syst ems

Toolbox.

LTI Models

1-3

LTI Models

You can specify linear t ime-invar iant (LTI) syst ems as t r ansfer funct ion (TF)

models, zer o/pole/gain (ZPK) models, st at e-space (SS) models, or frequency

response data (FRD) model. You can const r uct t he cor r esponding models using

t he const r uct or funct ions.

sys = tf(num,den) % transfer function

sys = zpk(z,p,k) % zero/pole/gain

sys = ss(a,b,c,d) % state space

sys = frd(response,frequencies) % frequency response data

To find out infor mat ion about LTI models, t ype

ltimodels

See also “Cr eat ing LTI Models” on page 2-8.

The out put sys is a model-specific dat a st r uct ur e called a TF, ZPK, SS, or FRD

object , r espect ively. These object s st or e t he model dat a and enable you t o

manipulat e t he LTI model as a single ent it y; see “LTI Object s” on page 2-3 for

mor e infor mat ion. For example, t ype

h = tf(1,[1 1]) % creates transfer function 1/(s+1)

and MATLAB r esponds wit h

Transfer function:

1

-----

s + 1

Type

1+h

MATLAB r esponds wit h

Transfer function:

s + 2

-----

s + 1

1 Quick Start

1-4

To cr eat e discr et e-t ime models, append t he sample t ime Ts t o t he pr evious

calling sequences.

sys = tf(num,den,Ts)

sys = zpk(z,p,k,Ts)

sys = ss(a,b,c,d,Ts)

sys = frd(response,frequency,Ts)

For mor e infor mat ion, see “Discr et e-Time Models” on page 2-20.

For example, t ype

sys = zpk(0.5,[–0.1 0.3],1,0.05)

and MATLAB r esponds wit h

Zero/pole/gain:

(z–0.5)

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

(z+0.1) (z–0.3)

Sampling time: 0.05

You can r et r ieve t he model dat a st or ed in t he LTI object sys wit h t he following

commands (see “Dat a Ret r ieval” on page 2-24 for mor e infor mat ion).

[num,den,Ts] = tfdata(sys)

[z,p,k,Ts] = zpkdata(sys)

[a,b,c,d,Ts] = ssdata(sys)

[response,frequency,Ts] = frdata(sys)

Alt er nat ely, you can access t his dat a by dir ect st r uct ur e-like r efer encing (see

“Dir ect Pr oper t y Refer encing” on page 2-33 for mor e infor mat ion), as in t his

example.

sys.num

sys.a

sys.Ts

MIMO Systems

You can also cr eat e mult i-input /mult i-out put (MIMO) models, including

ar bit r ar y MIMO t r ansfer funct ions and zer o/pole/gain models. MIMO t r ansfer

funct ions ar e ar r ays of single-input /single-out put (SISO) t r ansfer funct ions

LTI Models

1-5

wher e each SISO ent r y is char act er ized by it s numer at or and denominat or .

Cell ar r ays pr ovide an ideal means t o specify t he r esult ing ar r ays of

numer at or s and denominat or s; see, “MIMO Tr ansfer Funct ion Models” on page

2-10 for mor e infor mat ion. For example,

num = {0.5,[1 1]} % 1-by-2 cell array of numerators

den = {[1 0],[1 2]} % 1-by-2 cell array of denominators

H = tf(num,den)

cr eat es t he one-out put /t wo-input t r ansfer funct ion

Alt er nat ively, you can cr eat e t he same t r ansfer funct ion by mat r ix-like

concat enat ion of it s SISO ent r ies

h11 = tf(0.5,[1 0]) % 0.5/s

h12 = tf([1 1],[1 2]) % (s+1)/(s+2)

H = [h11,h12]

MIMO zer o/pole/gain syst ems ar e defined in a similar fashion. For example,

t he following commands specify above as a zer o/pole/gain model

Zeros = {[],–1} % Note: use [] when no zero

Poles = {0 ,–2}

Gains = [0.5,1] % Note: use regular matrix for gains

H = zpk(Zeros,Poles,Gains)

Model Conversion

The funct ions tf, zpk, frd, and ss also per for m model conver sion; see “Model

Conver sion” on page 2-42 for mor e infor mat ion. For example,

sys_ss = ss(sys)

conver t s some tf or zpk model sys t o st at e space. Similar ly, if you t ype

h = tf(1,[1 2 1]) % transfer function 1/(s^2+2s+1)

zpk(h)

H s ( )

0.5

s

--------

s 1 +

s 2 +

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

=

H s ( )

1 Quick Start

1-6

MATLAB der ives t he zer o/pole/gain r epr esent at ion of t he t r ansfer funct ion h

Zero/pole/gain:

1

-------

(s+1)^2

LTI Arrays

You can now cr eat e mult idimensional ar r ays of LTI models and manipulat e

t hem as a single ent it y. LTI ar r ays ar e useful t o per for m bat ch analysis on an

ent ir e set of models. For mor e infor mat ion, see Chapt er 4, “Ar r ays of LTI

Models.”

LTI Properties

1-7

LTI Properties

In addit ion t o t he model dat a, t he TF, ZPK, FRD, and SS object s can st or e ext r a

infor mat ion, such as t he syst em sample t ime, t ime delays, and input or out put

names. The var ious pieces of infor mat ion t hat can be at t ached t o an LTI object

ar e called t he LTI properties. For infor mat ion on LTI pr oper t ies, t ype

ltiprops

See also “LTI Pr oper t ies” on page 2-26 and “Time Delays” on page 2-45.

Use set t o list all LTI pr oper t ies and t heir assignable values, and get t o

display t he cur r ent pr oper t ies of t he syst em. For example, t ype

sys = ss(–1,1,1,0,0.5) ;% 1/(z+1), sample time = 0.5 sec

set(sys)

a: Nx-by-Nx matrix (Nx = no. of states)

b: Nx-by-Nu matrix (Nu = no. of inputs)

c: Ny-by-Nx matrix (Ny = no. of outputs)

d: Ny-by-Nu matrix

e: Nx-by-Nx matrix (or empty)

StateName: Nx-by-1 cell array of strings

Ts: scalar

InputDelay: Nu-by-1 vector

OutputDelay: Ny-by-1 vector

ioDelayMatrix: Ny-by-Nu array (I/O delays)

InputName: Nu-by-1 cell array of strings

OutputName: Ny-by-1 cell array of strings

InputGroup: M-by-2 cell array if M input groups

OutputGroup: P-by-2 cell array if P output groups

Notes: array or cell array of strings

UserData: arbitrary

1 Quick Start

1-8

Type:

get(sys)

a: -1

b: 1

c: 1

d: 0

e: []

StateName: {''}

Ts: 0.5

InputDelay: 0

OutputDelay: 0

ioDelayMatrix: 0

InputName: {''}

OutputName: {''}

InputGroup: {0x2 cell}

OutputGroup: {0x2 cell}

Notes: {}

UserData: []

You can also use set and get t o access/modify LTI pr oper t ies in a Handle

Gr aphics

®

fashion; see “Set t ing LTI Pr oper t ies” on page 2-30 for mor e

infor mat ion. For example, give names t o t he input and out put of t he SISO

st at e-space model sys. Type

set(sys,'inputname','thrust','outputname','velocity')

get(sys,'inputn')

MATLAB r esponds wit h

ans =

'thrust'

Finally, you can also use a st r uct ur e-like synt ax for accessing or modifying a

single pr oper t y. For example, t ype

sys.Ts = 0.3; % Set sample time to 0.3 sec.

sys.Ts% Get sample time value

LTI Properties

1-9

MATLAB r et ur ns

ans =

3.0000e–01

1 Quick Start

1-10

Model Characteristics

The Cont r ol Syst em Toolbox cont ains commands t o quer y such model

char act er ist ics as t he I/O dimensions, poles, zer os, and DC gain. See “Gener al

Model Char act er ist ics” on page 5-2 for mor e infor mat ion. These commands

apply t o bot h cont inuous- and discr et e-t ime model. Their LTI-based synt ax is

summar ized below (wit h sys denot ing an ar bit r ar y LTI model).

size(sys) % number of inputs, outputs, and array dimensions

ndims(sys) % number of dimensions

isct(sys) % returns 1 for continuous systems

isdt(sys) % returns 1 for discrete systems

hasdelay(sys) % true if system has delays

pole(sys) % system poles

zero(sys) % system (transmission) zeros

dcgain(sys) % DC gain

norm(sys) % system norms (H2 and Linfinity)

covar(sys,W) % covariance of response to white noise

pade(sys) % Pade approximation of input delays

Operations on LTI Models

1-11

Operations on LTI Models

You can per for m simple mat r ix oper at ions, such as addit ion, mult iplicat ion, or

concat enat ion on LTI models. See Chapt er 3, “Oper at ions on LTI Models” for

mor e infor mat ion. Thanks t o MATLAB object -or ient ed pr ogr amming

capabilit ies, t hese oper at ions assume appr opr iat e funct ionalit ies when applied

t o LTI models. For example, addit ion per for ms a par allel int er connect ion. Type

tf(1,[1 0]) + tf([1 1],[1 2])% 1/s + (s+1)/(s+2)

and MATLAB r esponds:

Transfer function

s^2 + 2 s + 2

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

s^2 + 2 s

Mult iplicat ion per for ms a ser ies int er connect ion. Type

2 * tf(1,[1 0])*tf([1 1],[1 2])% 2*1/s*(s+1)/(s+2)

and MATLAB r esponds

Transfer function:

2 s + 2

---------

s^2 + 2 s

If t he oper ands ar e models of differ ent t ypes, t he r esult ing model t ype is

det er mined by pr ecedence r ules; see “Pr ecedence Rules” on page 2-5 for mor e

infor mat ion. St at e-space models have highest pr ecedence while t r ansfer

funct ions have lowest pr ecedence. Hence t he sum of a t r ansfer funct ion and a

st at e-space model is always a st at e-space model.

Ot her available oper at ions include syst em inver sion, t r ansposit ion, and

per t r ansposit ion; see “Inver sion and Relat ed Oper at ions” on page 3-13.

Mat r ix-like indexing for ext r act ing subsyst ems is also suppor t ed; see

“Ext r act ing and Modifying Subsyst ems” on page 3-5 for mor e infor mat ion. For

inst ance, if sys is a MIMO syst em wit h t wo input s and t hr ee out put s,

sys(3,1)

1 Quick Start

1-12

ext r act s t he subsyst em mapping t he fir st input t o t he t hir d out put . Not e t hat

r ow indices select t he out put s while column indices select t he input s. Similar ly,

sys(3,1) = tf(1,[1 0])

r edefines t he r elat ion bet ween t he fir st input and t hir d out put as an int egr at or .

Continuous/Discrete Conversions

1-13

Continuous/Discrete Conversions

The commands c2d, d2c, and d2d per for m cont inuous t o discr et e, discr et e t o

cont inuous, and discr et e t o discr et e (r esampling) conver sions, r espect ively.

sysd = c2d(sysc,Ts) % discretization w/ sample period Ts

sysc = d2c(sysd) % equivalent continuous-time model

sysd1= d2d(sysd,Ts) % resampling at the period Ts

See “Cont inuous/Discr et e Conver sions of LTI Models” on page 3-20 for mor e

infor mat ion.

Var ious discr et izat ion/int er polat ion met hods ar e available, including

zer o-or der hold (default ), fir st -or der hold, Tust in appr oximat ion wit h or

wit hout pr ewar ping, and mat ched zer o-pole. For example,

sysd = c2d(sysc,Ts,'foh')% uses first-order hold

sysc = d2c(sysd,'tustin')% uses Tustin approx.

1 Quick Start

1-14

Time and Frequency Response

The following commands pr oduce var ious t ime and fr equency r esponse plot s for

LTI models (see “Time and Fr equency Response” on page 5-9 for mor e

infor mat ion).

step(sys) % step response

impulse(sys) % impulse response

initial(sys,x0) % undriven response to initial condition

lsim(sys,u,t,x0) % response to input u

bode(sys) % Bode plot

nyquist(sys) % Nyquist plot

nichols(sys) % Nichols plot

sigma(sys) % singular value plot

freqresp(sys,w) % complex frequency response

These commands wor k for bot h cont inuous- and discr et e-t ime LTI models sys

wit hout r est r ict ion on t he number of input s or out put s. For MIMO syst ems,

t hey pr oduce an ar r ay of plot s wit h one plot per I/O channel. For example,

sys = [tf(1,[1 1]) 1 ; tf([1 5],[1 1 10]) tf(–1,[1 0])];

bode(sys)

Time and Frequency Response

1-15

pr oduces t he Bode plot shown below.

To super impose and compar e t he r esponses of sever al LTI syst ems, use t he

synt ax

bode(sys1,sys2,sys3,...)

You can also cont r ol t he plot st yle by specifying a color /linest yle/mar ker for

each syst em, much as wit h t he plot command; see “Plot t ing and Compar ing

Mult iple Syst ems” on page 5-13 for mor e infor mat ion. For example,

bode(sys1,'r',sys2,'b--')

dr aws t he r esponse of sys1 wit h a r ed solid line and t he r esponse of sys2 wit h

a dashed blue line.

1 Quick Start

1-16

These commands aut omat ically det er mine an appr opr iat e simulat ion hor izon

or fr equency r ange based on t he syst em dynamics. To over r ide t he default

r ange, t ype

step(sys,tfinal) % final time = tfinal

bode(sys,{wmin,wmax}) % freq. range = [wmin,wmax]

The LTI Viewer

1-17

The LTI Viewer

You can also analyze t ime and fr equency domain r esponses using t he LTI

Viewer ; see “The LTI Viewer ” on page 6-1 for mor e infor mat ion. The LTI

Viewer is an int er act ive user int er face t hat assist s you wit h t he analysis of LTI

model r esponses by facilit at ing such funct ions as:

•Toggling bet ween t ypes of r esponse plot s

•Plot t ing r esponses of sever al LTI models

•Zooming int o r egions of t he r esponse plot s

•Calculat ing r esponse char act er ist ics, such as set t ling t ime

•Displaying differ ent I/O channels

•Changing t he plot st yles of t he r esponse plot s

To init ialize an LTI Viewer , t ype

ltiview

ltiview can also be called wit h addit ional input ar gument s t hat allow you t o

specify t he t ype of LTI model r esponse displayed when t he window is fir st

opened. The gener ic synt ax is

ltiview(plottype,sys1,...,sysn)

wher e sys1,...,sysn ar e names of LTI models in t he MATLAB wor kspace and

plottype is eit her a st r ing for one of t he following plot t ypes, or a cell ar r ay,

cont aining up t o six of t he following st r ings

'step'

'impulse'

'initial'

'lsim'

'pzmap'

'bode'

'nyquist'

'nichols'

'sigma'

For example, you can init ialize an LTI Viewer showing t he st ep r esponse of t he

LTI model sys by

ltiview('step',sys)

1 Quick Start

1-18

For mor e det ail on t he use of t he LTI Viewer and how it can be int egr at ed int o

a Simulink diagr am, see Chapt er 6, “The LTI Viewer .”

System Interconnections

1-19

System Interconnections

You can der ive LTI models for var ious syst em int er connect ions r anging fr om

simple ser ies connect ions t o mor e complex block diagr ams; see “Model

Int er connect ion Funct ions” on page 3-16 for mor e infor mat ion. Relat ed

commands include

append(sys1,sys2,...) % appends systems inputs and outputs

parallel(sys1,sys2) % general parallel connection

series(sys1,sys2) % general series connection

feedback(sys1,sys2) % feedback loop

lft(sys1,sys2) % LFT interconnection (star product)

connect(sys,q) % state-space model of block diagram

Not e t hat simple par allel and ser ies int er connect ions can be per for med by

dir ect addit ion and mult iplicat ion, r espect ively.

When combining LTI models of differ ent t ypes (for example, st at e-space sys1

and t r ansfer funct ion sys2), t he t ype of t he r esult ant model is det er mined by

t he same pr ecedence r ules as for ar it hmet ic oper at ions. See “Pr ecedence Rules”

on page 2-5 for mor e infor mat ion. Specifically, t he r anking of t he differ ent

t ypes of LTI models fr om highest t o lowest pr ecedence is FRD, SS, ZPK, and

TF.

1 Quick Start

1-20

Control Design Tools

The Cont r ol Syst em Toolbox suppor t s t hr ee mainst r eam cont r ol design

met hodologies: gain select ion fr om r oot locus, pole placement , and

linear -quadr at ic-Gaussian (LQG) r egulat ion. The fir st t wo t echniques ar e

cover ed by t he rlocus and place commands. The LQG design t ools include

commands t o comput e t he LQ-opt imal st at e-feedback gain (lqr, dlqr, and

lqry), t o design t he Kalman filt er (kalman), and t o for m t he r esult ing LQG

r egulat or (lqgreg). See “LQG Design” on page 7-8 for mor e infor mat ion.

As an example of LQG design, consider t he r egulat ion pr oblem illust r at ed by

Figur e 1-1. The goal is t o r egulat e t he plant out put ar ound zer o. The syst em

is dr iven by t he whit e noise dist ur bance , t her e is some measur ement noise

, and t he noise int ensit ies ar e given by

The cost funct ion

is used t o specify t he t r ade-off bet ween r egulat ion per for mance and cost of

cont r ol. Not e t hat an open-loop st at e-space model is

wher e is a st at e-space r ealizat ion of .

y

d

n

E d

2

( ) 1, = E n

2

( ) 0.01 =

J u ( ) 10y

2

u

2

+ ( ) t d

0

∞

∫

=

x

·

Ax Bu Bd + + = (st at e equat ions)

y

n

Cx n + = (measur ement s)

A B C , , ( ) 100 s

2

s 100 + + ( ) ⁄

Control Design Tools

1-21

Figure 1-1: Simple Regulation Loop

The following commands design t he opt imal LQG r egulat or for t his

pr oblem.

sys = ss(tf(100,[1 1 100]))% state-space plant model

% Design LQ-optimal gain K

K = lqry(sys,10,1) % u = –Kx minimizes J(u)

% Separate control input u and disturbance input d

P = sys(:,[^ ^]);

% input [u;d], output y

% Design Kalman state estimator KEST

Kest = kalman(P,1,0.01)

% Form LQG regulator = LQ gain + Kalman filter

F = lqgreg(Kest,K)

The last command r et ur ns a st at e-space model F of t he LQG r egulat or .

Not e t hat lqry, kalman, and lqgreg per for m discr et e-t ime LQG design when

applied t o discr et e plant s.

100

s

2

s 100 + +

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

LQG r egulat or

+

+

+

+

F s ( ) n

y d

u

u d +

Plant

y

n

F s ( )

F s ( )

1 Quick Start

1-22

To validat e t he design, close t he loop wit h feedback and compar e t he open- and

closed-loop impulse r esponses wit h impulse.

% Close loop

clsys = feedback(sys,F,+1) % Note positive feedback

% Open- vs. closed-loop impulse responses

impulse(sys,'r--',clsys,'b-')

Time (sec.)

A

m

p

l

i

t

u

d

e

Impulse Response

0 2 4 6 8 10 12

−8

−6

−4

−2

0

2

4

6

8

10

The Root Locus Design GUI

1-23

The Root Locus Design GUI

You can also design a compensat or using t he Root Locus Design Gr aphical

User Int er face (GUI). See Chapt er 8, “The Root Locus Design GUI” for mor e

infor mat ion. The Root Locus Design GUI is an int er act ive gr aphical user

int er face t hat assist s you in designing a compensat or by pr oviding t he

following feat ur es:

•Tuning t he value of t he feedback or compensat or gain

•Adding/r emoving compensat or poles and zer os dir ect ly on t he r oot locus plot

•Dr agging compensat or poles and zer os ar ound in t he r oot locus plane

•Examining changes in t he closed-loop r esponse whenever t he compensat or is

changed

•Dr awing boundar ies on t he r oot locus plane for par amet er s such as

minimum damping r at io, et c.

•Zooming in t o r egions of t he r oot locus

To init ialize t he Root Locus Design GUI, simply t ype

rltool

rltool can also be called wit h addit ional input ar gument s t hat allow you t o

init ialize t he plant and compensat or used in t he Root Locus Design GUI. For

example,

rltool(sys)

init ializes a Root Locus Design GUI wit h t he linear t ime invar iant (LTI) object

sys as t he plant . Adding a second input ar gument , as in

rltool(sys,comp)

also init ializes t he LTI object comp as t he r oot locus compensat or .

When one or t wo input ar gument s ar e pr ovided, t he r oot locus of t he closed-loop

poles and t heir locat ions for t he cur r ent compensat or gain ar e dr awn. The

closed-loop model is gener at ed by placing t he compensat or and design model in

t he for war d pat h of a negat ive unit y feedback syst em.

1 Quick Start

1-24

2

LTI Models

Introduct i on . . . . . . . . . . . . . . . . . . . . 2-2

Cre ati ng LTI Mode ls . . . . . . . . . . . . . . . . 2-8

LTI Properti es . . . . . . . . . . . . . . . . . . . 2-26

Mode l Conve rsi on . . . . . . . . . . . . . . . . . 2-42

Ti me Delays . . . . . . . . . . . . . . . . . . . . 2-45

Si mulink Block for LTI Syst ems . . . . . . . . . . . 2-57

Refe re nce s . . . . . . . . . . . . . . . . . . . . . 2-59

2 LTI Models

2-2

Introduction

The Cont r ol Syst em Toolbox offer s ext ensive t ools t o manipulat e and analyze

linear t ime-invar iant (LTI) models. It suppor t s bot h cont inuous- and

discr et e-t ime syst ems. Syst ems can be single-input /single-out put (SISO) or

mult iple-input /mult iple-out put (MIMO). In addit ion, you can st or e sever al LTI

models in an ar r ay under a single var iable name. See Chapt er 4, “Ar r ays of LTI

Models” for infor mat ion on LTI ar r ays.

This sect ion int r oduces key concept s about t he MATLAB r epr esent at ion of LTI

models, including LTI object s, pr ecedence r ules for oper at ions, and an analogy

bet ween LTI syst ems and mat r ices. In addit ion, it summar izes t he basic

commands you can use on LTI object s.

LTI Models

You can specify LTI models as:

•Tr ansfer funct ions (TF), for example,

•Zer o-pole-gain models (ZPK), for example,

•St at e-space models (SS), for example,

wher e A, B, C, and D ar e mat r ices of appr opr iat e dimensions, x is t he st at e

vect or , and u and y ar e t he input and out put vect or s.

•Fr equency r esponse dat a (FRD) models

FRD models consist of sampled measur ement s of a syst em’s fr equency

r esponse. For example, you can st or e exper iment ally collect ed fr equency

r esponse dat a in an FRD.

P s ( )

s 2 +

s

2

s 10 + +

--------------------------- =

H z ( )

2 z 0.5 – ( )

z z 0.1 + ( )

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

z

2

z 1 + + ( )

z 0.2 + ( ) z 0.1 + ( )

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

=

x d

t d

------ Ax Bu + =

y Cx Du + =

Introduction

2-3

Using LTI Models in the Control System Toolbox

You can manipulat e TF, SS, and ZPK models using t he ar it hmet ic and model

int er connect ion oper at ions descr ibed in Chapt er 3, “Oper at ions on LTI

Models,” and analyze t hem using t he model analysis funct ions, such as bode

and step, descr ibed in Chapt er 5, “Model Analysis Tools.” FRD models can be

manipulat ed and analyzed in much t he same way you analyze t he ot her model

t ypes, but analysis is r est r ict ed t o fr equency-domain met hods.

Using a var iet y of design t echniques, you can design compensat or s for syst ems

specified wit h TF, ZPK, SS, and FRD models. These t echniques include r oot

locus analysis, pole placement , LQG opt imal cont r ol, and fr equency domain

loop-shaping. For FRD models, you can eit her :

•Obt ain an ident ified TF, SS, or ZPK model using syst em ident ificat ion

t echniques.

•Use fr equency-domain analysis t echniques.

Other Uses of FRD Models

FRD models ar e unique model t ypes available in t he Cont r ol Syst em Toolbox

collect ion of LTI model t ypes, in t hat t hey don’t have a par amet r ic

r epr esent at ion. In addit ion t o t he st andar d oper at ions you may per for m on

FRD models, you can also use t hem t o:

•Per for m fr equency-domain analysis on syst ems wit h nonlinear it ies using

descr ibing funct ions.

•Validat e ident ified models against exper iment al fr equency r esponse dat a.

LTI Objects

Depending on t he t ype of model you use, t he dat a for your model may consist

of a simple numer at or /denominat or pair for SISO t r ansfer funct ions, four

mat r ices for st at e-space models, and mult iple set s of zer os and poles for MIMO

zer o-pole-gain models or fr equency and r esponse vect or s for FRD models. For

convenience, t he Cont r ol Syst em Toolbox pr ovides cust omized dat a st r uct ur es

(LTI objects) for each t ype of model. These ar e called t he TF, ZPK, SS, and FRD

object s. These four LTI object s encapsulat e t he model dat a and enable you t o

manipulat e LTI syst ems as single ent it ies r at her t han collect ions of dat a

vect or s or mat r ices.

2 LTI Models

2-4

Creating an LTI Object: An Example

An LTI object of t he t ype TF, ZPK, SS, or FRD is cr eat ed whenever you invoke

t he cor r esponding const r uct or funct ion, tf, zpk, ss, or frd. For example,

P = tf([1 2],[1 1 10])

cr eat es a TF object , P, t hat st or es t he numer at or and denominat or coefficient s

of t he t r ansfer funct ion

See “Cr eat ing LTI Models” on page 2-8 for met hods for cr eat ing all of t he LTI

object t ypes.

LTI Properties and Methods

The LTI object implement at ion r elies on MATLAB object -or ient ed

pr ogr amming capabilit ies. Object s ar e MATLAB st r uct ur es wit h an addit ional

flag indicat ing t heir class (TF, ZPK, SS, or FRD for LTI object s) and have

pr e-defined fields called object properties. For LTI object s, t hese pr oper t ies

include t he model dat a, sample t ime, delay t imes, input or out put names, and

input or out put gr oups (see “LTI Pr oper t ies” on page 2-26 for det ails). The

funct ions t hat oper at e on a par t icular object ar e called t he object methods.

These may include cust omized ver sions of simple oper at ions such as addit ion

or mult iplicat ion. For example,

P = tf([1 2],[1 1 10])

Q = 2 + P

per for ms t r ansfer funct ion addit ion.

The object -specific ver sions of such st andar d oper at ions ar e called overloaded

oper at ions. For mor e det ails on object s, met hods, and object -or ient ed

pr ogr amming, see Chapt er 14, “Classes and Object s” in Using MATLAB. For

det ails on oper at ions on LTI object s, see Chapt er 3, “Oper at ions on LTI

Models.”

P s ( )

s 2 +

s

2

s 10 + +

--------------------------- =

Q s ( ) 2 P s ( ) +

2s

2

3s 22 + +

s

2

s 10 + +

----------------------------------- = =

Introduction

2-5

Precedence Rules

Oper at ions like addit ion and commands like feedback oper at e on mor e t han

one LTI model at a t ime. If t hese LTI models ar e r epr esent ed as LTI object s of

differ ent t ypes (for example, t he fir st oper and is TF and t he second oper and is

SS), it is not obvious what t ype (for example, TF or SS) t he r esult ing model

should be. Such t ype conflict s ar e r esolved by precedence rules. Specifically, TF,

ZPK, SS, and FRD object s ar e r anked accor ding t o t he pr ecedence hier ar chy.

Thus ZPK t akes pr ecedence over TF, SS t akes pr ecedence over bot h TF and

ZPK, and FRD t akes pr ecedence over all t hr ee. In ot her wor ds, any oper at ion

involving t wo or mor e LTI models pr oduces:

•An FRD object if at least one oper and is an FRD object

•An SS object if no oper and is an FRD object and at least one oper and is an

SS object

•A ZPK object if no oper and is an FRD or SS object and at least one is an ZPK

object

•A TF object only if all oper ands ar e TF object s

Oper at ions on syst ems of differ ent t ypes wor k as follows: t he r esult ing t ype is

det er mined by t he pr ecedence r ules, and all oper ands ar e fir st conver t ed t o t his

t ype befor e per for ming t he oper at ion.

Viewing LTI Systems As Matrices

In t he fr equency domain, an LTI syst em is r epr esent ed by t he linear input /

out put map

This map is char act er ized by it s t r ansfer mat r ix H, a funct ion of eit her t he

Laplace or Z-t r ansfor m var iable. The t r ansfer mat r ix H maps input s t o

out put s, so t her e ar e as many columns as input s and as many r ows as out put s.

If you t hink of LTI syst ems in t er ms of (t r ansfer ) mat r ices, cer t ain basic

oper at ions on LTI syst ems ar e nat ur ally expr essed wit h a mat r ix-like synt ax.

FRD > SS > ZPK > TF

y Hu =

2 LTI Models

2-6

For example, t he par allel connect ion of t wo LTI syst ems sys1 and sys2 can be

expr essed as

sys = sys1 + sys2

because par allel connect ion amount s t o adding t he t r ansfer mat r ices.

Similar ly, subsyst ems of a given LTI model sys can be ext r act ed using

mat r ix-like subscr ipt ing. For inst ance,

sys(3,1:2)

pr ovides t he I/O r elat ion bet ween t he fir st t wo input s (column indices) and t he

t hir d out put (r ow index), which is consist ent wit h

for .

Command Summary

The next t wo t ables give an over view of t he main commands you can apply t o

LTI models.

Table 2-1: Creating LTI Models or Getting Data From Them

Command Description

drss Gener at e r andom discr et e st at e-space model.

dss Cr eat e descr ipt or st at e-space model.

filt Cr eat e discr et e filt er wit h DSP convent ion.

frd Cr eat e an FRD model.

frdata Ret r ieve FRD model dat a.

get Quer y LTI model pr oper t ies.

rss Gener at e r andom cont inuous st at e-space model.

y

1

y

2

y

3

H 1 1 , ( ) H 2 1 , ( )

H 2 1 , ( ) H 2 2 , ( )

H 3 1 , ( ) H 3 2 , ( )

u

1

u

2

=

y Hu =

Introduction

2-7

set Set LTI model pr oper t ies.

size Get out put /input /ar r ay dimensions or model or der.

ss Cr eat e a st at e-space model.

ssdata, dssdata Ret r ieve st at e-space dat a (r espect ively, descr ipt or

st at e-space dat a) or conver t it t o cell ar r ay for mat .

tf Cr eat e a t r ansfer funct ion.

tfdata Ret r ieve t r ansfer funct ion dat a.

zpk Cr eat e a zer o-pole-gain model.

zpkdata Ret r ieve zer o-pole-gain dat a.

Table 2-2: Converting LTI Models

Command Description

c2d Cont inuous- t o discr et e-t ime conver sion.

d2c Discr et e- t o cont inuous-t ime conver sion.

d2d Resampling of discr et e-t ime models.

frd Conver sion t o an FRD model.

pade Padé appr oximat ion of input delays.

ss Conver sion t o st at e space.

tf Conver sion t o t r ansfer funct ion.

zpk Conver sion t o zer o-pole-gain.

Table 2-1: Creating LTI Models or Getting Data From Them (Continued)

Command Description

2 LTI Models

2-8

Creating LTI Models

The funct ions tf, zpk, ss, and frd cr eat e t r ansfer funct ion models,

zer o-pole-gain models, st at e-space models, and fr equency r esponse dat a

models, r espect ively. These funct ions t ake t he model dat a as input and pr oduce

TF, ZPK, SS, or FRD object s t hat st or e t his dat a in a single MATLAB var iable.

This sect ion shows how t o cr eat e cont inuous or discr et e, SISO or MIMO LTI

models wit h tf, zpk, ss, and frd.

Note: You can only specify TF, ZPK, and SS models for syst ems whose

t r ansfer mat r ices have r eal-valued coefficient s.

Transfer Function Models

This sect ion explains how t o specify cont inuous-t ime SISO and MIMO t r ansfer

funct ion models. The specificat ion of discr et e-t ime t r ansfer funct ion models is

a simple ext ension of t he cont inuous-t ime case (see “Discr et e-Time Models” on

page 2-20). In t his sect ion you can also r ead about how t o specify t r ansfer

funct ions consist ing of pur e gains.

SISO Transfer Function Models

A cont inuous-t ime SISO t r ansfer funct ion

is char act er ized by it s numer at or and denominat or , bot h

polynomials of t he Laplace var iable s.

Ther e ar e t wo ways t o specify SISO t r ansfer funct ions:

•Using t he tf command

•As r at ional expr essions in t he Laplace var iable s

To specify a SISO t r ansfer funct ion model using t he tf

command, t ype

h = tf(num,den)

h s ( )

n s ( )

d s ( )

----------- =

n s ( ) d s ( )

h s ( ) n s ( ) d s ( ) ⁄ =

Creating LTI Models

2-9

wher e num and den ar e r ow vect or s list ing t he coefficient s of t he polynomials

and , r espect ively, when t hese polynomials ar e or der ed in descending

power s of s. The r esult ing var iable h is a TF object cont aining t he numer at or

and denominat or dat a.

For example, you can cr eat e t he t r ansfer funct ion by

t yping

h = tf([1 0],[1 2 10])

MATLAB r esponds wit h

Transfer function:

s

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

s^2 + 2 s + 10

Not e t he cust omized display used for TF object s.

You can also specify t r ansfer funct ions as r at ional expr essions in t he Laplace

var iable s by:

1 Defining t he var iable s as a special TF model

s = tf('s');

2 Ent er ing your t r ansfer funct ion as a r at ional expr ession in s

For example, once s is defined wit h tf as in 1,

H = s/(s^2 + 2*s +10);

pr oduces t he same t r ansfer funct ion as

h = tf([1 0],[1 2 10]);

Note: You need only define t he var iable s as a TF model once. All of t he

subsequent models you cr eat e using r at ional expr essions of s ar e specified as

TF object s, unless you conver t t he var iable s t o ZPK. See “Model Conver sion”

on page 2-42 for mor e infor mat ion.

n s ( ) d s ( )

h s ( ) s s

2

2s 10 + + ( ) ⁄ =

2 LTI Models

2-10

MIMO Transfer Function Models

MIMO t r ansfer funct ions ar e t wo-dimensional ar r ays of element ar y SISO

t r ansfer funct ions. Ther e ar e sever al ways t o specify MIMO t r ansfer funct ion

models, including:

•Concat enat ion of SISO t r ansfer funct ion models

•Using tf wit h cell ar r ay ar gument s

Consider t he r at ional t r ansfer mat r ix

.

You can specify by concat enat ion of it s SISO ent r ies. For inst ance,

h11 = tf([1 –1],[1 1]);

h21 = tf([1 2],[1 4 5]);

or , equivalent ly,

s = tf('s')

h11 = (s–1)/(s+1);

h21 = (s+2)/(s^2+4*s+5);

can be concat enat ed t o for m .

H = [h11; h21]

This synt ax mimics st andar d mat r ix concat enat ion and t ends t o be easier and

mor e r eadable for MIMO syst ems wit h many input s and/or out put s. See “Model

Int er connect ion Funct ions” on page 3-16 for mor e det ails on concat enat ion

oper at ions for LTI syst ems.

Alt er nat ively, t o define MIMO t r ansfer funct ions using tf, you need t wo cell

ar r ays (say, N and D) t o r epr esent t he set s of numer at or and denominat or

polynomials, r espect ively. See Chapt er 13, “St r uct ur es and Cell Ar r ays” in

Using MATLAB for mor e det ails on cell ar r ays.

H s ( )

s 1 –

s 1 +

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

s 2 +

s

2

4s 5 + +

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

=

H s ( )

H s ( )

Creating LTI Models

2-11

For example, for t he r at ional t r ansfer mat r ix , t he t wo cell ar r ays N and D

should cont ain t he r ow-vect or r epr esent at ions of t he polynomial ent r ies of

You can specify t his MIMO t r ansfer mat r ix by t yping

N = {[1 –1];[1 2]}; % cell array for N(s)

D = {[1 1];[1 4 5]}; % cell array for D(s)

H = tf(N,D)

MATLAB r esponds wit h

Transfer function from input to output...

s – 1

#1: -----

s + 1

s + 2

#2: -------------

s^2 + 4 s + 5

Not ice t hat bot h N and D have t he same dimensions as H. For a gener al MIMO

t r ansfer mat r ix , t he cell ar r ay ent r ies N{i,j} and D{i,j} should be

r ow-vect or r epr esent at ions of t he numer at or and denominat or of , t he

ent r y of t he t r ansfer mat r ix .

Pure Gains

You can use tf wit h only one ar gument t o specify simple gains or gain mat r ices

as TF object s. For example,

G = tf([1 0;2 1])

pr oduces t he gain mat r ix

H s ( )

N s ( )

s 1 –

s 2 +

= D s ( )

s 1 +

s

2

4s 5 + +

=

H s ( )

H s ( )

H

i j

s ( )

i j t h H s ( )

G

1 0

2 1

=

2 LTI Models

2-12

while

E = tf

cr eat es an empt y t r ansfer funct ion.

Zero-Pole-Gain Models

This sect ion explains how t o specify cont inuous-t ime SISO and MIMO

zer o-pole-gain models. The specificat ion for discr et e-t ime zer o-pole-gain

models is a simple ext ension of t he cont inuous-t ime case. See “Discr et e-Time

Models” on page 2-20.

SISO Zero-Pole-Gain Models

Cont inuous-t ime SISO zer o-pole-gain models ar e of t he for m

wher e is a r eal-valued scalar (t he gain), and ,..., and ,..., ar e t he

r eal or complex conjugat e pair s of zer os and poles of t he t r ansfer funct ion .

This model is closely r elat ed t o t he t r ansfer funct ion r epr esent at ion: t he zer os

ar e simply t he numer at or r oot s, and t he poles, t he denominat or r oot s.

Ther e ar e t wo ways t o specify SISO zer o-pole-gain models:

•Using t he zpk command

•As r at ional expr essions in t he Laplace var iable s

The synt ax t o specify ZPK models dir ect ly using zpk is

h = zpk(z,p,k)

wher e z and p ar e t he vect or s of zer os and poles, and k is t he gain. This

pr oduces a ZPK object h t hat encapsulat es t he z, p, and k dat a. For example,

t yping

h = zpk(0, [1–i 1+i 2], –2)

h s ( ) k

s z

1

– ( ) ... s z

m

– ( )

s p

1

– ( ) ... s p

n

– ( )

------------------------------------------------ - =

k z

1

z

m

p

1

p

n

h s ( )

Creating LTI Models

2-13

pr oduces

Zero/pole/gain:

–2 s

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

(s–2) (s^2 – 2s + 2)

You can also specify zer o-pole-gain models as r at ional expr essions in t he

Laplace var iable s by:

1 Defining t he var iable s as a ZPK model

s = zpk('s')

2 Ent er ing t he t r ansfer funct ion as a r at ional expr ession in s.

For example, once s is defined wit h zpk,

H = –2s/((s – 2)*(s^2 + 2*s + 2));

r et ur ns t he same ZPK model as

h = zpk([0], [2 –1–i –1+i ], –2);

Note: You need only define t he ZPK var iable s once. All subsequent r at ional

expr essions of s will be ZPK models, unless you conver t t he var iable s t o TF.

See “Model Conver sion” on page 2-42 for mor e infor mat ion on conver sion t o

ot her model t ypes.

MIMO Zero-Pole-Gain Models

J ust as wit h TF models, you can also specify a MIMO ZPK model by

concat enat ion of it s SISO ent r ies (see “Model Int er connect ion Funct ions” on

page 3-16).

You can also use t he command zpk t o specify MIMO ZPK models. The synt ax

t o cr eat e a p-by-m MIMO zer o-pole-gain model using zpk is

H = zpk(Z,P,K)

2 LTI Models

2-14

wher e

•Z is t he p-by-m cell ar r ay of zer os (Z{i,j} = zer os of )

•P is t he p-by-m cell ar r ay of poles (P{i,j} = poles of )

•K is t he p-by-m mat r ix of gains (K(i,j) = gain of )

For example, t yping

Z = {[],–5;[1–i 1+i] []};

P = {0,[–1 –1];[1 2 3],[]};

K = [–1 3;2 0];

H = zpk(Z,P,K)

cr eat es t he t wo-input /t wo-out put zer o-pole-gain model

Not ice t hat you use [] as a place-holder in Z (or P) when t he cor r esponding

ent r y of has no zer os (or poles).

State-Space Models

St at e-space models r ely on linear differ ent ial or differ ence equat ions t o

descr ibe t he syst em dynamics. Cont inuous-t ime models ar e of t he for m

wher e x is t he st at e vect or and u and y ar e t he input and out put vect or s. Such

models may ar ise fr om t he equat ions of physics, fr om st at e-space

ident ificat ion, or by st at e-space r ealizat ion of t he syst em t r ansfer funct ion.

H

i j

s ( )

H

i j

s ( )

H

i j

s ( )

H s ( )

1 –

s

------

3 s 5 + ( )

s 1 + ( )

2

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

2 s

2

2s – 2 + ( )

s 1 – ( ) s 2 – ( ) s 3 – ( )

--------------------------------------------------- 0

=

H s ( )

x d

t d

------ Ax Bu + =

y Cx Du + =

Creating LTI Models

2-15

Use t he command ss t o cr eat e st at e-space models

sys = ss(A,B,C,D)

For a model wit h Nx st at es, Ny out put s, and Nu input s

•A is an Nx-by-Nx r eal-valued mat r ix.

•B is an Nx-by-Nu r eal-valued mat r ix.

•C is an Ny-by-Nx r eal-valued mat r ix.

•D is an Ny-by-Nu r eal-valued mat r ix.

This pr oduces an SS object sys t hat st or es t he st at e-space mat r ices

. For models wit h a zer o D mat r ix, you can use D = 0 (zer o) as a

shor t hand for a zer o mat r ix of t he appr opr iat e dimensions.

As an illust r at ion, consider t he following simple model of an elect r ic mot or .

wher e is t he angular displacement of t he r ot or and t he dr iving cur r ent .

The r elat ion bet ween t he input cur r ent and t he angular velocit y

is descr ibed by t he st at e-space equat ions

wher e

This model is specified by t yping

sys = ss([0 1;–5 –2],[0;3],[0 1],0)

A B C and D , , ,

d

2

θ

t

2

d

---------- 2

θ d

t d

------ 5θ + + 3I =

θ I

u I =

y d θ d t ⁄ =

x d

t d

------ Ax B u + =

y Cx =

x

θ

θ d

t d

------

= A

0 1

5 – 2 –

= B

0

3

= C

0 1

=

2 LTI Models

2-16

t o which MATLAB r esponds

a =

x1 x2

x1 0 1.00000

x2 –5.00000 –2.00000

b =

u1

x1 0

x2 3.00000

c =

x1 x2

y1 0 1.00000

d =

u1

y1 0

In addit ion t o t he A, B, C, and D mat r ices, t he display of st at e-space models

includes st at e names, input names, and out put names. Default names (her e,

x1, x2, u1, and y1) ar e displayed whenever you leave t hese unspecified. See

“LTI Pr oper t ies” on page 2-26 for mor e infor mat ion on how t o specify st at e,

input , or out put names.

Descriptor State-Space Models

Descr ipt or st at e-space (DSS) models ar e a gener alizat ion of t he st andar d

st at e-space models discussed above. They ar e of t he for m

The Cont r ol Syst em Toolbox suppor t s only descr ipt or syst ems wit h a

nonsingular mat r ix. While such models have an equivalent explicit for m

E

x d

t d

------ Ax Bu + =

y Cx Du + =

E

x d

t d

------ E

1 –

A ( )x E

1 –

B ( )u + =

y Cx Du + =

Creating LTI Models

2-17

it is oft en desir able t o wor k wit h t he descr ipt or for m when t he mat r ix is

poor ly condit ioned wit h r espect t o inver sion.

The funct ion dss is t he count er par t of ss for descr ipt or st at e-space models.

Specifically,

sys = dss(A,B,C,D,E)

cr eat es a cont inuous-t ime DSS model wit h mat r ix dat a A,B,C,D,E. For

example, consider t he dynamical model

wit h vect or of angular velocit ies. If t he iner t ia mat r ix is poor ly condit ioned

wit h r espect t o inver sion, you can specify t his syst em as a descr ipt or model by

sys = dss(–F,eye(n),eye(n),0,J) % n = length of vector

Frequency Response Data (FRD) Models

In some inst ances, you may only have sampled fr equency r esponse dat a, r at her

t han a t r ansfer funct ion or st at e-space model for t he syst em you want t o

analyze or cont r ol. For infor mat ion on fr equency r esponse analysis of linear

syst ems, see Chapt er 8 of [1].

For example, suppose t he fr equency r esponse funct ion for t he SISO syst em you

want t o model is G(w). Suppose, in addit ion, t hat you per for m an exper iment

t o evaluat e G(w) at a fixed set of fr equencies, . You can do t his by

dr iving t he syst em wit h a sequence of sinusoids at each of t hese fr equencies, as

depict ed below.

E

J

d ω

d t

-------- Fω + T =

y ω =

ω J

ω

w

1

w

2

… w

n

, , ,

w

i

t sin

G(w) =

y

i

t ( )

2 LTI Models

2-18

Her e is t he input fr equency of each sinusoid, i = 1 ... n, and G(w) =

. The st eady st at e out put r esponse of t his syst em sat isfies

A frequency response data (FRD) object is a model for m you can use t o st or e

fr equency r esponse dat a (complex fr equency r esponse, along wit h a

cor r esponding vect or of fr equency point s) t hat you obt ain eit her t hr ough

simulat ions or exper iment ally. In t his example, t he fr equency r esponse dat a is

obt ained fr om t he set of r esponse pair s: .

Once you st or e your dat a in an FRD model, you can t r eat it as an LTI model,

and manipulat e an FRD model in most of t he same ways you manipulat e TF,

SS, and ZPK models.

The basic synt ax for cr eat ing a SISO FRD model is

sys = frd(response,frequencies,units)

wher e

•frequencies is a r eal vect or of lengt h Nf.

•response is a vect or of lengt h Nf of complex fr equency r esponse values for

t hese fr equencies.

•units is an opt ional st r ing for t he unit s of fr equency: eit her 'rad/s' (default )

or 'Hz'

w

i

G w ( ) j G w ( ) ∠ ( ) exp

y

i

t ( ) G w

i

( ) w

i

t G w

i

( ) ∠ + ( ) i ; sin 1…n = =

G w

i

( ) w

i

( , ) { } i , 1…n =

Creating LTI Models

2-19

For example, t he MAT-file LTIexamples.mat cont ains a fr equency vect or freq,

and a cor r esponding complex fr equency r esponse dat a vect or respG. To load

t his fr equency-domain dat a and const r uct an FRD model, t ype

load LTIexamples

sys = frd(respG,freq)

Continuous-time frequency response with 1 output and 1 input

at 5 frequency points.

From input 1 to:

Frequency(rad/s) output 1

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

1 –0.812505 –0.000312i

2 –0.092593 –0.462963i

4 –0.075781 –0.001625i

5 –0.043735 –0.000390i

The synt ax for cr eat ing a MIMO FRD model is t he same as for t he SISO case,

except t hat response is a p-by-m-by-N

f

mult idimensional ar r ay, wher e p is t he

number of out put s, m is t he number of input s, and N

f

is t he number of

fr equency dat a point s (t he lengt h of frequency).

The following t able summar izes t he complex-valued r esponse dat a for mat for

FRD models.

Table 2-3: Data Format for the Argument response in FRD Models

Model Form Response Data Format

SISO model Vect or of lengt h Nf for which response(i) is t he

fr equency r esponse at t he fr equency frequency(i)

MIMO model

wit h Ny out put s

and Nu input s

Ny-by-Nu-by-Nf mult idimensional ar r ay for which

response(i,j,k) specifies t he fr equency r esponse

fr om input j t o out put i at fr equency frequency(k)

S1-by-...-by-Sn

ar r ay of models

wit h Ny out put s

and Nu input s

Ny-by-Nu-by-S1-by-...-by-Sn mult idimensional ar r ay,

for which response(i,j,k,:) specifies t he ar r ay of

fr equency r esponse dat a fr om input j t o out put i at

fr equency frequency(k)

2 LTI Models

2-20

Discrete-Time Models

Cr eat ing discr et e-t ime models is ver y much like cr eat ing cont inuous-t ime

models, except t hat you must also specify a sampling per iod or sample time for

discr et e-t ime models. The sample t ime value should be scalar and expr essed in

seconds. You can also use t he value –1 t o leave t he sample t ime unspecified.

To specify discr et e-t ime LTI models using tf, zpk, ss, or frd, simply append

t he desir ed sample t ime value Ts t o t he list of input s.

sys1 = tf(num,den,Ts)

sys2 = zpk(z,p,k,Ts)

sys3 = ss(a,b,c,d,Ts)

sys4 = frd(response,frequency,Ts)

For example,

h = tf([1 –1],[1 –0.5],0.1)

cr eat es t he discr et e-t ime t r ansfer funct ion wit h

sample t ime 0.1 seconds, and

sys = ss(A,B,C,D,0.5)

specifies t he discr et e-t ime st at e-space model

wit h sampling per iod 0.5 second. The vect or s denot e t he

values of t he st at e, input , and out put vect or s at t he nt h sample.

By convent ion, t he sample t ime of cont inuous-t ime models is Ts = 0. Set t ing

Ts = –1 leaves t he sample t ime of a discr et e-t ime model unspecified. For

example,

h = tf([1 –0.2],[1 0.3],–1)

h z ( ) z 1 – ( ) z 0.5 – ( ) ⁄ =

x n 1 + [ ] Ax n [ ] Bu n [ ] + =

y n [ ] Cx n [ ] Du n [ ] + =

x n [ ] u n [ ] y n [ ] , ,

Creating LTI Models

2-21

pr oduces

Transfer function:

z – 0.2

-------

z + 0.3

Sampling time: unspecified

Note: Do not simply omit Ts in t his case. This would make h a

cont inuous-t ime t r ansfer funct ion.

If you for get t o specify t he sample t ime when cr eat ing your model, you can st ill

set it t o t he cor r ect value by r eassigning t he LTI pr oper t y Ts. See “Sample

Time” on page 2-34 for mor e infor mat ion on set t ing t his pr oper t y.

Discrete-Time TF and ZPK Models

You can specify discr et e-t ime TF and ZPK models using tf and zpk as indicat ed

above. Alt er nat ively, it is oft en convenient t o specify such models by:

1 Defining t he var iable z as a par t icular discr et e-t ime TF or ZPK model wit h

t he appr opr iat e sample t ime

2 Ent er ing your TF or ZPK model dir ect ly as a r at ional expr ession in z.

This appr oach par allels t he pr ocedur e for specifying cont inuous-t ime TF or

ZPK models using r at ional expr essions. This pr ocedur e is descr ibed in “SISO

Tr ansfer Funct ion Models” on page 2-8 and “SISO Zer o-Pole-Gain Models” on

page 2-12.

For example,

z = tf('z', 0.1);

H = (z+2)/(z^2 + 0.6*z + 0.9);

cr eat es t he same TF model as

H = tf([1 2], [1 0.6 0.9], 0.1);

2 LTI Models

2-22

Similar ly,

z = zpk('z', 0.1);

H = [z/(z+0.1)/(z+0.2) ; (z^2+0.2*z+0.1)/(z^2+0.2*z+0.01)]

pr oduces t he single-input , t wo-out put ZPK model

Zero/pole/gain from input to output...

z

#1: ---------------

(z+0.1) (z+0.2)

(z^2 + 0.2z + 0.1)

#2: ------------------

(z+0.1)^2

Sampling time: 0.1

Not e t hat :

•The synt ax z = tf('z') is equivalent t o z = tf('z',–1) and leaves t he

sample t ime unspecified. The same applies t o z = zpk('z').

•Once you have defined z as indicat ed above, any r at ional expr essions in z

cr eat es a discr et e-t ime model of t he same t ype and wit h t he same sample

t ime as z.

Discrete Transfer Functions in DSP Format

In digit al signal pr ocessing (DSP), it is cust omar y t o wr it e discr et e t r ansfer

funct ions as r at ional expr essions in and t o or der t he numer at or and

denominat or coefficient s in ascending powers of . For example, t he

numer at or and denominat or of

would be specified as t he r ow vect or s [1 0.5] and [1 2 3], r espect ively. When

t he numer at or and denominat or have differ ent degr ees, t his convent ion

clashes wit h t he “descending powers of ” convent ion assumed by tf (see

“Tr ansfer Funct ion Models” on page 2-8, or tf on page 11-224). For example,

h = tf([1 0.5],[1 2 3])

z

1 –

z

1 –

H z

1 –

( )

1 0.5z

1 –

+

1 2z

1 –

3z

2 –

+ +

---------------------------------------- =

z

Creating LTI Models

2-23

pr oduces t he t r ansfer funct ion

which differ s fr om by a fact or .

To avoid such convent ion clashes, t he Cont r ol Syst em Toolbox offer s a separ at e

funct ion filt dedicat ed t o t he DSP-like specificat ion of t r ansfer funct ions. It s

synt ax is

h = filt(num,den)

for discr et e t r ansfer funct ions wit h unspecified sample t ime, and

h = filt(num,den,Ts)

t o fur t her specify t he sample t ime Ts. This funct ion cr eat es TF object s just like

tf, but expect s num and den t o list t he numer at or and denominat or coefficient s

in ascending powers of . For example, t yping

h = filt([1 0.5],[1 2 3])

pr oduces

Transfer function:

1 + 0.5 z^–1

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

1 + 2 z^–1 + 3 z^–2

Sampling time: unspecified

You can also use filt t o specify MIMO t r ansfer funct ions in . J ust as for tf,

t he input ar gument s num and den ar e t hen cell ar r ays of r ow vect or s of

appr opr iat e dimensions (see “Tr ansfer Funct ion Models” on page 2-8 for

det ails). Not e t hat each r ow vect or should comply wit h t he “ascending power s

of ”convent ion.

z 0.5 +

z

2

2z 3 + +

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

H z

1 –

( ) z

z

1 –

z

1 –

z

1 –

2 LTI Models

2-24

Data Retrieval

The funct ions tf, zpk, ss, and frd pack t he model dat a and sample t ime in a

single LTI object . Conver sely, t he following commands pr ovide convenient dat a

r et r ieval for any t ype of TF, SS, or ZPK model sys, or FRD model sysfr.

[num,den,Ts] = tfdata(sys) % Ts = sample time

[z,p,k,Ts] = zpkdata(sys)

[a,b,c,d,Ts] = ssdata(sys)

[a,b,c,d,e,Ts] = dssdata(sys)

[response,frequency,Ts] = frdata(sysfr)

Not e t hat :

•sys can be any t ype of LTI object , except an FRD model

•sysfr, t he input ar gument t o frdata, can only be an FRD model

You can use any var iable names you want in t he out put ar gument list of any of

t hese funct ions. The ones list ed her e cor r espond t o t he model pr oper t y names

descr ibed in Tables 2-2 – 2.5.

The out put ar gument s num and den assigned t o tfdata, and z and p assigned

t o zpkdata, ar e cell ar r ays, even in t he SISO case. These cell ar r ays have as

many r ows as out put s, as many columns as input s, and t heir ijt h ent r y

specifies t he t r ansfer funct ion fr om t he jt h input t o t he it h out put . For example,

H = [tf([1 –1],[1 2 10]) , tf(1,[1 0])]

cr eat es t he one-out put /t wo-input t r ansfer funct ion

Typing

[num,den] = tfdata(H);

num{1,1}, den{1,1}

H s ( )

s 1 –

s

2

2s 10 + +

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

1

s

---

=

Creating LTI Models

2-25

displays t he coefficient s of t he numer at or and denominat or of t he fir st input

channel.

ans =

0 1 –1

ans =

1 2 10

Not e t hat t he same r esult is obt ained using

H.num{1,1}, H.den{1,1}

See “Dir ect Pr oper t y Refer encing” on page 2-33 for mor e infor mat ion about t his

synt ax.

To obt ain t he numer at or and denominat or of SISO syst ems dir ect ly as r ow

vect or s, use t he synt ax

[num,den,Ts] = tfdata(sys,'v')

For example, t yping

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

[num,den] = tfdata(sys,'v')

pr oduces

num =

0 1 3

den =

1 2 5

Similar ly,

[z,p,k,Ts] = zpkdata(sys,'v')

r et ur ns t he zer os, z, and t he poles, p, as vectors for SISO syst ems.

2 LTI Models

2-26

LTI Properties

The pr evious sect ion shows how t o cr eat e LTI object s t hat encapsulat e t he

model dat a and sample t ime. You also have t he opt ion t o at t r ibut e addit ional

infor mat ion, such as t he input names or not es on t he model hist or y, t o LTI

object s. This sect ion gives a complet e over view of t he LTI properties, i.e., t he

var ious pieces of infor mat ion t hat can be at t ached t o t he TF, ZPK, SS, and FRD

object s. Type help ltiprops for online help on available LTI pr oper t ies.

Fr om a dat a st r uct ur e st andpoint , t he LTI pr oper t ies ar e t he var ious fields in

t he TF, ZPK, SS, and FRD object s. These fields have names (t he property

names) and ar e assigned values (t he property values). We dist inguish bet ween

generic properties, common t o all four t ypes of LTI object s, and model-specific

properties t hat per t ain only t o one par t icular t ype of model.

Generic Properties

The gener ic pr oper t ies ar e t hose shar ed by all four t ypes of LTI models (TF,

ZPK, SS, and FRD object s). They ar e list ed in t he t able below.

Table 2-4: Generic LTI Properties

Property Name Description Property Value

IoDelayMatrix I/O delay(s) Mat r ix

InputDelay Input delay(s) Vect or

InputGroup Input channel gr oups Cell ar r ay

InputName Input channel names Cell vect or of st r ings

Notes Not es on t he model hist or y Text

OutputDelay Out put delay(s) Vect or

OutputGroup Out put channel gr oups Cell ar r ay

OutputName Out put channel names Cell vect or of st r ings

Ts Sample t ime Scalar

Userdata Addit ional dat a Ar bit r ar y

LTI Properties

2-27

The sample t ime pr oper t y Ts keeps t r ack of t he sample t ime (in seconds) of

discr et e-t ime syst ems. By convent ion, Ts is 0 (zer o) for cont inuous-t ime

syst ems, and Ts is –1 for discr et e-t ime syst ems wit h unspecified sample t ime.

Ts is always a scalar , even for MIMO syst ems.

The InputDelay, OutputDelay, and ioDelayMatrix pr oper t ies allow you t o

specify t ime delays in t he input or out put channels, or for each input /out put

pair . Their default value is zer o (no delay). See “Time Delays” on page 2-45 for

det ails on modeling delays.

The InputName and OutputName pr oper t ies enable you t o give names t o t he

individual input and out put channels. The value of each of t hese pr oper t ies is

a cell vect or of st r ings wit h as many cells as input s or out put s. For example,

t he OutputName pr oper t y is set t o

{ 'temperature' ; 'pressure' }

for a syst em wit h t wo out put s labeled temperature and pressure. The default

value is a cell of empt y st r ings.

Using t he InputGroup and OutputGroup pr oper t ies of LTI object s, you can

cr eat e differ ent gr oups of input or out put channels, and assign names t o t he

gr oups. For example, you may want t o designat e t he fir st four input s of a

five-input model as controls, and t he last input as noise. See “Input Gr oups

and Out put Gr oups” on page 2-37 for mor e infor mat ion.

Finally, Notes and Userdata ar e available t o st or e addit ional infor mat ion on

t he model. The Notes pr oper t y is dedicat ed t o any t ext you want t o supply wit h

your model, while t he Userdata pr oper t y can accommodat e ar bit r ar y

user -supplied dat a. They ar e bot h empt y by default .

For mor e det ailed infor mat ion on how t o use LTI pr oper t ies, see “Addit ional

Insight int o LTI Pr oper t ies” on page 2-34.

2 LTI Models

2-28

Model-Specific Properties

The r emaining LTI pr oper t ies ar e specific t o one of t he four model t ypes (TF,

ZPK, SS, or FRD). For single LTI models, t hese ar e summar ized in t he

following four t ables. The pr oper t y values differ for LTI ar r ays. See set on page

11-193 for mor e infor mat ion on t hese values.

Table 2-5: TF-Specific Properties

Property Name Description Property Value

den Denominat or (s) Real cell ar r ay of r ow vect or s

num Numer at or (s) Real cell ar r ay of r ow vect or s

Variable Tr ansfer funct ion

var iable

St r ing 's', 'p', 'z', 'q', or

'z^–1'

Table 2-6: ZPK-Specific Properties

Property Name Description Property Value

k Gains Two-dimensional r eal mat r ix

p Poles Cell ar r ay of column vect or s

Variable Tr ansfer funct ion

var iable

St r ing 's', 'p', 'z', 'q', or

'z^–1'

z Zer os Cell ar r ay of column vect or s

Table 2-7: SS-Specific Properties

Property Name Description Property Value

a St at e mat r ix 2-D r eal mat r ix

b Input -t o-st at e mat r ix 2-D r eal mat r ix

c St at e-t o-out put mat r ix 2-D r eal mat r ix

d Feedt hr ough mat r ix 2-D r eal mat r ix

A

B

C

D

LTI Properties

2-29

Most of t hese pr oper t ies ar e dedicat ed t o st or ing t he model dat a. Not e t hat t he

mat r ix is set t o [] (t he empt y mat r ix) for st andar d st at e-space models, a

st or age-efficient shor t hand for t he t r ue value .

The Variable pr oper t y is only an at t r ibut e of TF and ZPK object s. This

pr oper t y defines t he fr equency var iable of t r ansfer funct ions. The default

values ar e 's' (Laplace var iable ) in cont inuous t ime and 'z' (Z-t r ansfor m

var iable ) in discr et e t ime. Alt er nat ive choices include 'p' (equivalent t o )

and 'q' or 'z^–1' for t he r ecipr ocal of t he var iable. The influence of

t he var iable choice is most ly limit ed t o t he display of TF or ZPK models. One

except ion is t he specificat ion of discr et e-t ime t r ansfer funct ions wit h tf (see tf

on page 11-224 for det ails).

Not e t hat tf pr oduces t he same r esult as filt when t he Variable pr oper t y is

set t o 'z^–1' or 'q'.

Finally, t he StateName pr oper t y is analogous t o t he InputName and OutputName

pr oper t ies and keeps t r ack of t he st at e names in st at e-space models.

e Descr ipt or mat r ix 2-D r eal mat r ix

StateName St at e names Cell vect or of st r ings

Table 2-8: FRD-Specific Properties

Property Name Description Property Value

Frequency Fr equency dat a point s Real-valued vect or

ResponseData Fr equency r esponse Complex-valued

mult idimensional ar r ay

Units Unit s for fr equency St r ing 'rad/s' or 'Hz'

Table 2-7: SS-Specific Properties (Continued)

Property Name Description Property Value

E

E

E I =

s

z s

q z

1 –

= z

2 LTI Models

2-30

Setting LTI Properties

Ther e ar e t hr ee ways t o specify LTI pr oper t y values:

•You can set pr oper t ies when cr eat ing LTI models wit h tf, zpk, ss, or frd.

•You can set or modify t he pr oper t ies of an exist ing LTI model wit h set.

•You can also set pr oper t y values using st r uct ur e-like assignment s.

This sect ion discusses t he fir st t wo opt ions. See “Dir ect Pr oper t y Refer encing”

on page 2-33 for det ails on t he t hir d opt ion.

The funct ion set for LTI object s follows t he same synt ax as it s Handle

Gr aphics count er par t . Specifically, each pr oper t y is updat ed by a pair of

ar gument s

PropertyName,PropertyValue

wher e

•PropertyName is a st r ing specifying t he pr oper t y name. You can t ype t he

pr oper t y name wit hout r egar d for t he case (upper or lower ) of t he let t er s in

t he name. Act ually, you need only t ype any abbr eviat ion of t he pr oper t y

name t hat uniquely ident ifies t he pr oper t y. For example, 'user' is sufficient

t o r efer t o t he Userdata pr oper t y.

•PropertyValue is t he value t o assign t o t he pr oper t y (see set on page 11-193

for det ails on admissible pr oper t y values).

As an illust r at ion, consider t he following simple SISO model for a heat ing

syst em wit h an input delay of 0.3 seconds, an input called “ener gy,” and an

out put called “t emper at ur e.”

Figure 2-1: A Simple Heater Model

You can use a TF object t o r epr esent t his delay syst em, and specify t he t ime

delay, t he input and out put names, and t he model hist or y by set t ing t he

cor r esponding LTI pr oper t ies. You can eit her set t hese pr oper t ies dir ect ly

when you cr eat e t he LTI model wit h tf, or by using t he set command.

1

s 1 +

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

e

0.3s –

delay

energy

temperature

LTI Properties

2-31

For example, you can specify t he delay dir ect ly when you cr eat e t he model, and

t hen use t he set command t o assign InputName, OutputName, and Notes t o

sys.

sys = tf(1,[1 1],'Inputdelay',0.3);

set(sys,'inputname','energy','outputname','temperature',...

'notes','A simple heater model')

Finally, you can also use t he set command t o obt ain a list ing of all set t able

pr oper t ies for a given LTI model t ype, along wit h valid values for t hese

pr oper t ies. For t he t r ansfer funct ion sys cr eat ed above

set(sys)

pr oduces

num: Ny-by-Nu cell of row vectors (Nu = no. of inputs)

den: Ny-by-Nu cell of row vectors (Ny = no. of outputs)

Variable: [ 's' | 'p' | 'z' | 'z^-1' | 'q' ]

Ts: scalar

InputDelay: Nu-by-1 vector

OutputDelay: Ny-by-1 vector

ioDelayMatrix: Ny-by-Nu array (I/O delays)

InputName: Nu-by-1 cell array of strings

OutputName: Ny-by-1 cell array of strings

InputGroup: M-by-2 cell array if M input groups

OutputGroup: P-by-2 cell array if P output groups

Notes: array or cell array of strings

UserData: arbitrary

Accessing Property Values Using get

You access t he pr oper t y values of an LTI model sys wit h get. The synt ax is

PropertyValue = get(sys,PropertyName)

2 LTI Models

2-32

wher e t he st r ing PropertyName is eit her t he full pr oper t y name, or any

abbr eviat ion wit h enough char act er s t o ident ify t he pr oper t y uniquely. For

example, t yping

h = tf(100,[1 5 100],'inputname','voltage',...

'outputn','current',...

'notes','A simple circuit')

get(h,'notes')

pr oduces

ans =

'A simple circuit'

To display all of t he pr oper t ies of an LTI model sys (and t heir values), use t he

synt ax get(sys). In t his example,

get(h)

pr oduces

num: {[0 0 100]}

den: {[1 5 100]}

Variable: 's'

Ts: 0

InputDelay: 0

OutputDelay: 0

ioDelayMatrix: 0

InputName: {'voltage'}

OutputName: {'current'}

InputGroup: {0x2 cell}

OutputGroup: {0x2 cell}

Notes: {'A simple circuit'}

UserData: []

Not ice t hat default (out put ) values have been assigned t o any LTI pr oper t ies in

t his list t hat you have not specified.

Finally, you can also access pr oper t y values using dir ect st r uct ur e-like

r efer encing. This t opic is explained in t he next sect ion.

LTI Properties

2-33

Direct Property Referencing

An alt er nat ive way t o quer y/modify pr oper t y values is by st r uct ur e-like

r efer encing. Recall t hat LTI object s ar e basic MATLAB st r uct ur es except for

t he addit ional flag t hat mar ks t hem as TF, ZPK, SS, or FRD object s (see page

2-3). The field names for LTI object s ar e t he pr oper t y names, so you can

r et r ieve or modify pr oper t y values wit h t he st r uct ur e-like synt ax.

PropertyValue = sys.PropertyName% gets property value

sys.PropertyName = PropertyValue% sets property value

These commands ar e r espect ively equivalent t o

PropertyValue = get(sys,'PropertyName')

set(sys,'PropertyName',PropertyValue)

For example, t ype

sys = ss(1,2,3,4,'InputName','u');

sys.a

and you get t he value of t he pr oper t y “a” for t he st at e-space model sys.

ans =

1

Similar ly,

sys.a = –1;

r eset s t he st at e t r ansit ion mat r ix for sys t o –1. See “LTI Ar r ays of SS Models

wit h Differ ing Number s of St at es” on page 4-23 for infor mat ion on set t ing t he

pr oper t ies of LTI ar r ays of st at e-space models wit h differ ent number s of st at es

in each model.

Unlike st andar d MATLAB st r uct ur es, you do not need t o t ype t he ent ir e field

name or use upper -case char act er s. You only need t o t ype t he minimum

number of char act er s sufficient t o ident ify t he pr oper t y name uniquely. Thus

eit her of t he commands

sys.InputName

sys.inputn

2 LTI Models

2-34

pr oduces

ans =

'u'

Any valid synt ax for st r uct ur es ext ends t o LTI object s. For example, given t he

TF model

h = tf(1,[1,0],'variable','p');

you can r eset t he numer at or t o by t yping

h.num{1} = [1 2];

or equivalent ly, wit h

h.num{1}(2) = 2;

Additional Insight into LTI Properties

By r eading t his sect ion, you can lear n mor e about using t he Ts, InputName,

OutputName, InputGroup, and OutputGroup LTI pr oper t ies t hr ough a set of

examples. For basic infor mat ion on Notes and Userdata, see “Gener ic

Pr oper t ies” on page 2-26. For det ailed infor mat ion on t he use of InputDelay,

OutputDelay, and ioDelayMatrix, see “Time Delays” on page 2-45.

Sample Time

The sample t ime pr oper t y Ts is used t o specify t he sampling per iod (in seconds)

for eit her discr et e-t ime or discr et ized cont inuous-t ime LTI models. Suppose

you want t o specify

as a discr et e-t ime t r ansfer funct ion model wit h a sampling per iod of 0.5

seconds. To do t his, t ype

h = tf([1 0],[2 1 1],0.5);

h p ( ) 1 p ⁄ =

p 2 +

H z ( )

z

2z

2

z 1 + +

---------------------------- =

LTI Properties

2-35

This set s t he Ts pr oper t y t o t he value 0.5, as is confir med by

h.Ts

ans =

0.5000

For cont inuous-t ime models, t he sample t ime pr oper t y Ts is 0 by convent ion.

For example, t ype

h = tf(1,[1 0]);

get(h,'Ts')

ans =

0

To leave t he sample t ime of a discr et e-t ime LTI model unspecified, set Ts t o .

For example,

h = tf(1,[1 –1],–1)

pr oduces

Transfer function:

1

-----

z – 1

Sampling time: unspecified

The same r esult is obt ained by using t he Variable pr oper t y.

h = tf(1,[1 –1],'var','z')

In oper at ions t hat combine sever al discr et e-t ime models, all specified sample

t imes must be ident ical, and t he r esult ing discr et e-t ime model inher it s t his

common sample t ime. The sample t ime of t he r esult ant model is unspecified if

all oper ands have unspecified sample t imes. Wit h t his inher it ance r ule for Ts,

t he following t wo models ar e equivalent .

tf(0.1,[1 –1],0.1) + tf(1,[1 0.5],–1)

and

tf(0.1,[1 –1],0.1) + tf(1,[1 0.5],0.1)

1 –

2 LTI Models

2-36

Not e t hat

tf(0.1,[1 –1],0.1) + tf(1,[1 0.5],0.5)

r et ur ns an er r or message.

??? Error using ==> lti/plus

In SYS1+SYS2, both models must have the same sample time.

Caution: Reset t ing t he sample t ime of a cont inuous-t ime LTI model sys fr om

zer o t o a nonzer o value does not discr et ize t he or iginal model sys. The

command

set(sys,'Ts',0.1)

only affect s t he Ts pr oper t y and does not alt er t he r emaining model dat a. Use

c2d and d2c t o per for m cont inuous-t o-discr et e and discr et e-t o-cont inuous

conver sions. For example, use

sysd = c2d(sys,0.1)

t o discr et ize a cont inuous syst em sys at a 10Hz sampling r at e.

Use d2d t o change t he sample t ime of a discr et e-t ime syst em and r esample it .

Input Names and Output Names

You can use t he InputName and OutputName pr oper t ies (in shor t , I/O names) t o

assign names t o any or all of t he input and out put channels in your LTI model.

For example, you can cr eat e a SISO model wit h input thrust, out put

velocity, and t r ansfer funct ion by t yping

h = tf(1,[1 10]);

set(h,'inputname','thrust','outputname','velocity',...

'variable','p')

Equivalent ly, you can set t hese pr oper t ies dir ect ly by t yping

h = tf(1,[1 10],'inputname','thrust',...

'outputname','velocity',...

'variable','p')

H p ( ) 1 p 10 + ( ) ⁄ =

LTI Properties

2-37

This pr oduces

Transfer function from input "thrust" to output "velocity":

1

------

p + 10

Not e how t he display r eflect s t he input and out put names and t he var iable

select ion.

In t he MIMO case, use cell vect or s of st r ings t o specify input or out put channel

names. For example, t ype

num = {3 , [1 2]};

den = {[1 10] , [1 0]};

H = tf(num,den); % H(s) has one output and two inputs

set(H,'inputname',{'temperature' ; 'pressure'})

The specified input names appear in t he display of H.

Transfer function from input "temperature" to output:

3

------

s + 10

Transfer function from input "pressure" to output:

s + 2

-----

s

To leave cer t ain names undefined, use t he empt y st r ing '' as in

H = tf(num,den,'inputname',{ 'temperature' ; '' })

Input Groups and Output Groups

In many applicat ions, you may want t o cr eat e sever al (dist inct or int er sect ing)

gr oups of input or out put channels and name t hese gr oups. For example, you

may want t o label one set of input channels as noise and anot her set as

controls.

2 LTI Models

2-38

To see how input and out put gr oups (I/O gr oups) wor k:

1 Cr eat e a r andom st at e-space model wit h one st at e, t hr ee input s, and t hr ee

out put s.

2 Assign t he fir st t wo input s t o a gr oup named controls, t he fir st out put t o a

gr oup named temperature, and t he last t wo out put s t o a gr oup named

measurements.

LTI Properties

2-39

To do t his, t ype

h = rss(1,3,3);

set(h, 'InputGroup',{[1 2] 'controls'})

set(h, 'OutputGroup', {[1] 'temperature'; [2 3] 'measurements'})

h

and MATLAB r et ur ns a st at e-space model of t he following for m.

a =

x1

x1 –0.64884

b =

u1 u2 u3

x1 0.12533 0 0

c =

x1

y1 1.1909

y2 1.1892

y3 0

d =

u1 u2 u3

y1 0.32729 0 –0.1364

y2 0 0 0

y3 0 2.1832 0

I/O Groups:

Group Name I/O Channel(s)

controls I 1,2

temperature O 1

measurements O 2,3

Continuous-time model.

2 LTI Models

2-40

Not ice t hat t he middle column of t he I/O gr oup list ing indicat es whet her t he

gr oup is an input gr oup (I) or an out put gr oup (O).

In gener al, t o specify M input gr oups (or out put gr oups), you need an M-by-2

cell ar r ay or ganized as follows.

Figure 2-2: Two Column Cell Array

When you specify t he cell ar r ay for input (or out put ) gr oups, keep in mind:

•Each r ow of t his cell ar r ay designat es a differ ent input (out put ) gr oup.

•You can add input (or out put ) gr oups by appending r ows t o t he cell ar r ay.

•You can choose not t o assign any of t he gr oup names when you assign t he

gr oups, and leave off t he second column of t his ar r ay. In t hat case,

- Empt y st r ings ar e assigned t o t he gr oup names by default .

- If you append r ows t o a cell ar r ay wit h no gr oup names assigned, you have

t o assign empt y st r ings ('') t o t he gr oup names.

For example,

h.InputGroup = [h.InputGroup; {[3] 'disturbance'}];

adds anot her input gr oup called disturbance t o h.

Vect or s of Channel Indices Gr oup Names

{ Channels for Gr oup 1 , Name for Gr oup 1;

Channels for Gr oup 2 , Name for Gr oup 2;

Channels for Gr oup M , Name for Gr oup M }

LTI Properties

2-41

You can use r egular cell ar r ay synt ax for accessing or modifying I/O gr oup

component s. For example, t o delet e t he fir st out put gr oup, temperature, t ype

h.OutputGroup(1,:) = []

ans =

[1x2 double] 'measurements'

Similar ly, you can add or delet e channels fr om an exist ing input or out put

gr oup. Recalling t hat input gr oup channels ar e st or ed in t he fir st column of t he

cor r esponding cell ar r ay, t o add channel t hr ee t o t he input gr oup controls,

t ype

h.inputgroup{1,1} = [h.inputgroup{1,1} 3]

or , equivalent ly,

h.inputgroup{1,1} = [1 2 3]

2 LTI Models

2-42

Model Conversion

Ther e ar e four LTI model t ypes you can use wit h t he Cont r ol Syst em Toolbox:

TF, ZPK, SS, and FRD. This sect ion shows how t o conver t models fr om one t ype

t o t he ot her .

Explicit Conversion

Model conver sions ar e per for med by tf, ss, zpk, and frd. Given any TF, SS, or

ZPK model sys, t he synt ax for conver sion t o anot her model t ype is

Not ice t hat FRD models can’t be conver t ed t o t he ot her model t ypes. In

addit ion, you must also include a vect or of fr equencies (frequency) as an input

ar gument when conver t ing t o an FRD model.

For example, you can conver t t he st at e-space model

sys = ss(–2,1,1,3)

t o a zer o-pole-gain model by t yping

zpk(sys)

t o which MATLAB r esponds

Zero/pole/gain:

3 (s+2.333)

-----------

(s+2)

Not e t hat t he t r ansfer funct ion of a st at e-space model wit h dat a is

sys = tf(sys) % Conversion to TF

sys = zpk(sys) % Conversion to ZPK

sys = ss(sys) % Conversion to SS

sys = frd(sys,frequency) % Conversion to FRD

A B C D , , , ( )

H s ( ) D C s I A – ( )

1 –

B + =

Model Conversion

2-43

for cont inuous-t ime models, and

for discr et e-t ime models.

Automatic Conversion

Some algor it hms oper at e only on one t ype of LTI model. For example, t he

algor it hm for zer o-or der -hold discr et izat ion wit h c2d can only be per for med on

st at e-space models. Similar ly, commands like tfdata expect one par t icular

t ype of LTI models (TF). For convenience, such commands aut omat ically

conver t LTI models t o t he appr opr iat e or r equir ed model t ype. For example, in

sys = ss(0,1,1,0)

[num,den] = tfdata(sys)

tfdata fir st conver t s t he st at e-space model sys t o an equivalent t r ansfer

funct ion in or der t o r et ur n numer at or and denominat or dat a.

Not e t hat conver sions t o st at e-space models ar e not uniquely defined. For t his

r eason, aut omat ic conver sions t o st at e space ar e disabled when t he r esult

depends on t he choice of st at e coor dinat es, for example, in commands like

initial or kalman.

Caution About Model Conversions

When manipulat ing or conver t ing LTI models, keep in mind t hat :

•The t hr ee LTI model t ypes TF, ZPK, and SS, ar e not equally well-suit ed for

numer ical comput at ions. In par t icular , t he accur acy of comput at ions using

high-or der t r ansfer funct ions is oft en poor . Ther efor e, it is oft en pr efer able t o

wor k wit h t he st at e-space r epr esent at ion. In addit ion, it is oft en beneficial t o

balance and scale st at e-space models using ssbal. You get t his t ype of

H z ( ) D C z I A – ( )

1 –

B + =

2 LTI Models

2-44

balancing aut omat ically when you conver t any TF or ZPK model t o st at e

space using ss.

•Conver sions t o t he t r ansfer funct ion r epr esent at ion using tf may incur a

loss of accur acy. As a r esult , t he t r ansfer funct ion poles may not iceably differ

fr om t he poles of t he or iginal zer o-pole-gain or st at e-space model.

•Conver sions t o st at e space ar e not uniquely defined in t he SISO case, nor ar e

t hey guar ant eed t o pr oduce a minimal r ealizat ion in t he MIMO case. For a

given st at e-space model sys,

ss(tf(sys))

may r et ur n a model wit h differ ent st at e-space mat r ices, or even a differ ent

number of st at es in t he MIMO case. Ther efor e, if possible, it is best t o avoid

conver t ing back and for t h bet ween st at e-space and ot her model t ypes.

Time Delays

2-45

Time Delays

Using t he ioDelayMatrix, InputDelay, and OutputDelay pr oper t ies of LTI

object s, you can specify delays in bot h cont inuous- and discr et e-t ime LTI

models. Wit h t hese pr oper t ies, you can, for example, r epr esent :

•LTI models wit h independent delays for each input /out put pair . For

example, t he cont inuous-t ime model wit h t r ansfer funct ion

•St at e-space models wit h delayed input s and/or delayed out put s. For

example,

wher e is t he t ime delay bet ween t he input and t he st at e vect or ,

and is t he t ime delay bet ween and t he out put .

You can assign t he delay pr oper t ies ioDelayMatrix, InputDelay, and

OutputDelay eit her when fir st cr eat ing your model wit h t he tf, zpk, ss, or frd

const r uct or s, or lat er wit h t he set command (see “LTI Pr oper t ies and Met hods”

on page 2-4 for det ails).

Supported Functionality

Most analysis commands suppor t t ime delays, including:

•All t ime and fr equency r esponse commands

•Conver sions bet ween model t ypes

•Cont inuous-t o-discr et e conver sions (c2d)

•Hor izont al and ver t ical concat enat ion

•Ser ies, par allel, and feedback int er connect ions of discr et e-t ime models wit h

delays

H s ( )

e

0.1s – 2

s

--- e

0.3s – s 1 +

s 10 +

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

10 e

0.2s – s 1 –

s 5 +

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

=

x

·

t ( ) Ax t ( ) Bu t τ – ( ) + =

y t ( ) Cx t θ – ( ) Du t θ τ + ( ) – ( ) + =

τ u t ( ) x t ( )

θ x t ( ) y t ( )

2 LTI Models

2-46

•Int er connect ions of cont inuous-t ime delay syst ems as long as t he r esult ing

t r ansfer funct ion fr om input t o out put is of t he for m

wher e is a r at ional funct ion of

•Padé appr oximat ion of t ime delays (pade)

Specifying Input/Output Delays

Using t he ioDelayMatrix pr oper t y, you can specify fr equency-domain models

wit h independent delays in each ent r y of t he t r ansfer funct ion. In cont inuous

t ime, such models have a t r ansfer funct ion of t he for m

wher e t he ’s ar e r at ional funct ions of , and is t he t ime delay bet ween

input and out put . See “Specifying Delays in Discr et e-Time Models” on page

2-52 for det ails on t he discr et e-t ime count er par t . We collect ively r efer t o t he

scalar s as t he I/ O delays.

The synt ax t o cr eat e above is

H = tf(num,den,'iodelaymatrix',Tau)

or

H = zpk(z,p,k,'iodelaymatrix',Tau)

wher e

•num, den (r espect ively, z, p, k) specify t he r at ional par t of t he t r ansfer

funct ion

•Tau is t he mat r ix of t ime delays for each I/O pair . That is, Tau(i,j) specifies

t he I/O delay in seconds. Not e t hat Tau and should have t he same

r ow and column dimensions.

You can also use t he ioDelayMatrix pr oper t y in conjunct ion wit h st at e-space

models, as in

sys = ss(A,B,C,D,'iodelaymatrix',Tau)

j i s τ

i j

– ( ) h

i j

s ( ) exp

h

i j

s ( ) s

H s ( )

e

s τ

11

–

h

11

s ( ) ... e

s τ

1 m

–

h

1m

s ( )

: :

e

s τ

p 1

–

h

p 1

s ( ) ... e

s τ

p m

–

h

p m

s ( )

s τ

i j

– ( ) h

i j

s ( ) exp [ ] = =

h

i j

s τ

i j

j i

τ

i j

H s ( )

h

i j

s ( ) [ ]

H s ( )

τ

i j

H s ( )

Time Delays

2-47

This cr eat es t he LTI model wit h t he following t r ansfer funct ion.

Her e is t he ent r y of

Note: St at e-space models wit h I/O delays have only a fr equency-domain

int er pr et at ion. They cannot , in gener al, be descr ibed by st at e-space equat ions

wit h delayed input s and out put s.

Distillation Column Example

This example is adapt ed fr om [2] and illust r at es t he use of I/O delays in pr ocess

modeling. The pr ocess of int er est is t he dist illat ion column depict ed by t he

figur e below. This column is used t o separ at e a mix of met hanol and wat er (t he

feed) int o bottom products (most ly wat er ) and a met hanol-sat ur at ed distillate.

H s ( ) s τ

i j

– ( ) r

i j

s ( ) exp =

r

i j

s ( ) i j , ( )

R s ( ) D C s I A – ( )

1 –

B + =

2 LTI Models

2-48

Figure 2-3: Distillation Column

Schemat ically, t he dist illat ion pr ocess funct ions as follows:

•St eam flows int o t he r eboiler and vapor izes t he bot t om liquid. This vapor is

r einject ed int o t he column and mixes wit h t he feed

•Met hanol, being mor e volat ile t han wat er , t ends t o concent r at e in t he vapor

moving upwar d. Meanwhile, wat er t ends t o flow downwar d and accumulat e

as t he bot t om liquid

•The vapor exit ing at t he t op of t he column is condensed by a flow of cooling

wat er . Par t of t his condensed vapor is ext r act ed as t he dist illat e, and t he r est

of t he condensat e (t he reflux) is sent back t o t he column.

•Par t of t he bot t om liquid is collect ed fr om t he r eboiler as bot t om pr oduct s

(wast e).

Feed

Enr iched vapor

Cooling wat er

Condensat e

Reflux

Di st illate

Vapor

St eam flow

Reboiler

Bot t om liquid

Bottom products

Time Delays

2-49

The r egulat ed out put var iables ar e:

•Per cent age of met hanol in t he dist illat e

•Per cent age of met hanol in t he bot t om pr oduct s.

The goal is t o maximize by adjust ing t he r eflux flow r at e and t he st eam

flow r at e in t he r eboiler .

To obt ain a linear ized model ar ound t he st eady-st at e oper at ing condit ions, t he

t r ansient r esponses t o pulses in st eam and r eflux flow ar e fit t ed by fir st -or der

plus delay models. The r esult ing t r ansfer funct ion model is

Not e t he differ ent t ime delays for each input /out put pair .

You can specify t his MIMO t r ansfer funct ion by t yping

H = tf({12.8 –18.9;6.6 –19.4},...

{[16.7 1] [21 1];[10.9 1] [14.4 1]},...

'iodelay',[1 3;7 3],...

'inputname',{'R' , 'S'},...

'outputname',{'Xd' , 'Xb'})

X

D

X

B

X

D

R

S

X

D

s ( )

X

B

s ( )

12.8e

1s –

16.7e 1 +

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

18.9e

3s –

–

21.0s 1 +

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

6.6e

7s –

10.9s 1 +

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

19.4e

3s –

–

14.4s 1 +

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

R s ( )

S s ( )

=

2 LTI Models

2-50

The r esult ing TF model is displayed as

Transfer function from input "R" to output...

12.8

Xd: exp(–1*s) * ----------

16.7 s + 1

6.6

Xb: exp(–7*s) * ----------

10.9 s + 1

Transfer function from input "S" to output...

–18.9

Xd: exp(–3*s) * --------

21 s + 1

–19.4

Xb: exp(–3*s) * ----------

14.4 s + 1

Specifying Delays on the Inputs or Outputs

While ideal for fr equency-domain models wit h I/O delays, t he ioDelayMatrix

pr oper t y is inadequat e t o capt ur e delayed input s or out put s in st at e-space

models. For example, t he t wo models

shar e t he same t r ansfer funct ion

As a r esult , t hey cannot be dist inguished using t he ioDelayMatrix pr oper t y

(t he I/O delay value is 0.1 seconds in bot h cases). Yet , t hese t wo models have

differ ent st at e t r aject or ies since and ar e r elat ed by

M

1

( )

x

·

t ( ) x – t ( ) u t 0.1 – ( ) + =

y t ( ) x t ( ) = ¸

¸

M

2

( )

z

·

t ( ) z – t ( ) u t ( ) + =

y t ( ) z t 0.1 – ( ) = ¸

¸

h s ( )

e

0.1s –

s 1 +

---------------- =

x t ( ) z t ( )

z t ( ) x t 0.1 – ( ) =

Time Delays

2-51

Not e t hat t he 0.1 second delay is on t he input in t he fir st model, and on t he

output in t he second model.

InputDelay and OutputDelay Properties

When t he st at e t r aject or y is of int er est , you should use t he InputDelay and

OutputDelay pr oper t ies t o dist inguish bet ween delays on t he input s and

delays on t he out put s in st at e-space models. For example, you can accur at ely

specify t he t wo models above by

M1 = ss(–1,1,1,0,'inputdelay',0.1)

M2 = ss(–1,1,1,0,'outputdelay',0.1)

In t he MIMO case, you can specify a differ ent delay for each input (or out put )

channel by assigning a vect or value t o InputDelay (or OutputDelay). For

example,

sys = ss(A,[B1 B2],[C1;C2],[D11 D12;D21 D22])

sys.inputdelay = [0.1 0]

sys.outputdelay = [0.2 0.3]

cr eat es t he t wo-input , t wo-out put model

You can also use t he InputDelay and OutputDelay pr oper t ies t o convenient ly

specify input or out put delays in TF, ZPK, or FRD models. For example, you

can cr eat e t he t r ansfer funct ion

by t yping

s = tf('s');

H = [1/s ; 2/(s+1)]; % rational part

H.inputdelay = 0.1

x

·

t ( ) Ax t ( ) B

1

u

1

t 0.1 – ( ) + B

2

u

2

t ( ) + =

y

1

t 0.2 + ( ) C

1

x t ( ) D

11

u

1

t 0.1 – ( ) D

12

u

2

t ( ) + + =

y

2

t 0.3 + ( ) C

2

x t ( ) D

21

u

1

t 0.1 – ( ) D

22

u

2

t ( ) + + =

H s ( )

1

s

---

2

s 1 +

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

= e

0.1s –

2 LTI Models

2-52

The r esult ing model is displayed as

Transfer function from input to output...

1

#1: exp(–0.1*s) * -

s

2

#2: exp(–0.1*s) * -----

s + 1

By compar ison, t o pr oduce an equivalent t r ansfer funct ion using t he

ioDelayMatrix pr oper t y, you would need t o t ype

H = [1/s ; 2/(s+1)];

H.iodelay = [0.1 ; 0.1];

Not ice t hat t he 0.1 second delay is r epeat ed t wice in t he I/O delay mat r ix. Mor e

gener ally, for a TF, ZPK, or FRD model wit h input delays and

out put delays , t he equivalent I/O delay mat r ix is

Specifying Delays in Discrete-Time Models

You can also use t he ioDelayMatrix, InputDelay, and OutputDelay pr oper t ies

t o specify delays in discr et e-t ime LTI models. You specify t ime delays in

discr et e-t ime models wit h int eger mult iples of t he sampling per iod. The int eger

k you supply for t he t ime delay of a discr et e-t ime model specifies a t ime delay

of k sampling per iods. Such a delay cont r ibut es a fact or t o t he t r ansfer

funct ion.

For example,

h = tf(1,[1 0.5 0.2],0.1,'inputdelay',3)

α

1

... α

m

, , [ ]

β

1

... β

p

, , [ ]

α

1

β

1

+ α

2

β

1

+ ... α

m

β

1

+

α

1

β

2

+ α

2

β

2

+ α

m

β

2

+

: : :

α

1

β

p

+ α

2

β

p

+ ... α

m

β

p

+

z

k –

Time Delays

2-53

pr oduces t he discr et e-t ime t r ansfer funct ion

Transfer function:

1

z^(–3) * -----------------

z^2 + 0.5 z + 0.2

Sampling time: 0.1

Not ice t he z^(–3) fact or r eflect ing t he t hr ee-sampling-per iod delay on t he

input .

Mapping Discrete-Time Delays to Poles at the Origin

Since discr et e-t ime delays ar e equivalent t o addit ional poles at , t hey can

be easily absor bed int o t he t r ansfer funct ion denominat or or t he st at e-space

equat ions. For example, t he t r ansfer funct ion of t he delayed int egr at or

is

You can specify t his model eit her as t he fir st -or der t r ansfer funct ion

wit h a delay of t wo sampling per iods on t he input

Ts = 1; % sampling period

H1 = tf(1,[1 –1],Ts,'inputdelay',2)

or dir ect ly as a t hir d-or der t r ansfer funct ion:

H2 = tf(1,[1 –1 0 0],Ts) % 1/(z^3–z^2)

While t hese t wo models ar e mat hemat ically equivalent , H1 is a mor e efficient

r epr esent at ion bot h in t er ms of st or age and subsequent comput at ions.

When necessar y, you can map all discr et e-t ime delays t o poles at t he or igin

using t he command delay2z. For example,

H2 = delay2z(H1)

z 0 =

y k 1 + [ ] y k [ ] u k 2 – [ ] + =

H z ( )

z

2 –

z 1 –

------------ =

1 z 1 – ( ) ⁄

2 LTI Models

2-54

absor bs t he input delay in H1 int o t he t r ansfer funct ion denominat or t o pr oduce

t he t hir d-or der t r ansfer funct ion

Transfer function:

1

---------

z^3 – z^2

Sampling time: 1

Not e t hat

H2.inputdelay

now r et ur ns 0 (zer o).

Retrieving Information About Delays

Ther e ar e sever al ways t o r et r ieve t ime delay infor mat ion fr om a given LTI

model sys:

•Use pr oper t y display commands t o inspect t he values of t he ioDelayMatrix,

InputDelay, and OutputDelay pr oper t ies. For example,

sys.iodelay

get(sys,'inputdelay')

•Use t he helper funct ion hasdelay t o det er mine if sys has any delay at all.

The synt ax is

hasdelay(sys)

which r et ur ns 1 (t r ue) if sys has any delay, and 0 (false) ot her wise

•Use t he funct ion totaldelay t o det er mine t he t ot al delay bet ween each input

and each out put (cumulat ive cont r ibut ion of t he ioDelayMatrix,

InputDelay, and OutputDelay pr oper t ies). Type help totaldelay or see t he

Refer ence pages for det ails.

Conversion of Models with Delays to State Space

When you use ss t o conver t TF or ZPK models t o st at e-space for m, t he delays

in t he r esult ing st at e-space model ar e r edist r ibut ed when it is possible t o

r educe t he over all number of I/O delays, input channel delays, and out put

Time Delays

2-55

channel delays. The r esult ing model has a minimum number of delays. When

t his minimizat ion t akes place:

•All or par t of t he I/O delay mat r ix is absor bed int o t he input and out put delay

vect or s. This minimizes t he t ot al number of I/O delays.

•The input delays ar e t r ansfer r ed t o out put delays (or vice-ver sa), so as t o

minimize t he over all number of input and out put channel delays.

Padé Approximation of Time Delays

The funct ion pade comput es r at ional appr oximat ions of t ime delays in

cont inuous-t ime LTI models. The synt ax is

sysx = pade(sys,n)

wher e sys is a cont inuous-t ime model wit h delays, and t he int eger n specifies

t he Padé appr oximat ion or der . The r esult ing LTI model sysx is of t he same

t ype as sys, but is delay fr ee.

For models wit h mult iple delays or a mix of input , out put , and I/O delays, you

can use t he synt ax

sysx = pade(sys,ni,no,nio)

wher e t he vect or s ni and no, and t he mat r ix nio specify independent

appr oximat ion or der s for each input , out put , and I/O delay, r espect ively. Set

ni=[] if t her e ar e no input delays, and similar ly for no and nio.

For example, consider t he “Dist illat ion Column Example” on page 2-47. The

t wo-input , t wo-out put t r ansfer funct ion in t his example is

To comput e a Padé appr oximat ion of H(s) using:

•A fir st -or der appr oximat ion for t he 1 second and 3 second delays

•A second-or der appr oximat ion for t he 7 second delay,

H s ( )

12.8e

1s –

16.7e 1 +

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

18.9e

3 s –

–

21.0s 1 +

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

6.6e

7s –

10.9s 1 +

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

19.4e

3 s –

–

14.4s 1 +

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

=

2 LTI Models

2-56

t ype

pade(H,[],[],[1 1;2 1])

wher e H is t he TF r epr esent at ion of defined in t he “Dist illat ion Column

Example” on page 2-47. This command pr oduces a r at ional t r ansfer funct ion.

Transfer function from input "R" to output...

–12.8 s + 25.6

Xd: ---------------------

16.7 s^2 + 34.4 s + 2

6.6 s^2 – 5.657 s + 1.616

Xb: ---------------------------------------

10.9 s^3 + 10.34 s^2 + 3.527 s + 0.2449

Transfer function from input "S" to output...

18.9 s – 12.6

Xd: ----------------------

21 s^2 + 15 s + 0.6667

19.4 s – 12.93

Xb: --------------------------

14.4 s^2 + 10.6 s + 0.6667

H s ( )

Simulink Block for LTI Systems

2-57

Simulink Block for LTI Systems

You can incor por at e LTI object s int o Simulink diagr ams using t he LTI Syst em

block shown below.

The LTI Syst em block can be accessed eit her by t yping

ltiblock

at t he MATLAB pr ompt or by select ing Control Sys tem Toolbox fr om t he

Blocks ets and Toolboxes sect ion of t he main Simulink libr ar y.

The LTI Syst em block consist s of t he dialog box shown on t he r ight in t he figur e

above. In t he edit able t ext box labeled LTI s ys te m vari able, ent er eit her t he

var iable name of an LTI object locat ed in t he MATLAB wor kspace (for

example, sys) or a MATLAB expr ession t hat evaluat es t o an LTI object (for

example, tf(1,[1 1])). The LTI Syst em block accept s bot h cont inuous and

discr et e LTI object s in eit her t r ansfer funct ion, zer o-pole-gain, or st at e-space

for m. Simulink conver t s t he model t o it s st at e-space equivalent pr ior t o

init ializing t he simulat ion.

Use t he edit able t ext box labeled Ini ti al s tate s t o ent er an init ial st at e vect or

for st at e-space models. The concept of “init ial st at e” is not well-defined for

Double-click on the block in your

Simulink diagram to display or

modify model information.

This mask is linked to an LTI

block in a Simulink diagram.

2 LTI Models

2-58

t r ansfer funct ions or zer o-pole-gain models, as it depends on t he choice of st at e

coor dinat es used by t he r ealizat ion algor it hm. As a r esult , you cannot ent er

nonzer o init ial st at es when you supply TF or ZPK models t o LTI blocks in a

Simulink diagr am.

Note:

•For MIMO syst ems, t he input delays st or ed in t he LTI object must be eit her

all posit ive or all zer o.

•LTI blocks in a Simulink diagr am cannot be used for FRD models or LTI

ar r ays.

References

2-59

References

[1] Dor f, R.C. and R.H. Bishop, Modern Control S ystems, Addison-Wesley,

Menlo Par k, CA, 1998.

[2] Wood, R.K. and M.W. Ber r y, “Ter minal Composit ion Cont r ol of a Binar y

Dist illat ion Column,” Chemical Engineering S cience, 28 (1973), pp. 1707-1717.

2 LTI Models

2-60

3

Oper at ions on LTI Models

Introduct i on . . . . . . . . . . . . . . . . . . . . 3-2

Precedence and Prope rty Inheri t ance . . . . . . . . 3-3

Extracti ng and Modi fying Subsyste ms . . . . . . . . 3-5

Refer encing FRD Models Thr ough Fr equencies . . . . . . 3-7

Refer encing Channels by Name . . . . . . . . . . . . . 3-8

Resizing LTI Syst ems . . . . . . . . . . . . . . . . . 3-9

Ari thmet i c Operati ons . . . . . . . . . . . . . . . 3-11

Addit ion and Subt r act ion . . . . . . . . . . . . . . . 3-11

Mult iplicat ion . . . . . . . . . . . . . . . . . . . . 3-13

Inver sion and Relat ed Oper at ions . . . . . . . . . . . . 3-13

Tr ansposit ion . . . . . . . . . . . . . . . . . . . . 3-14

Per t r ansposit ion . . . . . . . . . . . . . . . . . . . 3-14

Delays and Model Oper at ions . . . . . . . . . . . . . 3-15

Mode l Interconnecti on Functi ons . . . . . . . . . . 3-16

Concat enat ion of LTI Models . . . . . . . . . . . . . . 3-17

Feedback and Ot her Int er connect ion Funct ions . . . . . . 3-18

Cont i nuous/Di screte Conversi ons of LTI Mode ls . . . 3-20

Zer o-Or der Hold . . . . . . . . . . . . . . . . . . . 3-20

Fir st -Or der Hold . . . . . . . . . . . . . . . . . . . 3-22

Tust in Appr oximat ion . . . . . . . . . . . . . . . . . 3-22

Tust in wit h Fr equency Pr ewar ping . . . . . . . . . . . 3-23

Mat ched Poles and Zer os . . . . . . . . . . . . . . . 3-23

Discr et izat ion of Syst ems wit h Delays . . . . . . . . . . 3-24

Delays and Cont inuous/Discr et e Model Conver sions . . . . 3-25

Resampli ng of Di scre te-Ti me Mode ls . . . . . . . . . 3-27

Refe re nce s . . . . . . . . . . . . . . . . . . . . . 3-28

3 Operations on LTI Models

3-2

Introduction

You can per for m basic mat r ix oper at ions such as addit ion, mult iplicat ion, or

concat enat ion on LTI models. Such oper at ions ar e “over loaded,” which means

t hat t hey use t he same synt ax as t hey do for mat r ices, but ar e adapt ed so as t o

apply t o t he LTI model cont ext . These over loaded oper at ions and t heir

int er pr et at ion in t his cont ext ar e discussed in t his chapt er . You can r ead about

discr et izat ion met hods in t his chapt er as well. The following t opics and

oper at ions on LTI models ar e cover ed in t his chapt er :

•Pr ecedence and Pr oper t y Inher it ance

•Ext r act ing and Modifying Subsyst ems

•Ar it hmet ic Oper at ions

•Model Int er connect ion Funct ions

•Cont inuous/Discr et e-Time Conver sions of LTI Models

•Resampling of Discr et e-Time Models

These oper at ions can be applied t o LTI models of differ ent t ypes. As a r esult ,

befor e discussing oper at ions on LTI models, we discuss model t ype pr ecedence

and how LTI model pr oper t ies ar e inher it ed when models ar e combined using

t hese oper at ions. To r ead about how you can apply t hese oper at ions t o ar r ays

of LTI models, see “Oper at ions on LTI Ar r ays” on page 4-25. To r ead about t he

available funct ions wit h which you can analyze LTI models, see Chapt er 5,

“Model Analysis Tools,”

Precedence and Property Inheritance

3-3

Precedence and Property Inheritance

You can apply oper at ions t o LTI models of differ ent t ypes. The r esult ing t ype

is t hen det er mined by t he r ules discussed in “Pr ecedence Rules” on page 2-5.

For example, if sys1 is a t r ansfer funct ion and sys2 is a st at e-space model,

t hen t he r esult of t heir addit ion

sys = sys1 + sys2

is a st at e-space model, since st at e-space models have pr ecedence over t r ansfer

funct ion models.

To super sede t he pr ecedence r ules and for ce t he r esult of an oper at ion t o be a

given t ype, for example, a t r ansfer funct ion (TF), you can eit her :

•Conver t all oper ands t o TF before per for ming t he oper at ion

•Conver t t he r esult t o TF after per for ming t he oper at ion

Suppose, in t he above example, you want t o comput e t he t r ansfer funct ion of

sys. You can eit her use a priori conver sion of t he second oper and

sys = sys1 + tf(sys2);

or a posteriori conver sion of t he r esult

sys = tf(sys1 + sys2)

Note: These alt er nat ives ar e not equivalent numer ically; comput at ions ar e

car r ied out on t r ansfer funct ions in t he fir st case, and on st at e-space models in

t he second case.

Anot her issue is pr oper t y inher it ance, t hat is, how t he oper and pr oper t y values

ar e passed on t o t he r esult of t he oper at ion. While inher it ance is par t ly

oper at ion-dependent , some gener al r ules ar e summar ized below:

•In oper at ions combining discr et e-t ime LTI models, all models must have

ident ical or unspecified (sys.Ts = –1) sample t imes. Models r esult ing fr om

such oper at ions inher it t he specified sample t ime, if t her e is one.

•Most oper at ions ignor e t he Notes and Userdata pr oper t ies.

3 Operations on LTI Models

3-4

•In gener al, when t wo LTI models sys1 and sys2 ar e combined using

oper at ions such as +, *, [,], [;], append, and feedback, t he r esult ing model

inher it s it s I/O names and I/O gr oups fr om sys1 and sys2. However ,

conflict ing I/O names or I/O gr oups ar e not inher it ed. For example, t he

InputName pr oper t y for sys1 + sys2 is left unspecified if sys1 and sys2 have

differ ent InputName pr oper t y values.

•A model r esult ing fr om oper at ions on TF or ZPK models inher it s it s

Variable pr oper t y value fr om t he oper ands. Conflict s ar e r esolved accor ding

t he following r ules:

- For cont inuous-t ime models, 'p' has pr ecedence over 's'.

- For discr et e-t ime models, 'z^–1' has pr ecedence over 'q' and 'z', while

'q' has pr ecedence over 'z'.

Extracting and Modifying Subsystems

3-5

Extracting and Modifying Subsystems

Subsyst ems r elat e subset s of t he input s and out put s of a syst em. The t r ansfer

mat r ix of a subsyst em is a submat r ix of t he syst em t r ansfer mat r ix. For

example, if sys is a syst em wit h t wo input s, t hr ee out put s, and I/O r elat ion

t hen gives t he r elat ion bet ween t he fir st input and t hir d out put .

Accor dingly, we use mat r ix-like subindexing t o ext r act t his subsyst em.

SubSys = sys(3,1)

The r esult ing subsyst em SubSys is an LTI model of t he same t ype as sys, wit h

it s sample t ime, t ime delay, I/O name, and I/O gr oup pr oper t y values inher it ed

fr om sys.

For example, if sys has an input gr oup named controls consist ing of channels

one, t wo, and t hr ee, t hen SubSys also has an input gr oup named controls wit h

t he fir st channel of SubSys assigned t o it .

If sys is a st at e-space model wit h mat r ices a, b, c, d, t he subsyst em sys(3,1)

is a st at e-space model wit h dat a a, b(:,1), c(3,:), d(3,1).

Note:

•In t he expr ession sys(3,1), t he fir st index select s t he out put channel while

t he second index select s t he input channel.

•When ext r act ing a subsyst em fr om a given st at e-space model, t he r esult ing

st at e-space model may not be minimal. Use t he command sminreal t o

eliminat e unnecessar y st at es in t he subsyst em.

You can use similar synt ax t o modify t he LTI model sys. For example,

sys(3,1) = NewSubSys

r edefines t he I/O r elat ion bet ween t he fir st input and t hir d out put , pr ovided

NewSubSys is a SISO LTI model.

y Hu =

H 3 1 , ( )

y

3

H 3,1 ( ) u

1

=

3 Operations on LTI Models

3-6

Note:

•sys, t he LTI model t hat has had a por t ion r eassigned, r et ains it s or iginal

model t ype (TF, ZPK, SS, or FRD) r egar dless of t he model t ype of NewSubSys.

•If NewSubSys is an FRD model, t hen sys must also be an FRD model.

Fur t her mor e, t heir fr equencies must mat ch.

•Subsyst em assignment does not r eassign any I/O names or I/O gr oup names

of NewSubSys t hat ar e alr eady assigned t o NewSubSys.

•Reassigning par t s of a MIMO st at e-space model gener ally incr eases it s

or der .

Ot her st andar d mat r ix subindexing ext ends t o LTI object s as well. For

example,

sys(3,1:2)

ext r act s t he subsyst em mapping t he fir st t wo input s t o t he t hir d out put .

sys(:,1)

select s t he fir st input and all out put s, and

sys([1 3],:)

ext r act s a subsyst em wit h t he same input s, but only t he fir st and t hir d out put s.

For example, consider t he t wo-input /t wo-out put t r ansfer funct ion

. T s ( )

1

s 0.1 +

----------------- 0

s 1 –

s

2

2s 2 + +

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

1

s

---

=

Extracting and Modifying Subsystems

3-7

To ext r act t he t r ansfer funct ion fr om t he fir st input t o t he fir st out put ,

t ype

T(1,1)

Transfer function:

1

-------

s + 0.1

Next r eassign t o and modify t he second input channel of T

by t yping

T(1,1) = tf(1,[1 0.5]);

T(:,2) = [ 1 ; tf(0.4,[1 0]) ]

Transfer function from input 1 to output...

1

#1: -------

s + 0.5

s – 1

#2: -------------

s^2 + 2 s + 2

Transfer function from input 2 to output...

#1: 1

0.4

#2: ---

s

Referencing FRD Models Through Frequencies

You can ext r act subsyst ems fr om FRD models, as you do wit h ot her LTI model

t ypes, by indexing int o input and out put (I/O) dimensions. You can also ext r act

subsyst ems by indexing int o t he fr equencies of an FRD model.

To index int o t he fr equencies of an FRD model, use t he st r ing 'Frequency' (or

any abbr eviat ion, such as, 'freq', as long as it does not conflict wit h exist ing

T

11

s ( )

T

11

s ( ) 1 s 0.5 + ( ) ⁄

3 Operations on LTI Models

3-8

I/O channel or gr oup names) as a keywor d. Ther e ar e t wo ways you can specify

FRD models using fr equencies:

•Using int eger s t o index int o t he fr equency vect or of t he FRD model

•Using a Boolean (logical) expr ession t o specify desir ed fr equency point s in an

FRD model

For example, if sys is an FRD model wit h five fr equencies, (e.g.,

sys.Frequency=[1 1.1 1.2 1.3 1.4]), t hen you can cr eat e a new FRD model

sys2 by indexing int o t he fr equencies of sys as follows.

sys2 = sys('frequency', 2:3);

sys2.Frequency

ans =

1.1000

1.2000

displays t he second and t hir d ent r ies in t he fr equency vect or .

Similar ly, you can use logical indexing int o t he fr equencies.

sys2 = sys('frequency',sys.Frequency >1.0 & sys.Frequency <1.15);

sys2.freq

ans =

1.1000

You can also combine model ext r act ion t hr ough fr equencies wit h indexing int o

t he I/O dimensions. For example, if sys is an FRD model wit h t wo input s, t wo

out put s, and fr equency vect or [2.1 4.2 5.3], wit h sys.Units specified in

r ad/s, t hen

sys2 = sys(1,2,'freq',1)

specifies sys2 as a SISO FRD model, wit h one fr equency dat a point , 2.1 r ad/s.

Referencing Channels by Name

You can also ext r act subsyst ems using I/O gr oup or channel names. For

example, if sys has an input gr oup named noise, consist ing of channels t wo,

four , and five, t hen

sys(1,'noise')

Extracting and Modifying Subsystems

3-9

is equivalent t o

sys(1,[2 4 5]

Similar ly, if pressure is t he name assigned t o an out put channel of t he LTI

model sys, t hen

sys('pressure',1) = tf(1, [1 1])

r eassigns t he subsyst em fr om t he fir st input of sys t o t he out put labeled

pressure.

You can r efer ence a set of channels by input or out put name by using a cell

ar r ay of st r ings for t he names. For example, if sys has one out put channel

named pressure and one named temperature, t hen t hese t wo out put channels

can be r efer enced using

sys({'pressure','temperature'})

Resizing LTI Systems

Resizing a syst em consist s of adding or delet ing input s and/or out put s. To

delet e t he fir st t wo input s, simply t ype

sys(:,1:2) = []

In delet ions, at least one of t he r ow/column indexes should be t he colon (:)

select or .

To per for m input /out put augment at ion, you can pr oceed by concat enat ion or

subassignment . Given a syst em sys wit h a single input , you can add a second

input using

sys = [sys,h];

or , equivalent ly, using

sys(:,2) = h;

wher e h is any LTI model wit h one input , and t he same number of out put s as

sys. Ther e is an impor t ant differ ence bet ween t hese t wo opt ions: while

concat enat ion obeys t he pr ecedence r ules (see page 2-5), subsyst em assignment

does not alt er t he model t ype. So, if sys and h ar e TF and SS object s,

r espect ively, t he fir st st at ement pr oduces a st at e-space model, and t he second

st at ement pr oduces a t r ansfer funct ion.

3 Operations on LTI Models

3-10

For st at e-space models, bot h concat enat ion and subsyst em assignment

incr ease t he model or der because t hey assume t hat sys and h have

independent st at es. If you int end t o keep t he same st at e mat r ix and mer ely

updat e t he input -t o-st at e or st at e-t o-out put r elat ions, use set inst ead and

modify t he cor r esponding st at e-space dat a dir ect ly. For example,

sys = ss(a,b1,c,d1)

set(sys,'b',[b1 b2],'d',[d1 d2])

adds a second input t o t he st at e-space model sys by appending t he B and D

mat r ices. You should simultaneously modify bot h mat r ices wit h a single set

command. Indeed, t he st at ement s

sys.b = [b1 b2]

and

set(sys,'b',[b1 b2])

cause an er r or because t hey cr eat e invalid int er mediat e models in which t he B

and D mat r ices have inconsist ent column dimensions.

Arithmetic Operations

3-11

Arithmetic Operations

You can apply almost all ar it hmet ic oper at ions t o LTI models, including t hose

shown below.

To under st and how t hese oper at ions wor k on LTI models, it ’s useful t o keep in

mind t he mat r ix analogy for syst ems discussed in “Viewing LTI Syst ems As

Mat r ices” on page 2-5.

Addition and Subtraction

As ment ioned in “Viewing LTI Syst ems As Mat r ices” on page 2-5, adding LTI

models is equivalent t o connect ing t hem in par allel. Specifically, t he LTI model

sys = sys1 + sys2

Operation Description

+ Addit ion

– Subt r act ion

* Mult iplicat ion

/ Right mat r ix divide

\ Left mat r ix divide

inv Mat r ix inver sion

' Per t r ansposit ion

.' Tr ansposit ion

^ Power s of an LTI model (as in s^2)

3 Operations on LTI Models

3-12

r epr esent s t he par allel int er connect ion shown below.

If sys1 and sys2 ar e t wo st at e-space models wit h dat a and

, t he st at e-space dat a associat ed wit h sys1 + sys2 is

Scalar addit ion is also suppor t ed and behaves as follows: if sys1 is MIMO and

sys2 is SISO, sys1 + sys2 pr oduces a syst em wit h t he same dimensions as

sys1 whose ijt h ent r y is sys1(i,j) + sys2.

Similar ly, t he subt r act ion of t wo LTI models

sys = sys1 – sys2

is depict ed by t he following block diagr am.

sys1

sys2

u

+

+

sys

y

1

y

2

y

A

1

B

1

C

1

D

1

, , ,

A

2

B

2

C

2

D

2

, , ,

A

1

0

0 A

2

,

B

1

B

2

, C

1

C

2

, D

1

D

2

+

sys1

sys2

u

y

+

–

sys

y

1

y

2

Arithmetic Operations

3-13

Multiplication

Mult iplicat ion of t wo LTI models connect s t hem in ser ies. Specifically,

sys = sys1 * sys2

r et ur ns an LTI model sys for t he ser ies int er connect ion shown below.

Not ice t he r ever se or der s of sys1 and sys2 in t he mult iplicat ion and block

diagr am. This is consist ent wit h t he way t r ansfer mat r ices ar e combined in a

ser ies connect ion: if sys1 and sys2 have t r ansfer mat r ices and , t hen

For st at e-space models sys1 and sys2 wit h dat a and

, t he st at e-space dat a associat ed wit h sys1*sys2 is

Finally, if sys1 is MIMO and sys2 is SISO, t hen sys1*sys2 or sys2*sys1 is

int er pr et ed as an ent r y-by-ent r y scalar mult iplicat ion and pr oduces a syst em

wit h t he same dimensions as sys1, whose ijt h ent r y is sys1(i,j)*sys2.

Inversion and Related Operations

Inver sion of LTI models amount s t o inver t ing t he following input /out put

r elat ionship.

This oper at ion is defined only for squar e syst ems (t hat is, syst ems wit h as

many input s as out put s) and is per for med using

inv(sys)

u y

v

sys2 sys1

H

1

H

2

y H

1

v H

1

H

2

u ( ) H

1

H

2

× ( ) u = = =

A

1

B

1

C

1

D

1

, , ,

A

2

B

2

C

2

D

2

, , ,

A

1

B

1

C

2

0 A

2

,

B

1

D

2

B

2

, C

1

D

1

C

2

, D

1

D

2

y H u = → u H

1 –

y =

3 Operations on LTI Models

3-14

The r esult ing inver se model is of t he same t ype as sys. Relat ed oper at ions

include:

•Left division sys1\sys2, which is equivalent t o inv(sys1)*sys2

•Right division sys1/sys2, which is equivalent t o sys1*inv(sys2)

For a st at e-space model sys wit h dat a , inv(sys) is defined only

when is a squar e inver t ible mat r ix, in which case it s st at e-space dat a is

Transposition

You can t r anspose an LTI model sys using

sys.'

This is a lit er al oper at ion wit h t he following effect :

•For TF models (wit h input ar gument s, num and den), t he cell ar r ays num and

den ar e t r ansposed.

•For ZPK models (wit h input ar gument s, z, p, and k), t he cell ar r ays, z and p,

and t he mat r ix k ar e t r ansposed.

•For SS models (wit h model dat a ), t r ansposit ion pr oduces t he

st at e-space model A

T

, C

T

, B

T

, D

T

.

•For FRD models (wit h complex fr equency r esponse mat r ix Response), t he

mat r ix of fr equency r esponse dat a at each fr equency is t r ansposed.

Pertransposition

For a cont inuous-t ime syst em wit h t r ansfer funct ion , t he pertransposed

syst em has t he t r ansfer funct ion

The discr et e-t ime count er par t is

Per t r ansposit ion of an LTI model sys is per for med using

sys'

A B C D , , ,

D

A BD

1 –

C , – BD

1 –

, D –

1 –

C , D

1 –

A B C D , , ,

H s ( )

G s ( ) H s – ( ) [ ]

T

=

G z ( ) H z

1 –

( ) [ ]

T

=

Arithmetic Operations

3-15

You can use per t r ansposit ion t o obt ain t he Her mit ian (conjugat e) t r anspose of

t he fr equency r esponse of a given syst em. The fr equency r esponse of t he

per t r anspose of , , is t he Her mit ian t r anspose of t he

fr equency r esponse of : .

To obt ain t he Her mit ian t r anspose of t he fr equency r esponse of a syst em sys

over a fr equency r ange specified by t he vect or w, t ype

freqresp(sys', w);

Operations on State-Space Models with Delays

When you apply oper at ions such as +,*,\,/,[], t o st at e-space models, all or

par t of t he I/O delay mat r ix of t he r esult ing model is absor bed int o t he input

and out put delay vect or s when it is possible t o r educe t he t ot al number of I/O

delays. The r esult ing model has a minimum number of such delays.

H s ( ) G s ( ) H s – ( ) [ ]

T

=

H s ( ) G j w ( ) H j w ( )

H

=

3 Operations on LTI Models

3-16

Model Interconnection Functions

The Cont r ol Syst em Toolbox pr ovides a number of funct ions t o help wit h t he

model building pr ocess. These include model int er connect ion funct ions t o

per for m I/O concat enat ion ([,], [;], and append), gener al par allel and ser ies

connect ions (parallel and series), and feedback connect ions (feedback and

lft). These funct ions ar e useful t o model open- and closed-loop syst ems.

Interconnection Operator Description

[,] Concat enat es hor izont ally

[;] Concat enat es ver t ically

append Appends models in a block diagonal

configur at ion

augstate Augment s t he out put by appending st at es

connect For ms an SS model fr om a block diagonal

LTI object for an ar bit r ar y int er connect ion

mat r ix

feedback For ms t he feedback int er connect ion of t wo

models

lft Pr oduces t he LFT int er connect ion

(Redheffer St ar pr oduct ) of t wo models

parallel For ms t he gener alized par allel connect ion

of t wo models

series For ms t he gener alized ser ies connect ion of

t wo models

Model Interconnection Functions

3-17

Concatenation of LTI Models

LTI model concat enat ion is done in a manner similar t o t he way you

concat enat e mat r ices in MATLAB, using

sys = [sys1 , sys2] % horizontal concatenation

sys = [sys1 ; sys2] % vertical concatenation

sys = append(sys1,sys2)% block diagonal appending

In I/O t er ms, hor izont al and ver t ical concat enat ion have t he following

block-diagr am int er pr et at ions (wit h and denot ing t he t r ansfer

mat r ices of sys1 and sys2).

You can use concat enat ion as an easy way t o cr eat e MIMO t r ansfer funct ions

or zer o-pole-gain models. For example,

H = [ tf(1,[1 0]) 1 ; 0 tf([1 –1],[1 1]) ]

specifies

H

1

H

2

H

2

y

+

+

H

1

u

1

u

2

y H

1

, H

2

u

1

u

2

=

Horizontal Concatenation

H

2

H

1

u

y

1

y

2

y

1

y

2

H

1

H

2

u =

Vertical Concatenation

H s ( )

1

s

--- 1

0

s 1 –

s 1 +

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

=

3 Operations on LTI Models

3-18

Use

append(sys1,sys2)

t o specify t he block-decoupled LTI model int er connect ion.

See append on page 11-12 for mor e infor mat ion on t his command.

Feedback and Other Interconnection Functions

The following LTI model int er connect ion funct ions ar e useful for specifying

closed- and open-loop model configur at ions:

•feedback put s t wo LTI models wit h compat ible dimensions in a feedback

configur at ion.

•series connect s t wo LTI models in ser ies.

•parallel connect s t wo LTI models in par allel.

•lft per for ms t he Redheffer st ar pr oduct on t wo LTI models.

•connect wor ks wit h append t o apply an ar bit r ar y int er connect ion scheme t o

a set of LTI models.

sys1

sys2

Appended Models

u

1

u

2

y

1

y

2

s ys 1 0

0 s ys 2

Transfer Function

Model Interconnection Functions

3-19

For example, if sys1 has m input s and p out put s, while sys2 has p input s and

m out put s, t hen t he negat ive feedback configur at ion of t hese t wo LTI models

is r ealized wit h

feedback(sys1,sys2)

This specifies t he LTI model wit h m input s and p out put s whose I/O map is

See Chapt er 11, “Refer ence,” for mor e infor mat ion on feedback, series,

parallel, lft, and connect.

sys1

sys2

–

+

u y

I s ys 1 s ys 2 ⋅ + ( )

1 –

s ys1

3 Operations on LTI Models

3-20

Continuous/Discrete Conversions of LTI Models

The funct ion c2d discr et izes cont inuous-t ime TF, SS, or ZPK models.

Conver sely, d2c conver t s discr et e-t ime TF, SS, or ZPK models t o cont inuous

t ime. Sever al discr et izat ion/int er polat ion met hods ar e suppor t ed, including

zer o-or der hold (ZOH), fir st -or der hold (FOH), Tust in appr oximat ion wit h or

wit hout fr equency pr ewar ping, and mat ched poles and zer os.

The synt ax

sysd = c2d(sysc,Ts); % Ts = sampling period in seconds

sysc = d2c(sysd);

per for ms ZOH conver sions by default . To use alt er nat ive conver sion schemes,

specify t he desir ed met hod as an ext r a st r ing input :

sysd = c2d(sysc,Ts,'foh'); % use first-order hold

sysc = d2c(sysd,'tustin'); % use Tustin approximation

The conver sion met hods and t heir limit at ions ar e discussed next .

Zero-Order Hold

Zer o-or der hold (ZOH) devices conver t sampled signals t o cont inuous-t ime

signals for analyzing sampled cont inuous-t ime syst ems. The zer o-or der -hold

discr et izat ion of a cont inuous-t ime LTI model is depict ed in t he

following block diagr am.

The ZOH device gener at es a cont inuous input signal u(t) by holding each

sample value u[k] const ant over one sample per iod.

H

d

z ( ) H s ( )

H s ( ) u k [ ] y k [ ]

u t ( ) y t ( )

ZOH

T

s

H

d

z ( )

Continuous/Discrete Conversions of LTI Models

3-21

The signal is t hen fed t o t he cont inuous syst em , and t he r esult ing

out put is sampled ever y seconds t o pr oduce .

Conver sely, given a discr et e syst em , t he d2c conver sion pr oduces a

cont inuous syst em whose ZOH discr et izat ion coincides wit h . This

inver se oper at ion has t he following limit at ions:

•d2c cannot oper at e on LTI models wit h poles at when t he ZOH is used.

•Negat ive r eal poles in t he domain ar e mapped t o pairs of complex poles in

t he domain. As a r esult , t he d2c conver sion of a discr et e syst em wit h

negat ive r eal poles pr oduces a cont inuous syst em wit h higher or der .

The next example illust r at es t he behavior of d2c wit h r eal negat ive poles.

Consider t he following discr et e-t ime ZPK model.

hd = zpk([],–0.5,1,0.1)

Zero/pole/gain:

1

-------

(z+0.5)

Sampling time: 0.1

Use d2c t o conver t t his model t o cont inuous-t ime

hc = d2c(hd)

and you get a second-or der model.

Zero/pole/gain:

4.621 (s+149.3)

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

(s^2 + 13.86s + 1035)

Discr et ize t he model again

c2d(hc,0.1)

u t ( ) u k [ ] , = k T

s

t k 1 + ( )T

s

≤ ≤

u t ( ) H s ( )

y t ( ) T

s

y k [ ]

H

d

z ( )

H s ( ) H

d

z ( )

z 0 =

z

s

3 Operations on LTI Models

3-22

and you get back t he or iginal discr et e-t ime syst em (up t o canceling t he

pole/zer o pair at z=–0.5):

Zero/pole/gain:

(z+0.5)

---------

(z+0.5)^2

Sampling time: 0.1

First-Order Hold

Fir st -or der hold (FOH) differ s fr om ZOH by t he under lying hold mechanism.

To t ur n t he input samples int o a cont inuous input , FOH uses linear

int er polat ion bet ween samples.

This met hod is gener ally mor e accur at e t han ZOH for syst ems dr iven by

smoot h input s. Due t o causalit y const r aint s, t his opt ion is only available for

c2d conver sions, and not d2c conver sions.

Note: This FOH met hod differ s fr om st andar d causal FOH and is mor e

appr opr iat ely called triangle approximation (see [2], p. 151). It is also known

as ramp-invariant appr oximat ion because it is dist or t ion-fr ee for r amp input s.

Tustin Approximation

The Tust in or bilinear appr oximat ion uses t he appr oximat ion

t o r elat e s-domain and z-domain t r ansfer funct ions. In c2d conver sions, t he

discr et izat ion of a cont inuous t r ansfer funct ion is der ived by

u k [ ] u t ( )

u t ( ) u k [ ]

t k T

s

–

T

s

------------------ u k 1 + [ ] u k [ ] – ( ) , + = k T

s

t k 1 + ( )T

s

≤ ≤

z e

s T

s

1 s T

s

2 ⁄ +

1 s T

s

2 ⁄ –

-------------------------- ≈ =

H

d

z ( ) H s ( )

Continuous/Discrete Conversions of LTI Models

3-23

Similar ly, t he d2c conver sion r elies on t he inver se cor r espondence

Tustin with Frequency Prewarping

This var iat ion of t he Tust in appr oximat ion uses t he cor r espondence

This change of var iable ensur es t he mat ching of t he cont inuous- and

discr et e-t ime fr equency r esponses at t he fr equency .

Matched Poles and Zeros

The mat ched pole-zer o met hod applies only t o SISO syst ems. The cont inuous

and discr et ized syst ems have mat ching DC gains and t heir poles and zer os

cor r espond in t he t r ansfor mat ion

See [2], p. 147 for mor e det ails.

H

d

z ( ) H s' ( ) , wher e = s'

2

T

s

------

z 1 –

z 1 +

------------ =

H s ( ) H

d

z' ( ), wher e = z'

1 s T

s

2 ⁄ +

1 s T

s

2 ⁄ –

-------------------------- =

H

d

z ( ) H s' ( ) , = s'

ω

ωT

s

2 ⁄ ( ) t an

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

z 1 –

z 1 +

------------ =

ω

H j ω ( ) H

d

e

j ωT

s

( ) =

z e

s T

s

=

3 Operations on LTI Models

3-24

Discretization of Systems with Delays

You can also use c2d t o discr et ize SISO or MIMO cont inuous-t ime models wit h

t ime delays. If Ts is t he sampling per iod used for discr et izat ion:

•A delay of tau seconds in t he cont inuous-t ime model is mapped t o a delay of

k sampling per iods in t he discr et ized model, wher e k = fix(tau/Ts).

•The r esidual fractional delay tau – k*Ts is absor bed int o t he coefficient s of

t he discr et ized model (for t he zer o-or der -hold and fir st -or der -hold met hods

only).

For example, t o discr et ize t he t r ansfer funct ion

using zer o-or der hold on t he input , and a 10 Hz sampling r at e, t ype

h = tf(10,[1 3 10],'inputdelay',0.25);

hd = c2d(h,0.1)

This pr oduces t he discr et e-t ime t r ansfer funct ion

Transfer function:

0.01187 z^2 + 0.06408 z + 0.009721

z^(–2) * ----------------------------------

z^3 – 1.655 z^2 + 0.7408 z

Sampling time: 0.1

Her e t he input delay in amount s t o 2.5 t imes t he sampling per iod of 0.1

seconds. Accor dingly, t he discr et ized model hd inher it s an input delay of t wo

sampling per iods, as confir med by t he value of hd.inputdelay. The r esidual

half-per iod delay is fact or ed int o t he coefficient s of hd by t he discr et izat ion

algor it hm.

H s ( ) e

0.25s – 10

s

2

3s 10 + +

------------------------------- =

H s ( )

Continuous/Discrete Conversions of LTI Models

3-25

The st ep r esponses of t he cont inuous and discr et ized models ar e compar ed in

t he figur e below. This plot was pr oduced by t he command

step(h,'--',hd,'-')

Note: The Tust in and mat ched pole/zer o met hods ar e accur at e only for

delays t hat ar e int eger mult iples of t he sampling per iod. It is t her efor e

pr efer able t o use t he zoh and foh discr et izat ion met hods for models wit h

delays.

Delays and Continuous/Discrete Model Conversions

When you apply c2d and d2c t o st at e-space models, all or par t of t he I/O delay

mat r ix of t he r esult ing model is absor bed int o t he input and out put delay

3 Operations on LTI Models

3-26

vect or s when it is possible t o r educe t he t ot al number of I/O delays. The

r esult ing model has a minimum number of such delays.

Resampling of Discrete-Time Models

3-27

Resampling of Discrete-Time Models

You can r esample a discr et e-t ime TF, SS, or ZPK model sys1 by t yping

sys2 = d2d(sys1,Ts)

The new sampling per iod Ts does not have t o be an int eger mult iple of t he

or iginal sampling per iod. For example, t yping

h1 = tf([1 0.4],[1 –0.7],0.1);

h2 = d2d(h1,0.25);

r esamples h1 at t he sampling per iod of 0.25 seconds, r at her t han 0.1 seconds.

You can compar e t he st ep r esponses of h1 and h2 by t yping

step(h1,'--',h2,'-')

The r esult ing plot is shown on t he figur e below (h1 is t he dashed line).

3 Operations on LTI Models

3-28

References

[1] Åst r öm, K.J . and B. Wit t enmar k, Computer-Controlled S ystems: Theory

and Design, Pr ent ice-Hall, 1990, pp. 48–52.

[2] Fr anklin, G.F., J .D. Powell, and M.L. Wor kman, Digital Control of Dynamic

S ystems, Second Edit ion, Addison-Wesley, 1990.

4

Ar r ays of LTI Models

Introduct i on . . . . . . . . . . . . . . . . . . . . 4-2

When t o Collect a Set of Models in an LTI Ar r ay . . . . . . 4-2

Rest r ict ions for LTI Models Collect ed in an Ar r ay . . . . . 4-2

Wher e t o Find Infor mat ion on LTI Ar r ays . . . . . . . . 4-3

The Concept of an LTI Array . . . . . . . . . . . . 4-4

Higher Dimensional Ar r ays of LTI Models . . . . . . . . 4-6

Di mensions, Size, and Shape of an LTI Array . . . . . 4-7

size and ndims . . . . . . . . . . . . . . . . . . . . 4-9

r eshape . . . . . . . . . . . . . . . . . . . . . . 4-11

Bui ldi ng LTI Arrays . . . . . . . . . . . . . . . . 4-12

Gener at ing LTI Ar r ays Using r ss . . . . . . . . . . . . 4-12

Building LTI Ar r ays Using for Loops . . . . . . . . . . 4-12

Building LTI Ar r ays Using t he st ack Funct ion . . . . . . . 4-15

Building LTI Ar r ays Using t f, zpk, ss, and fr d . . . . . . . 4-17

Indexi ng Into LTI Arrays . . . . . . . . . . . . . . 4-20

Accessing Par t icular Models in an LTI Ar r ay . . . . . . . 4-20

Ext r act ing LTI Ar r ays of Subsyst ems . . . . . . . . . . 4-21

Reassigning Par t s of an LTI Ar r ay . . . . . . . . . . . 4-22

Delet ing Par t s of an LTI Ar r ay . . . . . . . . . . . . . 4-23

Operati ons on LTI Arrays . . . . . . . . . . . . . . 4-25

Example: Addit ion of Two LTI Ar r ays . . . . . . . . . . 4-26

Dimension Requir ement s . . . . . . . . . . . . . . . 4-27

Special Cases for Oper at ions on LTI Ar r ays . . . . . . . . 4-27

Ot her Oper at ions on LTI Ar r ays . . . . . . . . . . . . 4-30

4 Arrays of LTI Models

4-2

Introduction

You can use LTI ar r ays t o collect a set of LTI models int o a single MATLAB

var iable. You t hen use t his var iable t o manipulat e or analyze t he ent ir e

collect ion of models in a vect or ized fashion. You access t he individual models

in t he collect ion t hr ough indexing r at her t han by individual model names.

LTI ar r ays ext end t he concept of single LTI models in a similar way t o how

mult idimensional ar r ays ext end t wo-dimensional mat r ices in MATLAB (see

Chapt er 12, “Mult idimensional Ar r ays” in Using MATLAB). Addit ionally,

when you t hink about LTI ar r ays, it is useful t o keep in mind t he mat r ix

int er pr et at ion of LTI models developed in “Viewing LTI Syst ems As Mat r ices”

on page 2-5.

When to Collect a Set of Models in an LTI Array

You can use LTI ar r ays t o r epr esent :

•A set of LTI models ar ising fr om t he linear izat ion of a nonlinear syst em at

sever al oper at ing point s

•A collect ion of t r ansfer funct ions t hat depend on one or mor e par amet er s

•A set of LTI models ar ising fr om sever al syst em ident ificat ion exper iment s

applied t o one plant

•A set of gain-scheduled LTI cont r oller s

•A list of LTI models you want t o collect t oget her under t he same name

Restrictions for LTI Models Collected in an Array

For each model in an LTI ar r ay, t he following pr oper t ies must be t he same:

•The number of input s and out put s

•The sample t ime, for discr et e-t ime models

•The I/O names and I/O gr oups

Note: You cannot specify Simulink LTI blocks wit h LTI ar r ays.

Introduction

4-3

Where to Find Information on LTI Arrays

The next t wo sect ions give examples t hat illust r at e t he concept of an LTI ar r ay,

it s dimensions, and size. To r ead about how t o build an LTI ar r ay, go t o

“Building LTI Ar r ays” on page 4-12. The r emainder of t he chapt er is devot ed t o

indexing and oper at ions on LTI Ar r ays. You can also apply t he analysis

funct ions in t he Cont r ol Syst em Toolbox t o LTI ar r ays. See Chapt er 5, “Model

Analysis Tools,” for mor e infor mat ion on t hese funct ions. You can also view

r esponse plot s of LTI ar r ays wit h t he LTI Viewer . For infor mat ion, see Chapt er

6, “The LTI Viewer .”

4 Arrays of LTI Models

4-4

The Concept of an LTI Array

To visualize t he concept of an LTI ar r ay, consider t he set of five t r ansfer

funct ion models shown below. In t his example, each model has t wo input s and

t wo out put s. They differ by par amet er var iat ions in t he individual model

component s.

Figure 4-1: Five LTI Models to be Collected in an LTI Array

Figure 4-2: An LTI Array Containing These Five Models

1.1

s 1 +

------------ 0

0

1

s 5 +

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

1.3

s 1.1 +

----------------- 0

0

1

s 5.2 +

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

1.11

s 1.2 +

----------------- 0

0

1

s 5.4 +

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

1.15

s 1.3 +

----------------- 0

0

1

s 5.6 +

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

1.09

s 1.4 +

----------------- 0

0

1

s 5.8 +

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

1.09

s 1.4 +

----------------- 0

0

1

s 5.8 +

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

1.15

s 1.3 +

----------------- 0

0

1

s 5.6 +

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

1.11

s 1.2 +

----------------- 0

0

1

s 5.4 +

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

1.3

s 1.1 +

----------------- 0

0

1

s 5.2 +

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

1.1

s 1 +

------------ 0

0

1

s 5 +

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

Each element of the

LTI array is a model.

This LTI array embodies a

1-by-5 list of models.

The Concept of an LTI Array

4-5

J ust as you might collect a set of t wo-by-t wo mat r ices in a mult idimensional

ar r ay, you can collect t his set of five t r ansfer funct ion models as a list in an LTI

ar r ay under one var iable name, say, sys. Each element of t he LTI ar r ay is an

LTI model.

Individual models in t he LTI ar r ay sys ar e accessed via indexing. The gener al

for m for t he synt ax you use t o access dat a in an LTI ar r ay is

For example, you can access t he t hir d model in sys wit h sys(:,:,3). The

following illust r at es how you can use indexing t o select models or t heir

component s fr om sys.

Figure 4-3: Using Indices to Select Models and Their Components

See “Indexing Int o LTI Ar r ays” on page 4-20 for mor e infor mat ion on indexing.

sys(Outputs,Inputs,Models)

The first index

selects the output

channels.

The second in-

dex selects the

input channels.

The remaining indices select

particular models in the LTI

array by their array coordi-

nates.

1.11

s 1.2 +

----------------- 0

0

1

s 5.4 +

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

sys(:,:,3) selects the third model in the array.

sys(2,2,3) selects

the (2,2) entry of the

third model in the array.

1.09

s 1.4 +

----------------- 0

0

1

s 5.8 +

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

1.15

s 1.3 +

----------------- 0

0

1

s 5.6 +

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

1.11

s 1.2 +

----------------- 0

0

1

s 5.4 +

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

1.3

s 1.1 +

----------------- 0

0

1

s 5.2 +

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

1.1

s 1 +

------------ 0

0

1

s 5 +

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

4 Arrays of LTI Models

4-6

Higher Dimensional Arrays of LTI Models

You can also collect a set of models in a t wo-dimensional ar r ay. The following

diagr am illust r at es a 2-by-3 ar r ay of six, t wo-out put , one-input models called

m2d.

Figure 4-4: m2d: A 2-by-3 Array of Two-Output, One-Input Models

Mor e gener ally, you can or ganize models int o a 3-D or higher -dimensional

ar r ay, in much t he same way you ar r ange numer ical dat a int o

mult idimensional ar r ays (see Chapt er 12, “Mult idimensional Ar r ays” in Using

MATLAB).

m2d(:,:,1,3) extracts the

model in the (1,3) position

of the array.

Each entry in this 2-by-3 array of

models is a two-output, one-input

transfer function.

3.36

s 2.9 +

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

7.23

3.4

s 2.86 +

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

7.27

3.45

s 2.81 +

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

7.32

m2d(:,:,1,1) m2d(:,:,1,2) m2d(:,:,1,3)

m2d(:,:,2,1) m2d(:,:,2,2) m2d(:,:,2,3)

3.42

s 2.84 +

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

7.29

m2d(:,:,1,3)

Dimensions, Size, and Shape of an LTI Array

4-7

Dimensions, Size, and Shape of an LTI Array

The dimensions and size of a single LTI model ar e det er mined by t he out put

and input channels. An ar r ay of LTI models has addit ional quant it ies t hat

det er mine it s dimensions, size, and shape.

Ther e ar e t wo set s of dimensions associat ed wit h LTI ar r ays:

•The I/ O dimensions—t he out put dimension and input dimension common t o

all models in t he LTI ar r ay

•The array dimensions—t he dimensions of t he ar r ay of models it self

The size of t he LTI ar r ay is det er mined by:

•The lengt hs of t he I/O dimensions—t he number of out put s (or input s)

common t o all models in t he LTI ar r ay

•The lengt h of each ar r ay dimension—t he number of models along t hat ar r ay

dimension

4 Arrays of LTI Models

4-8

The next figur e illust r at es t he concept s of dimension and size for t he LTI ar r ay

m2d, a 2-by-3 ar r ay of one-input , t wo-out put t r ansfer funct ion models.

Figure 4-5: Dimensions and Size of m2d, an LTI Array

You can load t his sample LTI ar r ay int o your wor kspace by t yping

load LTIexamples

size(m2d)

2x3 array of continuous-time transfer functions

Each transfer function has 2 outputs and 1 input.

Accor ding t o t he mat r ix analogy in “Viewing LTI Syst ems As Mat r ices” on page

2-5, t he I/O dimensions cor r espond t o t he r ow and column dimensions of t he

t r ansfer mat r ix. The t wo I/O dimensions ar e bot h of lengt h 1 for SISO models.

For MIMO models t he lengt hs of t hese dimensions ar e given by t he number of

out put s and input s of t he model.

T

h

e

l

e

n

g

t

h

o

f

t

h

e

f

i

r

s

t

a

r

r

a

y

d

i

m

e

n

s

i

o

n

i

s

2

.

The length of the second array dimension is 3.

Input dimension (length 1)

O

u

t

p

u

t

d

i

m

e

n

s

i

o

n

(

l

e

n

g

t

h

2

)

3.36

s 2.9 +

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

7.23

3.4

s 2.86 +

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

7.27

3.45

s 2.81 +

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

7.32

m2d(:,:,1,1) m2d(:,:,1,2) m2d(:,:,1,3)

m2d(:,:,2,1) m2d(:,:,2,2) m2d(:,:,2,3)

3.45

s 2.81 +

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

7.32

m2d(:,:,2,3)

Dimensions, Size, and Shape of an LTI Array

4-9

Five r elat ed quant it ies ar e per t inent t o under st anding t he ar r ay dimensions:

•N, t he number of models in t he LTI ar r ay

•K, t he number of ar r ay dimensions

• , t he list of lengt hs of t he ar r ay dimensions

- is t he number of models along t he dimension.

• , t he configur at ion of t he models in t he ar r ay

- The configur at ion det er mines t he shape of t he ar r ay.

- The pr oduct of t hese int eger s is N.

In t he example model m2d,:

•The lengt h of t he out put dimension, t he fir st I/O dimension, is 2, since t her e

ar e t wo out put channels in each model.

•The lengt h of t he input dimension, t he second I/O dimension, is 1, since t her e

is only one input channel in each model.

•N, t he number of models in t he LTI ar r ay, is 6.

•K, t he number of ar r ay dimensions, is 2.

•The ar r ay dimension lengt hs ar e [2 3].

•The ar r ay configur at ion is 2-by-3.

size and ndims

You can access t he dimensions and shape of an LTI ar r ay using:

•size t o det er mine t he lengt hs of each of t he dimensions associat ed wit h an

LTI ar r ay

•ndims t o det er mine t he t ot al number of dimensions in an LTI ar r ay

When applied t o an LTI ar r ay, size r et ur ns

[Ny Nu S1 S2 ... Sk]

wher e

•Ny is t he number of out put s common t o all models in t he LTI ar r ay.

•Nu is t he number of input s common t o all models in t he LTI ar r ay.

•S1 S2 ... Sk ar e t he lengt hs of t he ar r ay dimensions of a k-dimensional

ar r ay of models. Si is t he number of models along t he it h ar r ay dimension.

S

1

S

2

…S

K

S

i

i

t h

S

1

by S – –

2

by … by S

K

– – – –

S

1

S

2

× … S

K

× ×

4 Arrays of LTI Models

4-10

Note:

•By convent ion, a single LTI model is t r eat ed as a 1-by-1 ar r ay of models.

For single LTI models, size r et ur ns only t he I/O dimensions [Ny Nu].

•For LTI ar r ays, size always r et ur ns at least t wo ar r ay dimensions.

For example, t he size of a 2-by-1 LTI ar r ay in [Ny Nu 2 1]

•size ignor es t r ailing singlet on dimensions beyond t he second ar r ay

dimension.

For example, size r et ur ns [Ny Nu 2 3] for a 2-by-3-by-1-by-1 LTI ar r ay of

models wit h Ny out put s and Nu input s.

•You can use t he synt ax size(sys,'order') t o det er mine t he number of

st at es in an LTI ar r ay, sys. A mult idimensional ar r ay is r et ur ned if sys is an

SS model such t hat t he number s of st at es in each model in sys ar e not t he

same.

The funct ion ndims r et ur ns t he t ot al number of dimensions in an LTI ar r ay:

•2, for single LTI models

•2 + p, for LTI ar r ays, wher e p (gr eat er t han 2) is t he number of ar r ay

dimensions

Not e t hat

ndims (sys) = length(size(sys))

To see how t hese wor k on t he sample 2-by-3 LTI ar r ay m2d of t wo-out put ,

one-input models, t ype

load LTIexamples

s = size(m2d)

s =

2 1 2 3

Dimensions, Size, and Shape of an LTI Array

4-11

Not ice t hat size r et ur ns a vect or whose ent r ies cor r espond t o t he lengt h of

each of t he four dimensions of m2d: t wo out put s and one input in a 2-by-3 ar r ay

of models. Type

ndims(m2d)

ans =

4

t o see t hat t her e ar e indeed four dimensions at t r ibut ed t o t his LTI ar r ay.

reshape

Use reshape t o r eor ganize t he ar r angement (ar r ay configur at ion) of t he models

of an exist ing LTI ar r ay.

For example, t o ar r ange t he models in an LTI Ar r ay sys as a

ar r ay, t ype

reshape(sys,w1,...,wp)

wher e w1,...,wp ar e any set of int eger s whose pr oduct is N, t he number of

models in sys.

You can r eshape t he LTI ar r ay m2d int o a 3-by-2, a 6-by-1, or a 1-by-6 ar r ay

using reshape. For example, t ype

load LTIexamples

sys = reshape(m2d,6,1);

size(sys)

6x1 array of continuous-time transfer functions

Each transfer function has 2 outputs and 1 inputs.

s = size(sys)

s =

2 1 6 1

w

1

… × w

p

×

4 Arrays of LTI Models

4-12

Building LTI Arrays

Ther e ar e sever al ways t o build LTI ar r ays:

•Using a for loop t o assign each model in t he ar r ay

•Using stack t o concat enat e LTI models int o an LTI ar r ay

•Using tf, zpk, ss, or frd

In addit ion, you can use t he command rss t o gener at e LTI ar r ays of r andom

st at e-space models.

Generating LTI Arrays Using rss

A convenient way t o gener at e ar r ays of st at e-space models wit h t he same

number of st at es in each model is t o use rss. The synt ax is

rss(N,P,M,sdim1,...,sdimk)

wher e

•N is t he number of st at es of each model in t he LTI ar r ay.

•P is t he number of out put s of each model in t he LTI ar r ay.

•M is t he number of input s of each model in t he LTI ar r ay.

•sdim1,...,sdimk ar e t he lengt hs of t he ar r ay dimensions.

For example, t o cr eat e a 4-by-2 ar r ay of r andom st at e-space models wit h t hr ee

st at es, one out put , and one input , t ype

sys = rss(3,2,1,4,2);

size(sys)

4x2 array of continuous-time state-space models

Each model has 2 outputs, 1 input, and 3 states.

Building LTI Arrays Using for Loops

Consider t he following second-or der SISO t r ansfer funct ion t hat depends on

t wo par amet er s, and

.

ζ ω

H s ( )

ω

2

s

2

2ζωs ω

2

+ +

--------------------------------------- =

Building LTI Arrays

4-13

Suppose, based on measur ed input and out put dat a, you est imat e confidence

int er vals , and for each of t he par amet er s, and . All of t he

possible combinat ions of t he confidence limit s for t hese model par amet er

values give r ise t o a set of four SISO models.

Figure 4-6: Four LTI Models Depending on Two Parameters

You can ar r ange t hese four models in a 2-by-2 ar r ay of SISO t r ansfer funct ions

called H.

Figure 4-7: The LTI Array H

Her e, for , r epr esent s t he t r ansfer funct ion

cor r esponding t o t he par amet er values and .

ω

1

ω

2

[ , ] ζ

1

ζ

2

[ , ] ω ζ

H

11

s ( )

ω

1

2

s

2

2ζ

1

ω

1

s ω

1

2

+ +

--------------------------------------------- =

H

21

s ( )

ω

2

2

s

2

2ζ

1

ω

2

s ω

2

2

+ +

--------------------------------------------- = H

22

s ( )

ω

2

2

s

2

2ζ

2

ω

2

s ω

2

2

+ +

--------------------------------------------- =

H

12

s ( )

ω

1

2

s

2

2ζ

2

ω

1

s ω

1

2

+ +

--------------------------------------------- =

ω

1

ω

2

ζ

1

ζ

2

H(:,:,1,1) H(:,:,1,2)

H(:,:,2,1)

H(:,:,2,2)

ω

1

ω

2

ζ

2

ζ

1

Each entry of this 2-by-2 array is

a SISO transfer function model.

i , j 1 2 , { } ∈ H(:,:,i,j)

ω

j

2

s

2

2ζ

i

ω

j

s ω

j

2

+ +

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

ζ ζ

i

= ω ω

j

=

4 Arrays of LTI Models

4-14

The fir st t wo colon indices ( ) select all I/O channels fr om t he I/O dimensions

of H. The t hir d index of H r efer s t o t he fir st ar r ay dimension ( ), while t he four t h

index is for t he second ar r ay dimension ( ).

Suppose t he limit s of t he r anges of values for and ar e [0.66,0.76] and

[1.2,1.5], r espect ively. Ent er t hese at t he command line.

zeta = [0.66,0.75];

w = [1.2,1.5];

Since t he four models have t he same par amet r ic st r uct ur e, it ’s convenient t o

use t wo nest ed for loops t o const r uct t he LTI ar r ay.

for i = 1:2

for j = 1:2

H(:,:,i,j) = tf(w(j)^2,[1 2*zeta(i)*w(j) w(j)^2]);

end

end

H now cont ains t he four models in a 2-by-2 ar r ay. For example, t o display t he

t r ansfer funct ion in t he (1,2) posit ion of t he ar r ay, t ype

H(:,:,1,2)

Transfer function:

2.25

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

s^2 + 1.98 s + 2.25

:

ζ

ω

ζ ω

Building LTI Arrays

4-15

For t he pur poses of efficient comput at ion, you can init ialize an LTI ar r ay t o

zer o, and t hen r eassign t he ent ir e ar r ay t o t he values you want t o specify. The

gener al synt ax for zer o assignment of LTI ar r ays is

To init ialize H in t he above example t o zer o, t ype

H = tf(zeros(1,1,2,2));

befor e you implement t he nest ed for loops.

Building LTI Arrays Using the stack Function

Anot her way t o build LTI ar r ays is using t he funct ion stack. This funct ion

oper at es on single LTI models as well as LTI ar r ays. It concat enat es a list of

LTI ar r ays or single LTI models only along t he ar r ay dimension. The gener al

synt ax for stack is

stack(Arraydim,sys1,sys2...)

wher e

•Arraydim is t he ar r ay dimension along which t o concat enat e t he LTI models

or ar r ays.

•sys1, sys2, ... ar e t he LTI models or LTI ar r ays t o be concat enat ed.

Lengths of the array dimensions Lengths of the output/input dimensions

The maximum number of states in any model in the LTI array

sys = tf(zeros(Ny,Nu,S1,...,SK))

sys = zpk(zeros(Ny,Nu,S1,...,SK))

sys = ss(zeros(Ny,Nu,S1,...,SK,Nx))

sys = frd(zeros(Ny,Nu,Nf,S1,...,SK))

The number of frequency vectors in the FRD

4 Arrays of LTI Models

4-16

When you concat enat e sever al models or LTI ar r ays along t he jt h ar r ay

dimension, such as in

stack(j,sys1,sys2,...,sysn)

•The lengt hs of t he I/O dimensions of sys1,...,sysn must all mat ch.

•The lengt hs of all but t he jt h ar r ay dimension of sys1,...,sysn must mat ch.

For example, if t wo TF models sys1 and sys2 have t he same number of input s

and out put s,

sys = stack(1,sys1,sys2)

concat enat es t hem int o a 2-by-1 ar r ay of models.

Note:

•stack only concat enat es along an ar r ay dimension, not an I/O dimension.

•To concat enat e LTI models or LTI ar r ays along an input or out put

dimension, use t he br acket not at ion ([,] [;]). See “Model Int er connect ion

Funct ions” on page 3-16 for mor e infor mat ion on t he use of br acket not at ion

t o concat enat e models. See also “Special Cases for Oper at ions on LTI Ar r ays”

on page 4-27 for some examples of t his t ype of concat enat ion of LTI ar r ays.

Her e’s an example of how t o build t he LTI ar r ay H using t he funct ion stack.

% Set up the parameter vectors.

zeta = [0.66,0.75];

w = [1.2,1.5];

% Specify the four individual models with those parameters.

%

H11 = tf(w(1)^2,[1 2*zeta(1)*w(1) w(1)^2]);

H12 = tf(w(2)^2,[1 2*zeta(1)*w(2) w(2)^2]);

H21 = tf(w(1)^2,[1 2*zeta(2)*w(1) w(1)^2]);

H22 = tf(w(2)^2,[1 2*zeta(2)*w(2) w(2)^2]);

Building LTI Arrays

4-17

% Set up the LTI array using stack.

COL1 = stack(1,H11,H21); % The first column of the 2-by-2 array

COL2 = stack(1,H12,H22); % The second column of the 2-by-2 array

H = stack(2, COL1, COL2); % Concatenate the two columns of models.

Not ice t hat t his r esult is ver y differ ent fr om t he single MIMO LTI model

r et ur ned by

H = [H11,H12;H21,H22];

Building LTI Arrays Using tf, zpk, ss, and frd

You can also build LTI ar r ays using t he tf, zpk, ss, and frd const r uct or s. You

do t his by using mult idimensional ar r ays in t he input ar gument s for t hese

funct ions.

Specifying Arrays of TF models tf

For TF models, use

sys = tf(num,den)

wher e

•Bot h num and den ar e mult idimensional cell ar r ays t he same size as sys (see

“size and ndims” on page 4-9).

•sys(i,j,n1,...,nK) is t he (i, j) ent r y of t he t r ansfer mat r ix for t he model

locat ed in t he posit ion of t he ar r ay.

•num(i,j,n1,...,nK) is a r ow vect or r epr esent ing t he numer at or polynomial

of sys(i,j,n1,...,nK).

•den(i,j,n1,...,nK) is a r ow vect or r epr esent ing denominat or polynomial

of sys(i,j,n1,...,nK).

See “MIMO Tr ansfer Funct ion Models” on page 2-10 for r elat ed infor mat ion on

t he specificat ion of single TF models.

Specifying Arrays of ZPK Models Using zpk

For ZPK models, use

sys = zpk(zeros,poles,gains)

n

1

… n

K

, , ( )

4 Arrays of LTI Models

4-18

wher e

•Bot h zeros and poles ar e mult idimensional cell ar r ays whose cell ent r ies

cont ain t he vect or s of zer os and poles for each I/O pair of each model in t he

LTI ar r ay.

•gains is a mult idimensional ar r ay cont aining t he scalar gains for each I/O

pair of each model in t he ar r ay.

•The dimensions (and t heir lengt hs) of zeros, poles, and gains, det er mine

t hose of t he LTI ar r ay, sys.

Specifying Arrays of SS Models Using ss

To specify ar r ays of SS models, use

sys = ss(a,b,c,d)

wher e a, b, c, and d ar e r eal-valued mult idimensional ar r ays of appr opr iat e

dimensions. All models in t he r esult ing ar r ay of SS models have t he same

number of st at es, out put s, and input s.

Note: You cannot use t he ss const r uct or t o build an ar r ay of st at e-space

models wit h differ ent number s of st at es. Use stack t o build such LTI ar r ays.

The Size of LTI Array Data for SS Models

The size of t he model dat a for ar r ays of st at e-space models is summar ized in

t he following t able.

Data Size (Data)

a

b

c

d

N

s

N

s

S

1

S

2

…S

K

N

s

N

u

S

1

S

2

…S

K

N

y

N

s

S

1

S

2

…S

K

N

y

N

u

S

1

S

2

…S

K

Building LTI Arrays

4-19

wher e

• is t he maximum of t he number of st at es in each model in t he ar r ay.

• is t he number of input s in each model.

• is t he number of out put s in each model.

• ar e t he lengt hs of t he ar r ay dimensions.

Specifying Arrays of FRD Models Using frd

To specify a K-dimensional ar r ay of p-out put , m-input FRD models for which

ar e t he lengt hs of t he ar r ay dimensions, use

sys = frd(response,frequency,units)

wher e

•frequency is a r eal vect or of n fr equency dat a point s common t o all FRD

models in t he LTI ar r ay.

•response is a p-by-m-by-n-by- -by- -by- complex-valued

mult idimensional ar r ay.

•units is t he opt ional st r ing specifying 'rad/s' or 'Hz'.

Not e t hat for specifying an LTI ar r ay of SISO FRD models, response can also

be a mult idimensional ar r ay of 1-by-n mat r ices whose r emaining dimensions

det er mine t he ar r ay dimensions of t he FRD.

N

s

N

u

N

y

S

1

S

2

… S

K

, , ,

S

1

S

2

… S

K

, , ,

S

1

… S

K

4 Arrays of LTI Models

4-20

Indexing Into LTI Arrays

You can index int o LTI ar r ays in much t he same way as you would for

mult idimensional ar r ays t o:

•Access models

•Ext r act subsyst ems

•Reassign par t s of an LTI ar r ay

•Delet e par t s of an LTI ar r ay

When you index int o an LTI ar r ay sys, t he indices should be or ganized

accor ding t o t he following for mat

wher e

•Outputs ar e indices t hat select out put channels.

•Inputs ar e indices t hat select input channels.

• ar e indices int o t he ar r ay dimensions t hat select one model or a

subset of models in t he LTI ar r ay.

Note on Indexing into LTI Arrays of FRD models: For FRD models, t he

ar r ay indices can be followed by t he keywor d 'frequency' and some

expr ession select ing a subset of t he fr equency point s as in

sys (outputs, inputs, n1,...,nk, 'frequency', SelectedFreqs)

See “Refer encing FRD Models Thr ough Fr equencies” on page 3-7 for det ails on

fr equency point select ion in FRD models.

Accessing Particular Models in an LTI Array

To access any given model in an LTI ar r ay:

•Use colon ar gument s (:,:) for t he fir st t wo indices t o select all I/O channels.

•The r emaining indices specify t he model coor dinat es wit hin t he ar r ay.

sys(Outputs, Inputs, ) n

1

… n

K

, ,

n

1

… n

K

, ,

Indexing Into LTI Arrays

4-21

For example, if sys is a 5-by-2 ar r ay of st at e-space models defined by

sys = rss(4,3,2,5,2);

you can access (and display) t he model locat ed in t he (3,2) posit ion of t he ar r ay

sys by t yping

sys(:,:,3,2)

If sys is a 5-by-2 ar r ay of 3-out put , 2-input FRD models, wit h fr equency vect or

[1,2,3,4,5], t hen you can access t he r esponse dat a cor r esponding t o t he

middle fr equency (3 r ad/s), of t he model in t he (3,1) posit ion by t yping

sys(:,:,3,1,'frequency',3.0)

To access all fr equencies of t his model in t he ar r ay, you can simply t ype

sys(:,:,3,1)

Single Index Referencing of Array Dimensions

You can also access models using single index r efer encing of t he ar r ay

dimensions.

For example, in t he 5-by-2 LTI ar r ay sys above, you can also access t he model

locat ed in t he (3,2) posit ion by t yping

sys(:,:,8)

since t his model is in t he eight h posit ion if you wer e t o list t he 10 models in t he

ar r ay by successively scanning t hr ough it s ent r ies along each of it s columns.

For mor e infor mat ion on single index r efer encing, see t he “Advanced Indexing”

sect ion of Chapt er 10, “M-File Pr ogr amming” in Using MATLAB.

Extracting LTI Arrays of Subsystems

To select a par t icular subset of I/O channels fr om all t he models in an LTI

ar r ay, use t he synt ax descr ibed in “Ext r act ing and Modifying Subsyst ems” on

page 3-5. For example,

sys = rss(4,3,2,5,2);

A = sys(1, [1 2])

or equivalent ly,

A = sys(1,[1 2],:,:)

4 Arrays of LTI Models

4-22

select s t he fir st t wo input channels, and t he fir st out put channel in each model

of t he LTI ar r ay A, and r et ur ns t he r esult ing 5-by-2 ar r ay of one-out put ,

t wo-input subsyst ems.

You can also combine model select ion wit h I/O select ion wit hin an LTI ar r ay.

For example, t o access bot h:

•The st at e-space model in t he (3,2) ar r ay posit ion

•Only t he por t ion of t hat model r elat ing t he second input t o t he fir st out put

t ype

sys(1,2,3,2)

To access t he subsyst em fr om all input s t o t he fir st t wo out put channels of t his

same ar r ay ent r y, t ype

sys(1:2,:,3,2)

Reassigning Parts of an LTI Array

You can r eassign ent ir e models or por t ions of models in an LTI ar r ay. For

example,

sys = rss(4,3,2,5,2); % 5X2 array of state-space models

H = rss(4,1,1,5,2); % 5X2 array of SISO models

sys(1,2) = H

r eassigns t he subsyst em fr om input t wo t o out put one, for all models in t he LTI

ar r ay sys. This SISO subsyst em of each model in t he LTI ar r ay is r eplaced

wit h t he LTI ar r ay H of SISO models. This one-line assignment command is

equivalent t o t he following 10-st ep nest ed for loop.

for k = 1:5

for j = 1:2

sys(1,2,k,j) = H(:,:,k,j);

end

end

Not ice t hat you don’t have t o use t he ar r ay dimensions wit h t his assignment .

This is because I/O select ion applies t o all models in t he ar r ay when t he ar r ay

indices ar e omit t ed.

Indexing Into LTI Arrays

4-23

Similar ly, t he commands

sys(:,:,3,2) = sys(:,:,4,1);

sys(1,2,3,2) = 0;

r eassign t he ent ir e model in t he (3,2) posit ion of t he LTI ar r ay sys and t he (1,2)

subsyst em of t his model, r espect ively.

LTI Arrays of SS Models with Differing Numbers of States

You must use an ent ir e LTI model for r eassignment if you have an LTI ar r ay

sys of st at e-space models for which:

•The number s of st at es in each model in sys is not const ant .

•You want t o change t he dimensions of t he a, b, and c mat r ices in one model

as you r eassign it s a, b, and c pr oper t ies.

For example, if

sys = ss(stack(1,tf(1,[1 2 1]),tf(1,[1 1])));

t hen t he model sys(:,:,1) is of or der 2, while sys(:,:,2) is of or der 1. To

r eassign t he a, b, and c pr oper t ies of sys(:,:,1) so t hat t he st at e dimension of

t he new model is not 2, you must make t he ent ir e model assignment at once.

You can do t his as follows.

sys(:,:,1) = sys2

wher e sys2 r epr esent s an LTI model for which size(sys2,'order') is not 2.

Deleting Parts of an LTI Array

You can use indexing t o delet e any par t of an LTI ar r ay by r eassigning it t o be

empt y ([]). For inst ance,

sys = rss(4,3,2,5,2);

sys(1,:) = [];

size(sys)

5x2 array of continuous-time state-space models

Each model has 2 outputs, 2 inputs, and 4 states.

delet es t he fir st out put channel fr om ever y model of t his LTI ar r ay.

4 Arrays of LTI Models

4-24

Similar ly,

sys(:,:,[3 4],:) = []

delet es t he t hir d and four t h r ows of t his t wo-dimensional ar r ay of models.

Operations on LTI Arrays

4-25

Operations on LTI Arrays

Using LTI ar r ays, you can apply almost all of t he basic model oper at ions t hat

wor k on single LTI models t o ent ir e set s of models at once. These basic

oper at ions, discussed in Chapt er 3, “Oper at ions on LTI Models,” include:

•The ar it hmet ic oper at ions: +, –, *, /,\,',.'

•The model int er connect ion funct ions: concat enat ion along I/O dimensions

([,], [;]), feedback, append, series, parallel, and lft

When you apply any of t hese oper at ions t o t wo (or mor e) LTI ar r ays (for

example, sys1 and sys2), t he oper at ion is implement ed on a model-by-model

basis. Ther efor e, t he kt h model of t he r esult ing LTI ar r ay is der ived fr om t he

applicat ion of t he given oper at ion t o t he kt h model of sys1 and t he kt h model

of sys2.

For example, if sys1 and sys2 ar e t wo LTI ar r ays and

sys = op(sys1,sys2)

t hen t he kt h model in t he r esult ing LTI ar r ay sys is obt ained by adding t he kt h

models in sys1 t o t he kt h model in sys2

sys(:,:,k) = sys1(:,:,k) + sys2(:,:,k)

You can also apply any of t he r esponse plot t ing funct ions such as step, bode,

and nyquist descr ibed in Chapt er 5, “Model Analysis Tools,” t o LTI ar r ays.

These plot t ing funct ions ar e also applied on a model by model basis. See “The

Right -Click Menu for LTI Ar r ays” on page 6-28 for infor mat ion on using t he

model select or for LTI ar r ays on r esponse plot s.

4 Arrays of LTI Models

4-26

Example: Addition of Two LTI Arrays

The following diagr am illust r at es t he addit ion of t wo 3-by-1 LTI ar r ays

sys1+sys2.

Figure 4-8: The Addition of Two LTI Arrays

The summat ion of t hese LTI ar r ays

sys = sys1+sys2

is equivalent t o t he following model-by-model summat ion.

for k = 1:3

sys(:,:,k)=sys1(:,:,k) + sys2(:,:,k)

end

2s 6.5 +

s

2

6.5s 9 + +

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

1

s 4.5 +

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

1

s 2.5 +

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

sys2

sys1

+ =

sys

sys1(:,:,3)

sys1(:,:,2)

sys2(:,:,3) sys(:,:,3)

sys(:,:,2)

2. 1

s 4 +

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

sys2(:,:,2)

2.5s 8.25 +

s

2

6.8s 11.31 + +

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

sys(:,:,1)

=

=

1.5

s 3.9 +

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

sys2(:,:,1)

+

+

+

1

s 2.9 +

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

sys1(:,:,1)

1

s 2 +

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

3.15 9.25 +

s

2

6.5s 10 + +

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

=

Operations on LTI Arrays

4-27

Not e t hat :

•Each model in sys1 and sys2 must have t he same number of input s and

out put s. This is r equir ed for t he addit ion of t wo LTI ar r ays.

•The lengt hs of t he ar r ay dimensions of sys1 and sys2 must mat ch.

Dimension Requirements

In gener al, when you apply any of t hese basic oper at ions t o t wo or mor e LTI

ar r ays:

•The I/O dimensions of each of t he LTI ar r ays must be compat ible wit h t he

r equir ement s of t he oper at ion.

•The lengt hs of ar r ay dimensions must mat ch.

The I/O dimensions of each model in t he r esult ing LTI ar r ay ar e det er mined by

t he oper at ion being per for med. See Chapt er 3, “Oper at ions on LTI Models,” for

r equir ement s on t he I/O dimensions for t he var ious oper at ions.

For example, if sys1 and sys2 ar e bot h 1-by-3 ar r ays of LTI models wit h t wo

input s and t wo out put s, and sys3 is a 1-by-3 ar r ay of LTI models wit h t wo

out put s and 1 input , t hen

sys1 + sys2

is an LTI ar r ay wit h t he same dimensions as sys1 and sys2.

sys1 * sys3

is a 1-by-3 ar r ay of LTI models wit h t wo out put s and one input , and

[sys1,sys3]

is a 1-by-3 ar r ay of LTI models wit h t wo out put s and t hr ee input s.

Special Cases for Operations on LTI Arrays

Ther e ar e some special cases in applying oper at ions t o LTI ar r ays.

Consider applying any binar y oper at ion called op (such as +, –, or *) t o an LTI

ar r ay sys1

sys = op(sys1,sys2)

4 Arrays of LTI Models

4-28

wher e sys, t he r esult of t he oper at ion, is an LTI ar r ay wit h t he same ar r ay

dimensions as sys1. You can use shor t cut s for coding sys = op(sys1,sys2) in

t he following cases:

•For oper at ions t hat apply t o LTI ar r ays, sys2 does not have t o be an ar r ay.

It can be a single LTI model (or a gain mat r ix) whose I/O dimensions sat isfy

t he compat ibilit y r equir ement s for op (wit h t hose of each of t he models in

sys1). In t his case, op applies sys2 t o each model in sys1, and t he kt h model

in sys sat isfies

sys(:,:,k) = op(sys1(:,:,k),sys2)

•For ar it hmet ic oper at ions, such as +, *, /, and \, sys2 can be eit her a single

SISO model, or an LTI ar r ay of SISO models, even when sys1 is an LTI ar r ay

of MIMO models. This special case r elies on MATLAB’s scalar expansion

capabilit ies for ar it hmet ic oper at ions.

- When sys2 is a single SISO LTI model (or a scalar gain), op applies sys2

t o sys1 on an ent r y-by-ent r y basis. The ijt h ent r y in t he kt h model in sys

sat isfies

sys(i,j,k) = op(sys1(i,j,k),sys2)

- When sys2 is an LTI ar r ay of SISO models (or a mult idimensional ar r ay

of scalar gains), op applies sys2 t o sys1 on an ent r y-by-ent r y basis for each

model in sys.

sys(i,j,k) = op(sys1(i,j,k),sys2(:,:,k))

Examples of Operations on LTI Arrays with Single LTI Models

Suppose you want t o cr eat e an LTI ar r ay cont aining t hr ee models, wher e, for

in t he set , each model has t he for m τ 1.1 1.2 1.3 , , { } H

τ

s ( )

H

τ

s ( )

1

s τ +

----------- 0

1 –

1

s

---

=

Operations on LTI Arrays

4-29

You can do t his efficient ly by fir st set t ing up an LTI ar r ay h cont aining t he

SISO models and t hen using concat enat ion t o for m t he LTI ar r ay H of

MIMO LTI models , . To do t his, t ype

tau = [1.1 1.2 1.3];

for i=1:3 % Form LTI array h of SISO models.

h(:,:,i)=tf(1,[1 tau]);

end

H = [h 0; –1 tf(1,[1 0])]; %Concatenation: array h & single models

size(H)

3x1 array of continuous-time transfer functions

Each transfer function has 2 output(s) and 2 input(s).

Similar ly, you can use append t o per for m t he diagonal appending of each model

in t he SISO LTI ar r ay h wit h a fixed single (SISO or MIMO) LTI model.

S = append(h,tf(1,[1 3])); % Append a single model to h.

specifies an LTI ar r ay S in which each model has t he for m

You can also combine an LTI ar r ay of MIMO models and a single MIMO LTI

model using ar it hmet ic oper at ions. For example, if h is t he LTI ar r ay of t hr ee

SISO models defined above,

[h,h] + [tf(1,[1 0]);tf(1,[1 5])]

adds t he single one-out put , t wo-input LTI model [1/s 1/(s + 5)] t o ever y

model in t he 3-by-1 LTI ar r ay of one-out put , t wo-input models [h,h]. The

r esult is a new 3-by-2 ar r ay of models.

Examples: Arithmetic Operations on LTI Arrays and SISO Models

Using t he LTI ar r ay of one-out put , t wo-input st at e-space models [h,h],

defined in t he pr evious example,

tf(1,[1 3]) + [h,h]

1 s τ + ( ) ⁄

H

τ

s ( ) τ 1.1 1.2 1.3 , , { } ∈

S

τ

s ( )

1

s τ +

----------- 0

0

1

s 3 +

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

=

4 Arrays of LTI Models

4-30

adds a single SISO t r ansfer funct ion model t o each ent r y in each model of t he

LTI ar r ay of MIMO models [h,h].

Finally,

G = rand(1,1,3,1);

sys = G + [h,h]

adds t he ar r ay of scalar s t o each ent r y of each MIMO model in t he LTI ar r ay

[h,h] on a model-by-model basis. This last command is equivalent t o t he

following for loop.

hh = [h,h];

for k = 1:3

sys(:,:,k) = G(1,1,k) + hh(:,:,k);

end

Other Operations on LTI Arrays

You can also apply t he analysis funct ions, such as bode, nyquist, and step, t o

LTI ar r ays. See Chapt er 5, “Model Analysis Tools,” for mor e infor mat ion on

t hese funct ions.

5

Model Analysis Tools

General Model Characteri st i cs . . . . . . . . . . . 5-2

Model Dynami cs . . . . . . . . . . . . . . . . . . 5-4

St ate -Space Realizati ons . . . . . . . . . . . . . . 5-7

Ti me and Frequency Response . . . . . . . . . . . 5-9

Time Responses . . . . . . . . . . . . . . . . . . . 5-9

Fr equency Response . . . . . . . . . . . . . . . . . 5-11

Plot t ing and Compar ing Mult iple Syst ems . . . . . . . . 5-13

Cust omizing t he Plot Display . . . . . . . . . . . . . . 5-17

Mode l Orde r Re ducti on . . . . . . . . . . . . . . . 5-20

5 Model Analysis Tools

5-2

General Model Characteristics

Gener al model char act er ist ics include t he model t ype, I/O dimensions, and

cont inuous or discr et e nat ur e. Relat ed commands ar e list ed in t he t able below.

These commands oper at e on cont inuous- or discr et e-t ime LTI models or ar r ays

of LTI models of any t ype.

General Model Characteristics Commands

class Display model t ype ('tf', 'zpk', 'ss', or 'frd').

hasdelay Test t r ue if LTI model has any t ype of delay.

isa Test t r ue if LTI model is of specified class.

isct Test t r ue for cont inuous-t ime models.

isdt Test t r ue for discr et e-t ime models.

isempty Test t r ue for empt y LTI models.

isproper Test t r ue for pr oper LTI models.

issiso Test t r ue for SISO models.

ndims Display t he number of model/ar r ay dimensions.

reshape Change t he shape of an LTI ar r ay.

size Out put /input /ar r ay dimensions. Used wit h special

synt ax, size also r et ur ns t he number of st at e

dimensions for st at e-space models, and t he number

of fr equencies in an FRD model.

General Model Characteristics

5-3

This example illust r at es t he use of some of t hese commands. See t he r elat ed

r efer ence pages for mor e det ails.

H = tf({1 [1 –1]},{[1 0.1] [1 2 10]})

Transfer function from input 1 to output:

1

-------

s + 0.1

Transfer function from input 2 to output:

s – 1

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

s^2 + 2 s + 10

class(H)

ans =

tf

size(H)

Transfer function with 2 input(s) and 1 output(s).

[ny,nu] = size(H)% Note: ny = number of outputs

ny =

1

nu =

2

isct(H)% Is this system continuous?

ans =

1

isdt(H)% Is this system discrete?

ans =

0

5 Model Analysis Tools

5-4

Model Dynamics

The Cont r ol Syst em Toolbox offer s commands t o det er mine t he syst em poles,

zer os, DC gain, nor ms, et c. You can apply t hese commands t o single LTI models

or LTI ar r ays. The following t able gives an over view of t hese commands.

Wit h t he except ion of norm, t hese commands ar e not suppor t ed for FRD

models.

Model Dynamics

covar Covar iance of r esponse t o whit e noise.

damp Nat ur al fr equency and damping of syst em poles.

dcgain Low-fr equency (DC) gain.

dsort Sor t discr et e-t ime poles by magnit ude.

esort Sor t cont inuous-t ime poles by r eal par t .

norm Nor ms of LTI syst ems ( and ).

pole, eig Syst em poles.

pzmap Pole/zer o map.

zero Syst em t r ansmission zer os.

H

2

L

∞

L

∞

Model Dynamics

5-5

Her e is an example of model analysis using some of t hese commands.

h = tf([4 8.4 30.8 60],[1 4.12 17.4 30.8 60])

Transfer function:

4 s^3 + 8.4 s^2 + 30.8 s + 60

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

s^4 + 4.12 s^3 + 17.4 s^2 + 30.8 s + 60

pole(h)

ans =

–1.7971 + 2.2137i

–1.7971 – 2.2137i

–0.2629 + 2.7039i

–0.2629 – 2.7039i

zero(h)

ans =

–0.0500 + 2.7382i

–0.0500 – 2.7382i

–2.0000

dcgain(h)

ans =

1

[ninf,fpeak] = norm(h,inf)% peak gain of freq. response

ninf =

1.3402 % peak gain

fpeak =

1.8537 % frequency where gain peaks

5 Model Analysis Tools

5-6

These funct ions also oper at e on LTI ar r ays and r et ur n ar r ays. For example, t he

poles of a t hr ee dimensional LTI ar r ay sysarray ar e obt ained as follows.

sysarray = tf(rss(2,1,1,3))

Model sysarray(:,:,1,1)

=======================

Transfer function:

-0.6201 s - 1.905

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

s^2 + 5.672 s + 7.405

Model sysarray(:,:,2,1)

=======================

Transfer function:

0.4282 s^2 + 0.3706 s + 0.04264

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

s^2 + 1.056 s + 0.1719

Model sysarray(:,:,3,1)

=======================

Transfer function:

0.621 s + 0.7567

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

s^2 + 2.942 s + 2.113

3x1 array of continuous-time transfer functions.

pole(sysarray)

ans(:,:,1) =

-3.6337

-2.0379

ans(:,:,2) =

-0.8549

-0.2011

ans(:,:,3) =

-1.6968

-1.2452

State-Space Realizations

5-7

State-Space Realizations

The following funct ions ar e useful t o analyze, per for m st at e coor dinat e

t r ansfor mat ions on, and der ive canonical st at e-space r ealizat ions for single

st at e-space LTI models or LTI ar r ays of st at e-space models.

The funct ion ssbal uses a simple diagonal similar it y t r ansfor mat ion

t o balance t he st at e-space dat a . This is accomplished by r educing

t he nor m of t he mat r ix.

Such balancing usually impr oves t he numer ical condit ioning of subsequent

st at e-space comput at ions. Not e t hat conver sions t o st at e-space using ss

pr oduce balanced r ealizat ions of t r ansfer funct ions and zer o-pole-gain models.

By cont r ast , t he canonical r ealizat ions pr oduced by canon, ctrbf, or obsvf ar e

oft en badly scaled, sensit ive t o per t ur bat ions of t he dat a, and poor ly suit ed for

State-Space Realizations

canon Canonical st at e-space r ealizat ions.

ctrb Cont r ollabilit y mat r ix.

ctrbf Cont r ollabilit y st air case for m.

gram Cont r ollabilit y and obser vabilit y gr amians.

obsv Obser vabilit y mat r ix.

obsvf Obser vabilit y st air case for m.

ss2ss St at e coor dinat e t r ansfor mat ion.

ssbal Diagonal balancing of st at e-space r ealizat ions.

A B C , , ( ) T

1 –

AT T

1 –

B CT , , ( ) →

A B C , , ( )

T

1 –

AT T

1 –

B

CT 0

5 Model Analysis Tools

5-8

st at e-space comput at ions. Consequent ly, it is wise t o use t hem only for analysis

pur poses and not in cont r ol design algor it hms.

Time and Frequency Response

5-9

Time and Frequency Response

The Cont r ol Syst em Toolbox cont ains a set of commands t hat pr ovide t he basic

t ime and fr equency domain analysis t ools r equir ed for cont r ol syst em

engineer ing. These commands apply t o any kind of LTI model (TF, ZPK, or SS,

cont inuous or discr et e, SISO or MIMO). You can only apply t he fr equency

domain analysis t ools FRDs. The LTI Viewer pr ovides an int egr at ed gr aphical

user int er face (GUI) t o analyze and compar e LTI models (see Chapt er 6, “The

LTI Viewer ” for det ails).

Time Responses

Time r esponses invest igat e t he t ime-domain t r ansient behavior of LTI models

for par t icular classes of input s and dist ur bances. You can det er mine such

syst em char act er ist ics as r ise t ime, set t ling t ime, over shoot , and st eady-st at e

er r or fr om t he t ime r esponse. The Cont r ol Syst em Toolbox pr ovides funct ions

for st ep r esponse, impulse r esponse, init ial condit ion r esponse, and gener al

linear simulat ions. You can apply t hese funct ions t o single TF, SS, or ZPK

models or ar r ays of t hese t ypes of models. Not e t hat you can simulat e t he

r esponse t o whit e noise input s using lsim and t he funct ion rand (see Using

MATLAB t o gener at e r andom input vect or s.

The funct ions step, impulse, and initial aut omat ically gener at e an

appr opr iat e simulat ion hor izon for t he t ime r esponse plot s. Their synt ax is

step(sys)

impulse(sys)

initial(sys,x0) % x0 = initial state vector

Time Response

impulse Impulse r esponse.

initial Init ial condit ion r esponse.

gensig Input signal gener at or.

lsim Simulat ion of r esponse t o ar bit r ar y input s.

step St ep r esponse.

5 Model Analysis Tools

5-10

wher e sys is any cont inuous or discr et e LTI model or LTI ar r ay. For MIMO

models, t hese commands pr oduce an ar r ay of plot s wit h one plot per I/O

channel (or per out put for initial and lsim). For example,

h = [tf(10,[1 2 10]) , tf(1,[1 1])]

step(h)

pr oduces t he following plot .

The simulat ion hor izon is aut omat ically det er mined based on t he model

dynamics. You can over r ide t his aut omat ic mode by specifying a final t ime

step(sys,10) % simulates from 0 to 10 seconds

or a vect or of evenly spaced t ime samples.

t = 0:0.01:10 % time samples spaced every 0.01 second

step(sys,t)

Time and Frequency Response

5-11

Note: When specifying a t ime vect or t = [0:dt:tf], r emember t he

following const r aint s on t he spacing dt bet ween t ime samples:

•For discr et e syst ems, dt should mat ch t he syst em sample t ime.

•Cont inuous syst ems ar e fir st discr et ized using zer o-or der hold and dt as

sampling per iod, and step simulat es t he r esult ing discr et e syst em. As a

r esult , you should pick dt small enough t o capt ur e t he main feat ur es of t he

cont inuous t r ansient r esponse.

The synt ax step(sys) aut omat ically t akes t hese issues int o account .

Finally, t he funct ion lsim simulat es t he r esponse t o mor e gener al classes of

input s. For example,

t = 0:0.01:10

u = sin(t)

lsim(sys,u,t)

simulat es t he zer o-init ial condit ion r esponse of t he LTI syst em sys t o a sine

wave for a dur at ion of 10 seconds.

Note: You can also implement sever al plot t ing opt ions by using t he

r ight -click menus accessible fr om t he (whit e) plot r egion of all t ime and

fr equency plot s. These opt ions ar e list ed on t he menu. To lear n mor e about t he

r ight -click menus on plot s, see “The Right -Click Menus” on page 6-18

Frequency Response

The Cont r ol Syst em Toolbox pr ovides r esponse-plot t ing funct ions for t he

following fr equency domain analysis t ools:

•Bode plot s

•Nichols char t s

•Nyquist plot s

•Singular value plot s

5 Model Analysis Tools

5-12

In addit ion, t he funct ion margin det er mines t he gain and phase mar gins for a

given SISO open-loop model. These funct ions can be applied t o single LTI

models or LTI ar r ays.

As for t ime r esponse funct ions, t he commands

bode(sys)

nichols(sys)

nyquist(sys)

sigma(sys)

handle bot h cont inuous and discr et e models. These funct ions pr oduce a

fr equency r esponse plot for SISO LTI models, and an ar r ay of plot s in t he

MIMO case. The fr equency gr id used t o evaluat e t he r esponse is aut omat ically

select ed based on t he syst em poles and zer os.

The Bode plot pr oduced by bode plot s t he magnit ude of t he fr equency r esponse

in decibels (dB), as 20*log10(abs(response)). Phase is plot t ed in degr ees.

To set t he fr equency r ange explicit ly t o some int er val [wmin,wmax], use t he

synt ax

bode(sys,{wmin , wmax}) % Note the curly braces

Table 5-1: Frequency Response

Function Name Description

bode Comput es t he Bode plot .

evalfr Comput es t he fr equency r esponse at a single

complex fr equency (not for FRD models).

freqresp Comput es t he fr equency r esponse for a set of

fr equencies.

margin Comput es gain and phase mar gins.

ngrid Applies gr id lines t o a Nichols plot .

nichols Comput es t he Nichols plot .

nyquist Comput es t he Nyquist plot .

sigma Comput es t he singular value plot .

Time and Frequency Response

5-13

For example,

bode(sys,{0.1 , 100})

dr aws t he Bode plot bet ween 0.1 and 100 r adians/second. You can also specify

a par t icular vect or of fr equency point s as in

w = logspace(–1,2,100)

bode(sys,w)

The logspace command gener at es a vect or w of logar it hmically spaced

fr equencies st ar t ing at r ad/s and ending at r ad/s. See

t he r efer ence page for linspace for linear ly spaced fr equency vect or s.

Note: In discr et e t ime, t he fr equency r esponse is evaluat ed on t he unit cir cle

and t he not ion of “fr equency” should be under st ood as follows. The upper half

of t he unit cir cle is par amet r ized by

wher e is t he syst em sample t ime and is called t he Nyquist frequency.

The var iable plays t he r ole of cont inuous-t ime fr equency. We use t his

“equivalent fr equency” as an -axis var iable in all discr et e-t ime fr equency

r esponse plot s. In addit ion, t he fr equency r esponse is plot t ed only up t o t he

Nyquist fr equency because it is per iodic wit h per iod (a phenomenon

known as aliasing).

Note: An easy way t o implement t hese r esponse-plot t ing funct ions is

t hr ough t he LTI Viewer. See Chapt er 6, “The LTI Viewer ” for mor e

infor mat ion.

Plotting and Comparing Multiple Systems

The LTI Viewer pr ovides one met hod of plot t ing var ious r esponses for mult iple

models. See Chapt er 6, “The LTI Viewer ” t o see how t o accomplish t his. You can

also use t he command line r esponse-plot t ing funct ions t o plot t he r esponse of

10

1 –

0.1 = 10

2

100 =

z e

j ωT

s

= , 0 ω ω

N

π

T

s

------ = ≤ ≤

T

s

ω

N

ω

x

ω

N

2ω

N

5 Model Analysis Tools

5-14

sever al LTI models on a single plot . To do so, invoke t he cor r esponding

command line funct ion using t he list sys1,..., sysN of models as t he input s.

step(sys1,sys2,...,sysN)

impulse(sys1,sys2,...,sysN)

...

bode(sys1,sys2,...,sysN)

nichols(sys1,sys2,...,sysN)

...

All models in t he ar gument list s of any of t he r esponse plot t ing funct ions

(except for sigma) must have t he same number of input s and out put s. To

differ ent iat e t he plot s easily, you can also specify a dist inct ive color /linest yle/

mar ker for each syst em just as you would wit h t he plot command. For

example,

bode(sys1,’r’,sys2,’y--’,sys3,’gx’)

plot s sys1 wit h solid r ed lines, sys2 wit h yellow dashed lines, and sys3 wit h

gr een x mar ker s.

You can plot r esponses of mult iple models on t he same plot . These models need

not be all cont inuous-t ime or all discr et e-t ime.

Time and Frequency Response

5-15

The following example compar es a cont inuous model wit h it s zer o-or der -hold

discr et izat ion.

sysc = tf(1000,[1 10 1000])

sysd = c2d(sysc,0.2) % ZOH sampled at 0.2 second

step(sysc,'--',sysd,'-') % compare step responses

5 Model Analysis Tools

5-16

bode(sysc,'--',sysd,'-') % compare Bode responses

A compar ison of t he cont inuous and discr et ized r esponses r eveals a dr ast ic

under sampling of t he cont inuous syst em. Specifically, t her e ar e hidden

oscillat ions in t he discr et ized t ime r esponse and aliasing conceals t he

cont inuous-t ime r esonance near 300 r ad/sec.

Time and Frequency Response

5-17

Customizing the Plot Display

You can plot dat a gener at ed by sever al r esponse analysis funct ions applied t o

one or sever al LTI models, as well as your own dat a. Ther e ar e sever al ways

you can cust omize how you display plot s:

•St or e t he t ime or fr equency r esponse dat a in MATLAB ar r ays by invoking

r esponse analysis funct ions such as step, and bode wit h out put ar gument s

[y,t] = step(sys)

[mag,phase,w] = bode(sys)

[re,im,w] = nyquist(sys)

and use t he plot command t o display t he r esult .

•Use t he subplot and hold commands t o plot sever al set s of dat a in a single

figur e window.

•Use t he plot configur at ion menu in t he LTI Viewer for t ime and fr equency

r esponses of LTI models. For mor e infor mat ion, see “Viewer Configur at ion

Window” on page 6-39.

5 Model Analysis Tools

5-18

For example, t he following sequence of commands displays t he Bode plot , st ep

r esponse, pole/zer o map, and some addit ional dat a in a single figur e window.

h = tf([4 8.4 30.8 60],[1 4.12 17.4 30.8 60]);

subplot (121)

bode(h)

subplot(222)

bode(h)

subplot(224)

bode(h)

Time and Frequency Response

5-19

Anot her example is

subplot(221)

bode(h)

subplot(222)

step(h)

subplot(223)

pzmap(h)

subplot(224)

plot(rand(1, 100)) % any data can go here

title('Some noise')

Note: Each of t he plot s gener at ed by r esponse analysis funct ions in t hese

figur es (her e, bode, step, and pzmap) has it s own r ight -click menu (similar t o

t hose in t he LTI viewer. For mor e infor mat ion, see “The Right -Click Menus” on

page 6-18.

5 Model Analysis Tools

5-20

Model Order Reduction

You can der ive r educed-or der models wit h t he following commands.

Use minreal t o delet e uncont r ollable or unobser vable st at e dynamics in

st at e-space models, or cancel pole/zer o pair s in t r ansfer funct ions or

zer o-pole-gain models. Use sminreal t o r emove any st at es fr om a model t hat

don’t affect t he I/O r esponse. For alr eady minimal models, you can fur t her

r educe t he model or der using a combinat ion of balreal and modred. See t he

cor r esponding Refer ence pages for det ails.

Model Order Reduction

balreal Input /out put balancing.

minreal Minimal r ealizat ion or pole/zer o cancellat ion.

modred St at e delet ion in I/O balanced r ealizat ion.

sminreal St r uct ur ally minimal r ealizat ion

6

The LTI Viewer

Introduct i on . . . . . . . . . . . . . . . . . . . . 6-2

Ge tt i ng Started Usi ng t he LTI Vi ewer: An Example . . 6-4

The LTI Vi ewer Me nus . . . . . . . . . . . . . . . 6-15

The Ri ght -Click Menus . . . . . . . . . . . . . . . 6-18

The LTI Vi ewer Tools Menu . . . . . . . . . . . . . 6-39

Si mulink LTI Vi ewer . . . . . . . . . . . . . . . . 6-48

6 The LTI Viewer

6-2

Introduction

The LTI Viewer is a gr aphical user int er face for viewing and manipulat ing t he

r esponse plot s of LTI models.

You can display t he following plot t ypes for LTI models using t he LTI Viewer :

•St ep r esponse (only for TF, SS, or ZPK models)

•Impulse r esponse (only for TF, SS, or ZPK models)

•Bode plot

•Nyquist plot

•Nichols char t

•Singular values of t he fr equency r esponse

•Poles and zer os (only for TF, SS, or ZPK models)

•LTI model r esponse t o a gener al input (only for TF, SS, or ZPK models)

•Init ial st at e LTI r esponse (only for SS models)

The LTI Viewer displays up t o six of t hese differ ent r esponse analysis plot

t ypes simult aneously. You can also analyze t he r esponse plot s of sever al LTI

models at once. However , in or der t o analyze models wit h differ ent number s of

input s and out put s, you must display t hem in separ at e LTI Viewer s.

A special ver sion of t he LTI Viewer can also be used t o analyze Simulink

models. The oper at ion of t he Simulink LTI Viewer is discussed at t he end of

t his chapt er in “Simulink LTI Viewer ” on page 6-48.

Functionality of the LTI Viewer

The basic funct ion of t he LTI Viewer is t o display t he plot s of LTI model

r esponses. Sever al menus ar e included for oper at ions such as impor t ing models

int o t he LTI Viewer or pr int ing r esponse plot s. In addit ion t o t hese dat a

oper at ions, you can manipulat e t he LTI Viewer r esponse plot s in sever al ways,

including:

•Change t he t ype of plot being displayed in each plot r egion of t he LTI Viewer

•Toggle on and off t he r esponse plot s of individual LTI models loaded in t he

LTI Viewer

•Display r esponse plot char act er ist ics for a given plot t ype, such as set t ling

t ime for a st ep r esponse plot

Introduction

6-3

•Zoom in on or out fr om t he individual displayed plot s

•Toggle t he gr id on or off on a plot

•Select which I/O channels t he LTI Viewer displays for MIMO models in each

plot

•For a given plot t ype, select how t he LTI Viewer displays t he I/O channels for

MIMO models

•Select which models of an LTI ar r ay you want displayed in t he LTI Viewer

by indexing int o dimensions or model char act er ist ics

•Cont r ol plot char act er ist ics such as t he r anges for t ime and fr equency used

in var ious t ypes of plot s

•Cont r ol linest yle pr efer ences such as t he color and mar ker for each model

r esponse plot t ed

•Init ialize t he LTI Viewer fr om t he command line t o display mult iple plot

t ypes (e.g., Bode plot and st ep r esponse) simult aneously

•Cont r ol of t he number of r esponse plot r egions t hat appear (one t o six

r egions) in t he LTI Viewer

Many of t hese feat ur es ar e accessed and cont r olled t hr ough plot -specific

r ight -click menus.

6 The LTI Viewer

6-4

Getting Started Using the LTI Viewer: An Example

This sect ion cont ains a br ief int r oduct ion t o t he LTI Viewer t hr ough an

example t hat leads you t hr ough t he following st eps:

1 Load t wo LTI models int o t he LTI Viewer , init ialized wit h t he st ep r esponses

and Bode plot s of bot h models.

2 Use t he r ight -click menu t o display mar ker s for

- The set t ling t ime on t he st ep r esponses

- The peak magnit ude r esponse on t he Bode plot s

3 Use t he mouse t o display t he values of t hese r esponse char act er ist ics on t he

plot s.

4 Impor t a t hir d LTI model t o t he LTI Viewer for compar ison.

5 Use t he r ight -click menu t o zoom in on a plot .

Suppose you have a set of compensat or s you’ve designed t o cont r ol a syst em,

and you want t o compar e t he closed-loop st ep r esponses and Bode plot s. You

can do t his wit h t he LTI Viewer .

A sample set of closed-loop t r ansfer funct ion models ar e included (along wit h

some ot her models) in t he MAT-file LTIexamples.mat. Type

load LTIexamples

In t his example, you analyze t he r esponse plot s of t hese t hr ee t r ansfer funct ion

models.

Gcl1, Gcl2, Gcl3

Transfer function:

4 s^3 + 8.4 s^2 + 30.8 s + 60

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

s^4 + 4.12 s^3 + 17.4 s^2 + 30.8 s + 60

Getting Started Using the LTI Viewer: An Example

6-5

Transfer function:

2 s^3 + 1.2 s^2 + 15.1 s + 7.5

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

s^4 + 2.12 s^3 + 10.2 s^2 + 15.1 s + 7.5

Transfer function:

1.2 s^3 + 1.12 s^2 + 9.1 s + 7.5

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

s^4 + 1.32 s^3 + 10.12 s^2 + 9.1 s + 7.5

Initializing the LTI Viewer with Multiple Plots

For a given LTI model, you can use t he LTI Viewer t o simult aneously display

mult iple r esponse plot t ypes, such as t he Bode plot and t he st ep r esponse. You

can also init ialize t he LTI Viewer t o display t he plot s of sever al differ ent

models at once. The gener al synt ax for init ializing t he LTI Viewer t o plot up t o

six plot t ypes is

ltiview({'type1';'type2';...;'typek'},sys1,...,sysn)

wher e:

•{'type1';'type2';...;'typek'} is a cell ar r ay list ing up t o six st r ings for

t he names of t he plot t ypes ( ).

•sys1, ..., sysn is a list of t he MATLAB wor kspace var iable names for t he

syst ems whose r esponses you want t o init ially display in t he LTI Viewer .

The plot t ype names can be any of t he following.

Plot Type Description

bode Bode plot

impulse Impulse r esponse

initial Init ial st at e r esponse for SS models

lsim LTI model r esponse t o gener al input

nichols Nichols char t

nyquist Nyquist plot

k 6 ≤

6 The LTI Viewer

6-6

Note: When you init ialize t he LTI Viewer wit h lsim or initial, t hese plot

t ypes r equir e some ext r a ar gument s. For mor e infor mat ion on t he synt ax for

calling ltiview, see ltiview on page 11-133.

To load t he t wo models Gcl1, and Gcl2 int o t he LTI Viewer so t hat it displays

t he st ep r esponses and Bode plot s of bot h models, t ype

ltiview({'step';'bode'},Gcl1,Gcl2)

This opens t he following LTI Viewer .

pzmap Plot of poles and zer os

sigma Singular values of t he fr equency r esponse

step St ep r esponse

Plot Type Description

Getting Started Using the LTI Viewer: An Example

6-7

Right-Click Menus: Setting Response Characteristics

To access t he individual r esponse plot cont r ols, use t he r ight -click menus

available fr om any of t he plot r egions displayed. These r ight -click menus var y,

depending on if t he LTI Viewer is displaying t he r esponse plot s of SISO models,

MIMO models, or LTI ar r ays. Some of t he menu it ems ar e also plot t ype

dependent .

For example, suppose you want t o mar k t he set t ling t ime on t he st ep r esponses,

and t he peak magnit ude r esponse on t he Bode plot s. To do t his:

Two response curves

are plotted on each

of the two plot

regions.

Right-click on

either plot region

to see the

response plot

menus.

The File menu has

several items,

including ones that

allow you to import

models and print

plots.

The Tools menu items

allow you to

reconfigure the plot

arrangement and set

general plot and

linestyle preferences

for this open LTI

Viewer.

Plot region for the step response

Plot region for the

Bode plot

Status bar provides

useful information.

6 The LTI Viewer

6-8

1 Right -click anywher e in t he plot r egion of t he st ep r esponse plot s. This opens

t he following menu list in t he plot r egion.

Figure 6-1: The Right-Click Menu for SISO Models

2 Place your mouse point er on t he Characteri sti cs menu it em, and select

Settli ng Ti me wit h your left mouse but t on.

Figure 6-2: The Step Response Characteristics Submenu

3 Right -click anywher e in t he plot r egion of t he Bode plot s t o open a r ight -click

menu.

4 Place your mouse point er on t he Characteri sti cs menu it em.

The submenu it ems of t he Characteri s ti cs menu for t he Bode plot ar e

differ ent t han t hose of t he Characteri sti cs menu for t he st ep r esponse

r ight -click menu.

Figure 6-3: Bode Plot Characteristics Submenu

5 Select Pe ak Res pons e wit h your left mouse but t on.

Getting Started Using the LTI Viewer: An Example

6-9

Your LTI Viewer should now look like t his.

Not ice t hat t her e is one set t ling t ime or peak magnit ude mar ker for each LTI

model displayed in t he LTI Viewer .

Displaying Response Characteristics on a Plot

To display t he values of any plot char act er ist ic mar ked on a plot :

1 Click on t he mar ker

2 Hold t he left or r ight mouse but t on down t o r ead t he values off t he plot .

6 The LTI Viewer

6-10

Not e t hat you can:

•Use eit her t he r ight or t he left mouse but t on when you select a mar ker on a

plot .

•Left -click anywher e on a par t icular plot line t o see t he r esponse values of

t hat plot at t hat point .

•Right -click anywher e on a plot line t o see I/O and model infor mat ion.

Hold the mouse

button down on the

marker to display the

values.

Getting Started Using the LTI Viewer: An Example

6-11

Importing Models

If t he closed-loop models Gcl1 and Gcl2 do not meet your specificat ions, you

may want t o design anot her compensat or at t he command line, and impor t t he

r esult ing closed-loop model Gcl3 for compar ison:

1 Select Import fr om t he Fi le menu. This opens a br owser list ing all of t he LTI

models cur r ent ly available in t he MATLAB wor kspace.

This br owser allows you t o copy LTI models fr om t he MATLAB wor kspace

int o t he LTI Viewer workspace. LTI model var iable names have t o be in t he

LTI Viewer wor kspace befor e you can analyze t he r esponse plot s of t hese

models using t he LTI Viewer .

2 Select Gcl3 fr om t he list of models in t he wor kspace br owser .

3 Select OK.

The LTI Viewer now shows t he st ep r esponse of Gcl3 in addit ion t o t hose of

Gcl1 and Gcl2.

To multiselect individual

models, select one model and

hold down the Control key

while selecting additional

models.

To deselect any selected models, hold down

the control key while you click on the

highlighted model names.

To multiselect a list of several models in a row,

select the first model and hold down the Shift key

while selecting the last model you want in the

list.

6 The LTI Viewer

6-12

Note: A given LTI Viewer can only be used t o analyze models wit h t he same

number of input s and out put s. If you want t o analyze models wit h differ ent

number s of input s or out put s, you must impor t t hese int o separ at e LTI

Viewer s. See “Opening a New LTI Viewer ” on page 6-16 for mor e infor mat ion.

Zooming

Wit h t hr ee models loaded int o t he LTI Viewer , you may want t o zoom in on one

r egion of a given plot , in or der t o inspect t he r esponse behavior in t hat r egion

mor e closely. For example, let ’s zoom in on t he st ep r esponses of t hese t hr ee

models in t he vicinit y of 4.5 seconds on t he t ime axis.

To zoom in on a r egion on any of t he plot s, use t he Zoom menu it em available

fr om t he r ight -click menu:

1 Right -click on a plot r egion (in t his case, t he st ep r esponse) t o open t he

r ight -click menu.

2 Move your mouse point er over t he Zoom menu.

Your menu looks like t his.

3 Select X-Y t o zoom in bot h t he hor izont al and ver t ical dir ect ions.

4 Use your mouse t o cr eat e t he r ect angular r ubber band t hat indicat es t he

zoom r egion:

Select In-X and a horizontal rubber band is

available to select the zoom region.

Select In-Y and a vertical rubber band is

available to select the zoom region.

Select X-Y and a rectangular rubber band is

available to select the zoom region.

Getting Started Using the LTI Viewer: An Example

6-13

a Point your mouse t o any cor ner of t he r ect angle of t he r egion you want t o

zoom in on.

b Left -Click t her e, and hold t he mouse but t on down.

c Dr ag t he mouse point er unt il t he r ect angle cover s t he r egion you want t o

zoom in on.

d Release your mouse.

For t his example, zoom in ar ound t he r egion near 4.5 seconds on t he st ep

r esponse plot .

Your st ep r esponse plot looks like t his as you select t he zoom r egion.

6 The LTI Viewer

6-14

Aft er r eleasing t he mouse on t he zoom r egion, t he LTI Viewer looks like t his.

Not ice t hat you’ve only zoomed on t he st ep r esponse plot ; t he Bode plot r emains

unchanged.

Note: To zoom out, i.e., t o r ever t back t o t he or iginal coor dinat e limit s t hat

wer e in place befor e you zoomed, follow t he st eps for zooming again, only t his

t ime select Out fr om t he Zoom menu.

The LTI Viewer Menus

6-15

The LTI Viewer Menus

The LTI Viewer has t hr ee main menus:

•Fi le

•Tools

•Help

The Fi le menu pr ovides feat ur es per t inent t o br inging dat a in and out of t he

LTI Viewer . The Help pr ovides help on t he LTI Viewer feat ur es. The Fi le and

Help menus ar e cover ed in t his sect ion. The Tools menu allows you t o cont r ol

cer t ain feat ur es common t o all of t he plot s. You can r ead about t he Tools menu

it ems in “The LTI Viewer Tools Menu” on page 6-39.

The File Menu

The Fi le menu gives you t h following opt ions:

•New Vi ewer—Open a new LTI Viewer .

•Import—Br ing in new models int o t he LTI Viewer wor kspace.

•Export—Expor t models t o t he MATLAB wor kspace or t o a disk.

•Dele te Systems —Delet e some or all of t he LTI models in t he LTI Viewer

wor kspace.

•Refres h Syst ems—Updat e t he LTI Viewer wit h any changes you made at

t he MATLAB command line t o models in t he LTI Viewer wor kspace.

•Pri nt—Gener at e a har dcopy of t he LTI model r esponse.

•Pri nt to Fi gure—Send t he LTI Viewer plot s t o a MATLAB figur e window.

•Close Vi ewer—Close an open LTI Viewer .

Det ails on some of t hese menu it ems ar e descr ibed below.

Importing a New Model into the LTI Viewer Workspace

LTI models in t he MATLAB wor kspace can only be viewed by t he LTI Viewer

if t hey ar e in t he LTI Viewer wor kspace. Ther e ar e t wo ways of loading models

int o t he LTI Viewer wor kspace:

•Load t hem int o t he LTI Viewer wor kspace when you open t he LTI Viewer .

•Impor t t hem int o an open LTI Viewer using t he br owser t hat is opened when

you select t he Import menu it em under t he Fi le menu.

6 The LTI Viewer

6-16

For dir ect ions for loading LTI models int o t he LTI Viewer wor kspace when you

open it , see “Init ializing t he LTI Viewer wit h Mult iple Plot s” on page 6-5. For

dir ect ions for impor t ing models int o t he wor kspace of an open LTI Viewer , see

“Impor t ing Models” on page 6-11.

Opening a New LTI Viewer

The New Vi e wer opt ion in t he Fi le menu enables you t o init ialize a new LTI

Viewer . This is t he same as t yping ltiview at t he MATLAB pr ompt . You can

use t his feat ur e t o compar e r esponse plot s of LTI models t hat don’t have t he

same number s of input s and out put s.

Refreshing Systems in the LTI Viewer Workspace

If you modify t he char act er ist ics of an LTI model in t he MATLAB wor kspace,

select Refres h Syst ems in t he Fi le menu t o updat e t he models in t he LTI

Viewer wor kspace wit h t he changes you made.

Printing Response Plots

To pr int your r esponse plot s, go t o t he Fi le menu:

•Choose t he Pri nt opt ion t o obt ain a har dcopy.

•Choose t he Pri nt to Fi gure opt ion t o send t he plot s t o a MATLAB figur e

window.

The Pri nt opt ion allows you t o pr int t he plot s, exact ly as you see t hem

displayed in t he LTI Viewer . The Pri nt to Fi gure opt ion allows you t o use t he

Plot Tools feat ur e of MATLAB figur e windows t o edit t he plot s befor e pr int ing

t hem.

Getting Help

You can obt ain inst r uct ions on how t o use t he LTI Viewer dir ect ly fr om t he

He lp menu.

Static Help

The Help menu cont ains t hr ee submenus:

•Overvi ew

•Re sponse Pre fe rence s

•Li ne style Pre fe rence s

The LTI Viewer Menus

6-17

The fir st submenu, Overvi e w, opens t he help t ext descr ibing how t o use t he

LTI Viewer menus and r ight -click menus t hat cont r ol t he LTI Viewer . The

r emaining help menu it ems per t ain t o LTI Viewer cont r ols you access fr om t he

Tools menu: t he Re spons e Prefere nces and Li ne style Pre ferences windows.

These windows pr ovide addit ional t ools for manipulat ing t he syst em

r esponses. See t he “Response Pr efer ences” on page 6-40” and t he “Linest yle

Pr efer ences” on page 6-44” sect ions for mor e infor mat ion on t he Response

Prefe rence s and Li nes tyle Prefe rence s windows.

Interactive Help

The st at us bar at t he bot t om of t he LTI Viewer pr ovides you wit h inst r uct ions,

hint s, and er r or messages as you pr oceed t hr ough your analysis. In gener al,

you can consult t he st at us bar t o lear n:

•If you have t r ied t o per for m an unsuppor t ed funct ion

•If a funct ion has successfully been complet ed

•If addit ional infor mat ion on t he use of an LTI Viewer cont r ol is available

6 The LTI Viewer

6-18

The Right-Click Menus

You can access most of t he cont r ols for t he individual r esponse plot s displayed

by t he LTI Viewer t hr ough t he r ight -click menus locat ed in any plot r egion.

Ther e is one r ight -click menu per plot r egion displayed on t he LTI Viewer .

These menus var y slight ly, depending on t he model dimensions and plot t ype:

•The menu it ems t hat appear on t he plot r egions of t he r esponses for SISO

models ar e t he basic r ight -click menu it ems.

•Addit ional menu it ems appear when you ar e displaying t he plot s of MIMO

LTI models or LTI ar r ays.

You can’t access t he r ight -click menu for t he LTI Viewer plot s unt il at least one

r esponse plot is displayed in t he LTI Viewer .

The Right-Click Menu for SISO Models

If you have not alr eady done so, load t he t hr ee SISO LTI models int o t he LTI

Viewer wor kspace. You can do t his by t yping

load LTIexamples

ltiview({'step';'bode'},Gcl1,Gcl2,Gcl3)

Once you have loaded models int o t he LTI Viewer , r ight -click on t he plot r egion

of t he st ep r esponse plot . The following menu appear s in t he plot r egion.

Figure 6-4: The Right-Click Menu for SISO Models

Each arrow next to a menu

item opens a submenu list

when you select the menu

item.

The Right-Click Menus

6-19

This is t he r ight -click menu for SISO models. These menu it ems cont r ol t he LTI

Viewer plot s for all models:

•Plot Type —You can choose which plot t ype you want displayed fr om t his list

of nine plot t ypes.

Figure 6-5: Plot Type Submenu

•Systems—The Systems submenu list s t he models in t he LTI Viewer

wor kspace. You can choose t o display or hide t he plot s of LTI models in t he

LTI Viewer wor kspace fr om t his menu it em:

Figure 6-6: The Systems Submenu for Three Models

- The legend for t he individual r esponse cur ves (descr ibed as linest yle,

mar ker t ypes, or color pr efer ences) is indicat ed next t o t he name of each

model. For infor mat ion on how t o modify t hese pr efer ences, see “Linest yle

Pr efer ences” on page 6-44.

- Check mar ks appear next t o t he names of models whose plot s ar e

displayed. Names of models t hat do not have a check mar k next t o t hem

The check mark next to the plot type indicates your

selection for the type of plot displayed. You can

select from any of the items on this list.

The color (in parentheses) is a

legend item that indicates the

style in which each model’s

response plot is displayed.

The check mark next to

a model name indicates

that the model’s

response is displayed

on the plot that brought

up this menu.

LTI model name

6 The LTI Viewer

6-20

ar e in t he LTI Viewer wor kspace, but t heir r esponses ar e not displayed on

t he plot associat ed wit h t he open menu.

- You can select any model in t he list wit h your mouse t o t oggle on (or off)

t he visibilit y of it s r esponse cur ve in t he select ed plot r egion.

•Characteri sti cs —You can t oggle on and off t he opt ion t o display a mar ker

for var ious r esponse char act er ist ics for each plot t ype. For mor e infor mat ion,

see “Displaying Response Char act er ist ics on a Plot ” on page 6-9.

Figure 6-7: The Characteristics Submenu for the Step Response

•Zoom—You can zoom in or out of a given plot using t he four submenu it ems

in t he Zoom menu. For mor e infor mat ion, see “Zooming” on page 6-12.

•Gri d—You can t oggle a gr id on and off by select ing t his menu it em.

Selecting a Menu Item

To select any menu it em on t he r ight -click menu:

1 Move your mouse over t he menu it em unt il it becomes highlight ed, and it s

submenu (if it has one) is displayed.

2 Click on any (sub)menu it em you want t o select :

a For opt ions menus such as Characteri s ti cs and Systems: If t he menu

it em does not have a check next t o it , select ing t he menu it em will

pr oduce a check next t o t hat it em. Select ing a checked it em unchecks t hat

menu select ion (deselect s t hat menu opt ion).

b For exclusive menus such as Plot Type, one menu it em must be checked,

and select ing a plot t ype ot her t han t he one checked changes t he plot t ype

accor ding t o your select ion.

A check mark indicates that the characteristic is

displayed on the plot. You can multiselect these submenu

items one at a time, by re-opening the right-click menu.

The Right-Click Menus

6-21

Note: To mult iselect submenu it ems (such as in t he Characteri sti cs or t he

Syste ms menus), r e-open t he r ight -click menu for each submenu it em

select ion.

The Right-Click Menu for MIMO Models

When you load a MIMO model int o t he LTI Viewer , t he r ight -click menu has a

few mor e opt ions t han t he r ight -click menu for SISO models does. These

addit ional menu it ems ar e:

•Axes Groupi ng for gr ouping I/O channels

•Sele ct I/Os for hiding t he plot s fr om some I/O channels

To see t hese menu it ems, you much have a MIMO model loaded in t he LTI

Viewer wor kspace.

The model ssF8 in t he file LTIexamples.mat is a MIMO st at e-space model for

an F-8 air cr aft . This model has t wo input s and t wo out put s. The InputNames

have been assigned as Elevator and Flaperon, and t he OutputNames have been

assigned as Acceleration and FlightPath.

If you haven’t alr eady done so, load t his model int o t he MATLAB wor kspace by

t yping

load LTIexamples

Now t hat ssF8 is in t he MATLAB wor kspace, you can load it int o an LTI Viewer

wor kspace. To open a new LTI Viewer t hat displays t he four nyquist plot s for

each of t he I/O channels of t his model, t ype

ltiview('nyquist',ssF8)

6 The LTI Viewer

6-22

Your LTI Viewer looks like t his.

Figure 6-8: Nyquist Plots of the Four I/O Responses in ssF8

Not ice t hat t he I/O names for t his model appear on t he Nyquist plot . Each of

t he four plot s displayed r epr esent s t he I/O r esponse fr om a single input t o a

single out put .

This plot region is

displayed as a grid

of four distinct

plots: one for each

I/O response of

ssF8.

The Right-Click Menus

6-23

Right -click on any par t of t he plot r egion (anywher e on t he gr id of plot s). This

opens t he following menu.

Figure 6-9: The Right-Click Menu for MIMO Models

The Axes Grouping Submenu

The Axes Groupi ng submenu is as follows.

When you fir st load a MIMO model int o t he LTI Viewer , it displays each I/O

r esponse cur ve in a separ at e por t ion of t he plot r egion. For example, if you have

t wo input s and t hr ee out put s, t he LTI Viewer init ially displays a t hr ee-by-t wo

gr id of six separ at e plot s. In t his example, a t wo-by-t wo gr id of four separ at e

plot s is displayed in t he plot r egion. This init ial (default ) Axe s Groupi ng

set t ing is indicat ed by (checked) submenu it em, None.

The right-click menu for MIMO models has two extra menu

items: Axes Grouping and Select I/Os.

Default Axes Grouping setting: Each I/O

response is displayed individually.

6 The LTI Viewer

6-24

You can use t he Axe s Groupi ng submenu t o r econfigur e t he gr ouping of t hese

I/O r esponse cur ves wit h t he following submenu it ems.

•Inputs: The r esponse cur ves fr om all of t he input s t o a given out put ar e

plot t ed in t he same por t ion of t he plot r egion. Ther e ar e as many separ at e

por t ions of t he plot r egion displayed as t her e ar e out put s.

Figure 6-10: Axes Grouping: Inputs

The plot region is

divided into two

portions: one for

each output.

The Right-Click Menus

6-25

•Outputs: The r esponse cur ves fr om a given input t o all of t he out put s ar e

plot t ed in t he same por t ion of t he plot r egion. Ther e ar e as many separ at e

por t ions of t he plot r egion displayed as t her e ar e input s.

Figure 6-11: Axes Grouping: Outputs

The plot region is

divided into two

portions: one for

each input.

6 The LTI Viewer

6-26

•All: All of t he I/O r esponse cur ves ar e displayed (gr ouped) in a single plot

r egion.

Figure 6-12: Axes Grouping: All

The Select I/Os Menu Item

The LTI Viewer init ially displays all of t he I/O r esponse cur ves fr om each input

channel t o each out put channel. You can select t he Sele ct I/Os menu it em t o

cust omize t he display wit h r espect t o t he input and out put channels.

The responses

appear all on

the same plot

region.

The Right-Click Menus

6-27

When you select Sele ct I/Os fr om t he r ight -click menu, t he following window

opens.

This I/O Selector window allows you t o cust omize t he I/O channel display for

t he plot s of MIMO models. You can:

•Select any input channel t o display t he r esponses fr om only t hat input .

•Select any out put channel t o display t he r esponses only t o t hat out put .

•Select All t o display t he I/O r esponses fr om all input s t o all out put s.

•Select individual I/O r esponse channels. You can mult iselect channels by

holding down t he Shi ft key while select ing t he channels, or by

r ubber banding a box ar ound a select ed set of I/O r esponse mar ker s on t he

gr id.

For example, select Elevator t o display t he r esponses fr om only t his input .

Not ice t hat t he name of t his input is now highlight ed in r ed in t he I/O Sele ctor

window.

Select all to display the responses from all

I/O channels.

Hold down the Shift key while

selecting individual I/O

response markers to

customize the display.

Select one of these output

channel names to display

only I/O responses to the

selected output.

Select one of these output

channel names to display

only I/O responses to the

selected output.

Select one of these input

channel names to display

only I/O responses from the

selected input.

6 The LTI Viewer

6-28

Wit h t he Axe s Groupi ng set t o None, t he display looks like t his.

Note: To r eset t he Axes Groupi ng t o None, open t he r ight -click menu on

t he plot r egion, and select None .

The Right-Click Menu for LTI Arrays

When you load an LTI ar r ay int o t he LTI Viewer , all models in t he LTI ar r ay

ar e init ially displayed. Using t he Se le ct from LTI Array menu it em available

t o you t hr ough t he r ight -click menu, you can choose t o display t he plot s fr om a

subset of t he models in any LTI ar r ay in t he LTI Viewer wor kspace, while

hiding t he plot s of t he ot her models.

The Select from LTI Array menu it em opens t he Model Selector for LTI

Arrays window.

The Right-Click Menus

6-29

For a given LTI ar r ay in t he LTI Viewer wor kspace, you can use t his int er face

t o display t he plot s of a subset of models in t he LTI ar r ay, using eit her or bot h

of t he following opt ions:

•Indexing int o t he ar r ay dimensions

•Indexing int o t he ar r ay t hr ough design specificat ion cr it er ia

In or der t o have access t o r ight -click menu it em for LTI ar r ays, you must have

at least one LTI ar r ay loaded in t he LTI Viewer wor kspace. For example, t ype

load LTIexamples

ltiview('step',m2d)

m2d is a 2-by-3 ar r ay of t wo-out put , one-input models. Your LTI Viewer looks

like t his.

Not ice t hat for each I/O map in m2d, t he st ep r esponses of all of t he models ar e

plot t ed in t he same plot r egion.

6 The LTI Viewer

6-30

To display t he r esponses of only some of t he models in t he LTI ar r ay, you must

fir st complet e t he following t wo st eps:

1 Right -click anywher e in t he plot r egion t o open t he following r ight -click

menu.

Figure 6-13: Right-Click Menu for LTI Arrays

2 Select t he Se lect from LTI Array menu it em.

The Right-Click Menus

6-31

This opens t he Mode l Selector for LTI Arrays window in t he (default ) Index

i nto Di me ns i ons set up.

Figure 6-14: LTI Array Model Selector for a 2-by-3 Array of Models

The Model Selector for LTI Arrays

For any of t he LTI ar r ays loaded int o t he LTI Viewer wor kspace, you can use

t he Model Selector for LTI Arrays window t o display t he r esponses of only a

subset of t he models in t he LTI ar r ay. To do t his, you must fir st select t he LTI

ar r ay name fr om t he Arrays pull-down t ab.

Each numbered entry

in a given listbox

represents the indices

for each dimension of

the selected LTI array.

Each listbox corresponds to a dimension of the LTI

array. The number of entries in each listbox is the

same as the number of models along the

corresponding dimension.

There are two selection criteria you can

use to index into the LTI array: Index

into Dimensions and Bound on

Characteristics. You can apply either

or both of these methods (at once) to

index in to the LTI array.

This tab lists all LTI arrays

in the LTI Viewer. You

only apply selection

criteria to one LTI array

at a time.

You can use the mouse or the

textbox to select or deselect models

in a listbox that indexes into a

particular dimension. Your choice of

models is reflected in the LTI Viewer

display (once you press OK or

Apply).

You can use

these tabs to

show all of the

models in the LTI

array, or show or

hide selected

ones as you

index into the

dimensions of

the LTI array.

6 The LTI Viewer

6-32

Once you have select ed t he name of an LTI ar r ay in t he Model Selector for

LTI Arrays window, you can select models in t he LTI ar r ay whose r esponse

plot s you want displayed using eit her or bot h of t he following:

•Index int o t he ar r ay dimensions of t he LTI ar r ay (Inde x i nto Di me nsi ons)

•Index int o LTI ar r ay using design specificat ion cr it er ia (Bound on

Characteri sti cs )

Indexing into the Array Dimensions of an LTI Array

To index int o t he ar r ay dimensions of an LTI Ar r ay:

1 Select Index i nto Di mens i ons in t he Se le cti on Cri teri a list box. This it em

is init ially select ed for you by default .

2 Leave t he show selecte d t ab as is (or change it t o hi de s elected). This

allows you t o use your mouse or t he t ext boxes t o index int o each dimension

of t he LTI ar r ay.

3 Select indices of models whose plot s you want displayed (or hidden) using

t he list boxes cor r esponding t o t he dimensions of t he LTI ar r ay by eit her :

- Using your mouse (using t he Control key for mult iselect ion) t o select

model indices fr om each ar r ay dimension of t he LTI ar r ay (fr om each

list box)

- Typing a vect or of indices or any MATLAB expr ession t hat specifies a

vect or of indices in t he t ext box below t he list box

4 Select Apply t o implement your model select ion choice wit hout closing t he

window, or OK t o implement your model select ion choice and close t he

Model Se lector for LTI Arrays window.

Note: Choosing t he show all t ab while in t he Inde xi ng i nto Di mensi ons

select ion cr it er ion is equivalent t o select ing all of t he indices in t he list boxes.

However , any pr evious select ions you made using t he Inde xi ng i nto

Di mens i ons select ion cr it er ion ar e not lost . They can be r einst alled by

applying show sele cte d.

The Right-Click Menus

6-33

For example t o display only t he fir st r ow of models in t he 2-by-3 LTI ar r ay m2d,

eit her :

•Select t he fir st index in t he fir st list box (cor r esponding t o t he fir st dimension

of t he LTI ar r ay) wit h your mouse.

•Type t he vect or [1] in t he t ext box below t he fir st list box.

The following figur e depict t he Model Se lector for LTI Arrays window for

select ing t o display t he r esponses of t he fir st r ow of models in t he LTI ar r ay

m2d.

Figure 6-15: LTI Array Model Selector to Select the First Row of m2d

The next figur e shows t he LTI Viewer display t hat r esult s fr om select ing Apply

or OK.

Select OK or Apply to

implement your LTI array model

6 The LTI Viewer

6-34

Figure 6-16: Step Response of the First Row of Models in m2d

Ther e ar e a var iet y of ways you can index int o t he dimensions of an LTI ar r ay

using t he t ext boxes locat ed below each list box. You can t ype bot h logical

expr essions, or ones t hat define indices dir ect ly.

For example, suppose you have a var iable p defined in t he MATLAB

wor kspace, r epr esent ing a vect or of par amet er s associat ed wit h t he second

dimension of m2d.

p = [1.1 5.3 10]

The var iable p might , for example, r epr esent t hr ee differ ent oper at ing

condit ions for which you cr eat ed t he LTI ar r ay. To select indices specified by

t hese par amet er s in t he second ar r ay dimension of m2d, you can, for example,

t ype t he following under t he second list box.

p>5 % Choose the 2nd and 3rd indices in the 2nd array dim. of m2d

or

find(p<2) % Choose the 1st index in the 2nd array dim. of m2d

The plots of only

three models (as

opposed to the

six models in the

LTI array) are

shown here.

The Right-Click Menus

6-35

Indexing into the LTI Array Using Design Specification Criteria

You can also use sever al plot -specific design cr it er ia t o select t hose models in

t he LTI ar r ay whose r esponses you want displayed. You index int o t he LTI

ar r ay t hr ough t hese design cr it er ia (r esponse plot char act er ist ics) using

Boolean expr essions. To plot select ed models by indexing int o t he LTI ar r ay in

t his manner :

1 Select s how all in t he Inde x i nto Di mensi ons set -up, and select Apply.

This st ep is not r equir ed, but if you don’t do t his, t hen any indexing int o

design specificat ions you per for m applies only t o t he models whose plot s ar e

select ed t o be displayed using Index i nto Di mens i ons.

2 Select Bound on Characte ri sti cs in t he Selecti on Cri teri a list box. The

r ight side of t he int er face now r eflect s t he plot -specific design specificat ion

char act er ist ics available for you t o select models fr om.

Figure 6-17: Selector for LTI Arrays Using Design Specification Criteria

3 Select t he checkbox next t o a design specificat ion char act er ist ic you want t o

index t hr ough.

You can index into specific design criteria by selecting

any (or all) of the checkboxes next to the listed

criteria. This allows you to type MATLAB logical

expressions in the corresponding textboxes.

Always select Apply

or OK to implement

your selection.

6 The LTI Viewer

6-36

4 Posit ion your mouse point er in t he t ext box next t o t he design specificat ion

char act er ist ic.

5 Type a MATLAB r elat ional expr ession in t he t ext box, using $ as a var iable

name in t he expr ession. Not e t hat for ar r ays of MIMO models, you can

consider $ t o be an Ny-by-Nu mat r ix, if each model in t he LTI ar r ay has Ny

out put s and Nu input s. This allows you t o specify differ ent r equir ement s on

differ ent I/O channels.

6 Pr ess Apply t o implement your indexing select ion.

For example, t o display only t he plot of t he model wit h t he maximum r ise t ime

in t he st ep r esponse fr om t he input t o t he fir st out put , t ype

$(1,1) == max($(1,1))

in t he t ext box next t o Ri se Ti me.

Figure 6-18: Specifying Design Criteria to Select Models in the LTI Array

Aft er select ing t he Apply but t on, your LTI Viewer displays only t he st ep

r esponse of t he model wit h t he maximum r ise t ime in t he st ep r esponse fr om

t he input t o t he fir st out put . The r esult of your act ion is displayed on t he st at us

bar .

The Right-Click Menus

6-37

Figure 6-19: Step Response of the Model with the Maximum Rise Time

You can also use any logical expr ession in var iables defined in t he MATLAB

wor kspace t o index int o a specific design cr it er ion. For example, t yping

$(2,1) < 7.25 & $(1,1) > 1.2

next t o Ste ady State (aft er unchecking Ri s e Ti me), displays t he r esponses of

any models for which t he st eady-st at e r esponse has a value less t han 7.25 for

in t he second I/O channel, and gr eat er t han 1.2 in t he fir st .

Suppose you have a design specificat ion r equir ement for each I/O map of each

model of t he LTI ar r ay, and st or e t his r equir ement in a mat r ix q in t he

MATLAB wor kspace. For example, if q is an Ny-by-Nu mat r ix (2-by-1, in t his

case), and N is t he number of models in t he LTI ar r ay (6, in t his case), t hen you

can t ype

N = 6;

Q = repmat(q,[1,1,N]);

The step response

of the model in

the (2,3) position

of the LTI array is

displayed.

6 The LTI Viewer

6-38

at t he MATLAB command line, and

$ > any(any(Q))

in t he Model Se lector for LTI Arrays window. This displays only t he plot s of

t hose models for which t he r equir ed bound is not sat isfied on any of t he I/O

channels. You must use t he any command t wice, once for each I/O dimension.

Typing $>Q would only display t he plot s of t hose models for which is bound is

not sat isfied on all of t he I/O channels.

The LTI Viewer Tools Menu

6-39

The LTI Viewer Tools Menu

Thr ee pr efer ences windows pr ovide addit ional opt ions for cust omizing t he LTI

Viewer display. You can access t hese windows fr om t he Tools menu. The

pr efer ence windows you can access fr om t he Tools menu ar e:

•Vi ewe r Confi gurati on—To change t he number and t ype of plot s displayed

by t he LTI Viewer

•Res ponse Prefere nces—To set var ious par amet er s such as t he r anges of

values for t he r esponse plot t ime and fr equency scales

•Li nes tyle Prefere nces—To set opt ions for changing linest yles, color s, and

mar ker s for all of t he r esponse cur ves

Viewer Configuration Window

Select t he Vi ewer Confi gurati on menu it em under t he Tools menu. The

following window opens t he Avai lable LTI Vi ewe r Confi gurati ons window.

Figure 6-20: The Available LTI Viewer Configurations Window

For example, load t he model ssF8 int o t he LTI Viewer wor kspace (see “The

Right -Click Menu for MIMO Models” on page 6-21 for inst r uct ions on how t o

Choose response plot types

to correspond to your chosen

plot configuration here. Each

of these pull-down tabs lists

all of the possible plot types.

Select one of these six plot configuration radio buttons,

and then select the corresponding response plot types

to be mapped to that configuration.

6 The LTI Viewer

6-40

load t his model). Wit h t he Avai lable LTI Vi ewer Confi gurati ons window

open:

1 Select t he r adio but t on for t he t wo-plot configur at ion.

2 Use t he pull-down t ab next t o 1. t o set t he fir st plot t o nyqui s t.

3 Use t he pull-down t ab next t o 2. t o set t he second plot t o bode.

4 Select OK.

Wit h t he ssF8 model loaded, t he LTI Viewer now displays t wo plot t ypes on

separ at e plot s:

Response Preferences

When you select Re sponse Pre fe rence s fr om t he Tools menu, t he Res pons e

Prefere nces window shown below opens.

The LTI Viewer Tools Menu

6-41

Figure 6-21: Response Preferences Window

You can use t he Re sponse Pre ferences window t o:

•Specify t he t ime dur at ion for t ime domain r esponse plot s and t he fr equency

r ange for fr equency domain r esponse plot s.

•Choose unit s for plot t ing t he magnit ude, phase, and fr equency of Bode plot s.

This choice of unit s also assigns t he magnit ude and fr equency unit s for

singular value (sigma) plot s.

•Specify ver t ical axis limit s for t ime domain r esponses.

•Set t ar get per cent ages for set t ling t ime and r ise t ime calculat ions on st ep

r esponse plot s.

Setting Response Time Durations and Frequency Ranges

To get a smoot her t ime domain r esponse cur ve over a specified t ime dur at ion,

you can over r ide t he default t ime r ange and r eset t he t ime vect or t o a desir ed

Always press OK or Apply to

execute window options.

Select Define to define your

own time or frequency vectors

in the editable text boxes.

Select Define to define your

own vertical axis range.

Edit these text boxes to

customize the response

characteristics for step

response plots.

Use these radio

buttons to

change units on

Bode and sigma

plots.

6 The LTI Viewer

6-42

value. You can use t he Ti me vector (sec.) por t ion of t he Ti me Domai n field

shown below t o do t his.

The Ti me vector (se c.) field accept s one, t wo, or t hr ee ar gument s, separ at ed

by colons and sur r ounded by squar e br acket s:

•[Tf] specifies only t he final t ime.

•[Ti:Tf] specifies t he init ial and final t ime.

•[Ti:dt:Tf] specifies t he init ial and final t ime and pr ovides t he incr ement al

st ep dt t o use when gener at ing t he t ime vect or .

The Gene rate automati cally r adio but t on is select ed when you init ially open

t his window. Wit h t his opt ion select ed, t he LTI Viewer aut omat ically

det er mines t he t ime vect or t o use for plot t ing t he r esponse. To over r ide t he

default set t ing:

1 Select t he Defi ne r adio but t on.

2 Ent er t he desir ed final t ime Tf or t he new t ime vect or as [Ti:dt:Tf] as

descr ibed pr eviously.

3 Select eit her :

- Apply t o keep t he Res pons e Pre fe rence s window open when you apply

t hese changes

- OK t o apply t he changes and close t he Re sponse Prefere nces window

You can also use t his window for set t ing:

•The Y-axi s Range sect ion of t he Ti me Domai n field t o over r ide t he ver t ical

axis default set t ings: Ent er t he desir ed ver t ical axis limit as a r ow vect or of

t he lower and upper axis limit .

•The Fre quency vector (rad/se c.) sect ion of t he Freque ncy Domai n field:

Ent er t he desir ed fr equencies as if t hey wer e t he input ar gument s of t he

logspace funct ion.

The LTI Viewer Tools Menu

6-43

The Fre que ncy ve ctor (rad/s ec.) field also pr ovides you wit h t he opt ion t o

r ecalculat e a new fr equency vect or for each fr equency r esponse t ype. When t his

checkbox is select ed along wit h Ge nerate automati cally, a new fr equency

vect or and r esponse is calculat ed each t ime you t oggle bet ween differ ent

fr equency r esponses, e.g.fr om Bode t o Nyquist . If you deselect t he Re calculate

for each re sponse type checkbox, t he fr equency vect or used t o calculat e t he

pr evious fr equency r esponse is used and t he fr equency r esponse dat a is simply

conver t ed t o t he new r esponse t ype.

Note: Whenever you over r ide any of t he default set t ings in t he Res pons e

Prefe rence s window, t he values you ent er ar e used on each plot , and dur ing

ever y applicable r esponse calculat ion.

Customizing Step Response Specifications

You can also use t he Re sponse Pre fe rences window t o cust omize t he

per cent age values used in t he st ep r esponse set t ling t ime or r ise t ime

calculat ion.

The settling time per cent age value det er mines t he t ime aft er which t he

envelope of t he st ep r esponse r emains wit hin t hat per cent age of t he st eady

st at e value of t he st ep r esponse.

The rise time per cent ages ar e mar ked by t wo values. These det er mine t he t ime

it t akes for t he st ep r esponse t o incr ease fr om t he fir st per cent age value t o t he

second per cent age value of t he st eady st at e st ep value r esponse.

The default values for t hese st ep r esponse char act er ist ics ar e:

•2% of t he st eady st at e value for set t ling t ime

•10% t o 90% of t he st eady st at e value for r ise t ime

You can use t he edit able t ext box in t he Plot Opti on sect ion of t he Ti me

Domai n field shown below t o change t he per cent ages for t he set t ling t ime or

6 The LTI Viewer

6-44

r ise t ime. For example, you can change t he value for t he set t ling t ime t o 5% as

shown below.

Figure 6-22: Changing the Settling Time Percentage Value to 5%

Changing the Frequency Domain Plot Units

In addit ion t o pr oviding opt ions for specifying t he fr equencies used in t he

fr equency r esponses, t he Fre que ncy Domai n field allows you t o choose t he

unit s used for Bode plot s and singular value (sigma) plot s. You can use t he

r adio but t ons in t he Fre que ncy Domai n field shown below t o over r ide t he

default unit s for t hese plot s.

By default , t he LTI Viewer plot s:

•Magnit ude in decibels

•Phase in degr ees

•Fr equency in r adians per second

Linestyle Preferences

You can use t he cont r ols in t he Li nes tyle Prefe rence s window t o modify t he

r esponse cur ve plot st yles.

To do t his:

1 Open t he Tools menu.

2 Select Li ne style Pre fe rence s.

The LTI Viewer Tools Menu

6-45

Aft er select ing Li nes tyle Prefe rence s fr om t he Tools menu, t he following

Li nes tyle Prefere nces window opens.

Figure 6-23: The Linestyle Preferences Window

You can use t he Li nes tyle Prefere nces window t o:

•Select t he pr oper t y used t o dist inguish t he r esponse cur ves for differ ent LTI

models, input s, out put s, or I/O channels.

•Change t he or der in which t he line pr oper t ies ar e applied.

The set t ings you select in t he Li nestyle Pre fe rence s window over r ide any plot

st yles you may have ent er ed in t he or iginal ltiview command.

To dist inguish mult iple r esponse cur ves in each of t he plot r egions, you can

dist inguish t he plot t ed r esponse cur ves using combinat ions of any of t he

following pr efer ences:

•Color s (r ed, blue, gr een, et c.)

•Mar ker s (cir cles, cr osses, et c.)

•Linest yle, t he t ype of cur ve dr awn (solid, dashed, et c.)

Always press OK or

Apply to execute

window functions.

Distinguish multiple

response curves

according to any of these

four characteristics.

Distinguish multiple

response curves by

either of these three

line properties, or not

at all. If you select a line property,

you can use the arrow buttons

next to one of the three

selected line property

listboxes to rearrange the

order of the entries in that

listbox.

The default linestyle

preferences are

selected.

6 The LTI Viewer

6-46

You can designat e t hat t he chosen pr efer ence (color , mar ker , or linest yle)

dist inguish t he plot t ed r esponse cur ves by any (or all) of t he following.

•Systems: The line pr oper t ies var y wit h t he models.

•Inputs: The line pr oper t ies var y wit h t he input channels.

•Outputs : The line pr oper t ies var y wit h t he out put channels.

•Channe ls: The line pr oper t ies var y wit h t he I/O channels.

Changing the Response Curve Linestyle Properties

You can use t he r adio but t ons in t he Di s ti ngui sh by field of t he Li nes tyle

Prefere nces window t o var y a line pr oper t y by model, input , out put , or I/O

channel.

When you open t he Li nes tyle Prefe rence s window, t he r adio but t on in t he

Systems r ow and Color column of t he Di sti ngui s h by field is select ed and t he

r adio but t ons in t he No Di sti ncti on column ar e select ed in t he r emaining r ows.

This is t he default set t ing for t he plot st yles used for all of t he r esponse plot s.

For example, t o dist inguish t he r esponses fr om differ ent input s of a MIMO

model using differ ent linest yles (in addit ion t o dist inguishing mult iple models

by color ):

1 Select t he r adio but t on in t he Inputs r ow and Li nes tyle column.

As soon as you select t his r adio but t on, t he pr eviously select ed r adio but t on

in t he Inputs r ow is t ur ned off, as shown in t he figur e below.

The r adio but t ons ar e mut ually exclusive along each r ow and each column

wit h t he except ion of t he No Di sti ncti on column. In ot her wor ds, you can

use only one line pr oper t y t o dist inguish t he differ ent syst ems, input s,

out put s, or channels, and t hat same pr oper t y cannot be applied t o any ot her

r ow of t he Li nes tyle Prefere nces window.

The LTI Viewer Tools Menu

6-47

2 Select eit her :

- Apply t o keep t he Li ne style Prefere nces window open when you apply

t hese changes

- OK t o apply t he changes and close t he Li nes tyle Pre fere nces window

The Order in which Line Properties are Assigned

You can det er mine t he or der in which t he line pr oper t ies ar e applied t o models

(or input s, out put s, or I/O channels) by r efer r ing t o t he or der of t he line

pr oper t ies in t he list boxes. The t hr ee list boxes t ell you t he default or der in

which each of t he line pr oper t ies will be applied. For example, look at t he

Li nes tyle Orde r list box and not ice t hat t he r esponses fr om t he fir st input will

be plot t ed wit h a solid line, and t he second input wit h a dashed line.

If, for example, (while Li ne style is assigned t o dist inguish models by input s),

you want t o plot t he r esponse fr om t he fir st input wit h dashed lines and t hose

fr om t he second input wit h dot t ed lines, you can use t he up and down ar r ows

t o t he left of each list box t o r eor der t he ent r ies in t he list boxes. The figur e below

shows t he up and down ar r ows and t he Li ne style Orde r list box.

To change any list box or der :

1 Select t he line pr oper t y you want t o move in t he list .

2 Pr ess t he up and down ar r ows t o t he left of t hat list box t o move t he

highlight ed pr oper t y in t he desir ed dir ect ion wit hin t he list box.

6 The LTI Viewer

6-48

Simulink LTI Viewer

If you have Simulink, you can use t he S imulink LTI Viewer, a ver sion of t he

LTI Viewer t hat per for ms linear analysis on any por t ion of a Simulink model.

The Simulink LTI Viewer feat ur es:

•Dr ag-and-dr op blocks t hat ident ify t he locat ion for t he input s and out put s of

t he por t ion of a Simulink model you want t o analyze.

•The abilit y t o specify t he oper at ing condit ions about which t he Simulink

model is linear ized for analysis in t he LTI Viewer .

•Access t o all t ime and fr equency r esponse t ools feat ur ed in t he LTI Viewer .

•The abilit y t o compar e a set of (linear ized) models obt ained by var ying eit her

t he oper at ing condit ions or some model par amet er values.

Using the Simulink LTI Viewer

To lear n about t he Simulink LTI Viewer , we will per for m some analysis on a

Simulink model for a van der Pol oscillat or . To open t his model, t ype

vdp

at t he MATLAB pr ompt . This br ings up t he following diagr am:

Simulink LTI Viewer

6-49

Not ice t hat t he t it le of t his Simulink model is vdp, and t hat it cont ains st at ic

nonlinear it ies.

A Sample Analysis Task

Suppose you want t o:

•Analyze t he Bode plot of t he linear r esponse bet ween t he input x2 t o t he

Pr oduct block and t he out put x1 of t he second Int egr at or block.

•Det er mine t he effect of changing t he value of t he Gain block labeled Mu on

t his r esponse.

6 The LTI Viewer

6-50

The basic pr ocedur e for car r ying out t his t ype of analysis is out lined below:

1 Open t he Simulink LTI Viewer .

2 Specify your analysis model:

a Specify t he por t ion of t he Simulink model you want t o analyze. This

involves using special Simulink blocks t o locat e t he input s and out put s of

t his analysis model on your Simulink diagr am.

b Set t he oper at ing condit ions for linear analysis (opt ional). If your

Simulink model includes nonlinear component s, t he Simulink LTI

Viewer linear izes t he model ar ound t he specified oper at ion point . The

default oper at ing condit ions have all st at e and input values set t o zer o.

c Modify any Simulink model block par amet er s (opt ional).

3 Per for m linear analysis wit h t he Simulink LTI Viewer :

a Impor t a linear ized analysis model t o t he Simulink LTI Viewer .

b Analyze t he Bode plot .

c Specify a second analysis model by changing t he value of t he Gain block,

Mu.

d Impor t t he second linear ized analysis model, and compar e t he Bode plot s

of t he t wo linear ized analysis models.

4 Save t he analysis models for fut ur e use.

In t he r emaining sect ions of t his chapt er , we explain how t o car r y out each of

t hese st eps on t he van der Pol oscillat or example.

Opening the Simulink LTI Viewer

To open a Simulink LTI Viewer linked t o t he vdp Simulink model:

1 Go t o t he Tools menu on t he Simulink model.

2 Select Li ne ar Analys i s .

Simulink LTI Viewer

6-51

When you select Li near Analys i s, t wo new windows open: an LTI Viewer

window and a Simulink diagr am called Mode l_Inputs_and_Outputs

cont aining t wo blocks: Input Point and Out put Point .

The following figur e depict s how t o open t he Simulink LTI Viewer .

6 The LTI Viewer

6-52

The Simulink LTI Viewer differ s fr om t he regular LTI Viewer , in t hat :

The Simulink LTI Viewer

includes an additional

menu for acquiring the

analysis model from

Simulink, specifying the

operating points, or

removing all the Input

and Output Point blocks.

Select Linear Analysis from the

Simulink model Tools menu to

open the Simulink LTI Viewer.

This set of Simulink blocks opens when you select Linear Analysis.

Use these blocks to specify the inputs and outputs of the portion

of the Simulink model you want to analyze.

Plot region

Your Tools menu may

differ from this one,

depending on your

options.

Simulink LTI Viewer

6-53

•The t it le bar shows t he name of t he Simulink model t o which it is linked.

•The menu bar cont ains an addit ional menu called Si muli nk t hat cont ains

t he following it ems:

- Get Li ne ari zed Mode l linear izes t he Simulink model and impor t s t he

r esult ing linear ized analysis model t o t he LTI Viewer . Each t ime you

select t his menu it em, a new ver sion of t he linear ized analysis model is

added t o t he Simulink LTI Viewer wor kspace.

- Set Operati ng Poi nt allows you t o set or r eset t he oper at ing condit ions.

- Re move Input/Output Poi nts clear s all Input Point and Out put Point

blocks fr om t he diagr am.

Specifying the Simulink Model Portion for Analysis

To specify t he por t ion of t he Simulink model you want t o analyze, mar k it s

input and out put signals on t he Simulink model using t he Input Point and

Out put Point blocks in t he Model_Inputs_and_Outputs window. This defines

an input /out put r elat ionship t hat is linear ized and analyzed by t he LTI Viewer .

Adding Input Point or Output Point Blocks to the Diagram

To designat e t he input and out put signals of your analysis model, inser t Input

Point and Out put Point blocks on t he cor r esponding signal lines in your

Simulink diagr am.

For example, t o inser t an Input Point block on t he Simulink model:

1 Gr ab t he Input Point block in t he Model_Inputs_and_Outputs window by

clicking on t he block and holding t he mouse but t on down.

2 Dr ag t he block t o your Simulink model and place it over t he line associat ed

wit h t he desir ed signal.

3 Release t he mouse but t on. The block should aut omat ically connect t o t he

line.

4 If t he block fails t o connect (t his may occur , for example, when t he line is t oo

shor t ), r esize t he line and double-click on t he block t o for ce t he connect ion.

6 The LTI Viewer

6-54

To set up t he analysis model for t he vdp Simulink model:

1 Inser t an Input Point block on t he line labeled x2 going int o t he Pr oduct

block.

2 Inser t an Out put Point block on t he line ent er ing t he Out por t block, Out1.

This r esult s in t he following diagr am.

Simulink LTI Viewer

6-55

.

Grab an Input Point

block, drag it, and

release it on the

Simulink model

here.

6 The LTI Viewer

6-56

Keep t he following in mind when using t he Input Point and Out put Point

blocks t o specify analysis models:

•You must place at least one Input Point block and one Out put Point block

somewher e in t he diagr am in or der t o specify an analysis model.

•You can place t he Input Point and Out put Point blocks on any scalar or

vect or signal line in t he Simulink model, wit h t he except ion of signal lines

connect ed t o any block in t he Power Syst em Blockset .

•You can inser t Input Point and Out put Point blocks at differ ent levels of a

Simulink model hier ar chy.

•Ther e is no limit on t he number of t hese blocks you can use.

Removing Input Points and Output Points

Ther e ar e t wo ways you can r emove Input Point or Out put Point blocks fr om

t he Simulink model:

1 One by one: Select t he Input Point or Out put Point block you want t o

r emove and delet e it as you would any ot her Simulink block.

2 All at once: To r emove all Input Point and Out put Point blocks, select

Remove Input/Output Poi nts fr om t he Si muli nk menu in t he LTI Viewer .

When you delet e an Input Point or an Out put Point block, t he signal lines

coming int o and out of t his block ar e aut omat ically r econnect ed.

Specifying Open- Versus Closed-Loop Analysis Models

Placing t he Input Point and Out put Point blocks on your Simulink model does

not br eak any connect ion or isolat e any component . As a r esult , t he Simulink

LTI Viewer per for ms closed-loop analysis whenever your diagr am cont ains

feedback loops. This may somet imes lead t o count er -int uit ive r esult s, as is

illust r at ed by t he next example.

Simulink LTI Viewer

6-57

Consider t he following simple diagr am.

Based on t he locat ion of t he Input Point and Out put Point blocks, you might

t hink t hat t he analysis model specified by t hese blocks is simply t he plant

model, P. However , due t o t he feedback loop, t his analysis model is act ually t he

closed-loop t r ansfer funct ion .

If you want t o analyze t he (open-loop) plant P inst ead, you need t o open t he

loop, for example, by delet ing t he line bet ween t he Sum and Input Point blocks.

Setting the Operating Conditions

If you have nonlinear component s in your Simulink model, t he Simulink LTI

Viewer aut omat ically linear izes t hem when you select Get Li ne ari zed Model.

The Simulink LTI Viewer uses t he init ial st at e values you set in t he Simulink

diagr am as default set t ings for linear izat ion point s for t he st at es in t he

diagr am. The default input values for t his linear izat ion ar e zer o. You also have

t he opt ion t o linear ize about t he oper at ing condit ions of your choice.

If you want your analysis model t o be linear ized about zer o st at e, or ot her st at e

and input oper at ing condit ions, follow t hese st eps before select ing Get

Li neari zed Model:

Delete this line to isolate

the plant, P, for open

loop analysis.

P 1 PK + ( ) ⁄

6 The LTI Viewer

6-58

1 Select Se t Operati ng Poi nt in t he Si muli nk menu. This opens t he

Operati ng Poi nt window.

Figure 6-24: The Operating Point Window for Changing Linearization Points

2 Change t he r adio but t on select ion t o eit her :

- Set all st at e values for t he linear izat ion t o zer o.

- Define your own st at e values for t he linear izat ion.

3 Use t he whit e t ext boxes t o specify t he oper at ing condit ions for each input

(and st at e) list ed in t he Operati ng Poi nt window. You don’t have t o specify

t he st at es if you choose t he Ze ro state values r adio but t on.

The default setting for the Operating

Point window uses initial states from

the Simulink diagram. Select either of

the other two radio buttons to set all

state values for linearization to zero,

or choose some other values.

Edit the operating

point values in the

textboxes provided.

When you select this

radio button, the

Simulink LTI Viewer

uses zero state

values for each

linearization.

When you select this

radio button, the

Simulink LTI Viewer

uses the values in the

textboxes for each

linearization, unless

you change these.

When you

have inputs in

your Simulink

model, you

can set

linearization

values for

them here.

Simulink LTI Viewer

6-59

4 Select OK. A dialog box opens.

a Select ing Ye s closes t he Ope rati ng Poi nt window and linear izes t he

model aut omat ically. The new oper at ing condit ions you select ed r emain

in effect for any fut ur e linear izat ions.

b Select ing No closes t he Operati ng Poi nt window wit hout linear izing t he

model. The new oper at ing condit ions you select ed r emain in effect for any

fut ur e linear izat ions.

c Select ing Cance l closes t he dialog box and r et ur ns you t o t he Operati ng

Poi nt window wit hout linear izing t he model or changing oper at ing

condit ions.

6 The LTI Viewer

6-60

For t his example, we use t he Zero i ni ti al states set t ing, shown in t he figur e

below.

Not e t he following:

•The input s list ed on t he Ope rati ng Poi nt window cor r espond t o t he Inpor t

blocks on t he t op level of your Simulink model.

•All st at es and input s in t he Simulink diagr am ar e list ed in t his window, not

just t hose associat ed wit h your analysis model.

•If you want t o change t he oper at ing condit ions, you need only change t hose

values associat ed wit h your analysis model.

•While t he Ope rati ng Poi nt window is in t he Us er-defi ne d i ni ti al state

value s mode, t he values list ed in t he Operati ng Poi nt window r emain in

effect t hr oughout your Simulink LTI Viewer session unless you change

t hese.

Choose this menu on the

Simulink LTI Viewer to set

the operating conditions.

Simulink path name for the state variables

Selecting OK opens a dialog box, asking you to accept

the changes you made to the operating conditions and

linearize the model with these operating conditions.

Edit the operating

point values here.

Selecting Cancel closes this

window without

implementing any changes

to the operating conditions.

Simulink LTI Viewer

6-61

•While t he Operati ng Poi nt window is in t he Ini ti al s tate i n Si muli nk

di agram mode, t he linear izat ion values used by t he Simulink LTI Viewer

ar e updat ed as you change any st at e values in your Simulink diagr am.

•To use t he MATLAB command line t o change Simulink diagr am init ial st at e

values

- Select Parame ters under t he Si mulati on menu on your Simulink

diagr am.

- Choose t he Workspace I/O t ab in t he Si mulati on Parameters window.

- Load init ial st at es fr om t he MATLAB wor kspace using t he appr opr iat e

t ext box.

Modifying the Block Parameters

You have t he opt ion of modifying any of your Simulink model block

par amet er s, such as Gain block gain values or LTI block poles and zer os, befor e

you impor t your analysis model int o t he Simulink LTI Viewer .

Performing Linear Analysis

Once you have specified your analysis model, you ar e r eady t o analyze it wit h

t he Simulink LTI Viewer .

Let ’s use t he Simulink LTI Viewer t o compar e t he Bode plot s of t wo differ ent

linear ized analysis models. The pr ocedur e for car r ying out t his analysis on t he

van der Pol example involves:

•Impor t ing a linear ized analysis model t o t he Simulink LTI Viewer .

•Analyzing t he Bode plot of t he linear ized analysis model.

•Specifying anot her analysis model.

•Impor t ing t he second linear ized analysis model t o compar e t he Bode plot s of

bot h linear ized analysis models.

6 The LTI Viewer

6-62

Importing a Linearized Analysis Model to the LTI Viewer

To linear ize and load your fir st analysis model for t he van der Pol example int o

t he LTI Viewer , select Get Li ne ari zed Mode l on t he Si muli nk menu on t he

LTI Viewer . This pr oduces t he following r esponse plot :

Each t ime you select Ge t Li neari ze d Model in t he LTI Viewer ’s Si muli nk

menu:

•The linear ized analysis model is impor t ed int o t he LTI Viewer wor kspace.

•The st ep r esponse of t he linear ized analysis model is t he default plot t ype

displayed.

The LTI Viewer displays the selected

response plot for all of the models in

the LTI Viewer workspace. These are

listed in the Systems menu

available by right-clicking in the

plot region. The default plot type is

step response.

Simulink LTI Viewer

6-63

You can view t he linear ized models in t he LTI Viewer wor kspace or change t he

plot t ype using t he r ight -click menus. See “The Right -Click Menus” on page

6-18 for mor e infor mat ion.

Analyzing the Bode Plot of the Linearized Analysis Model

To analyze t he Bode plot for t his model,

1 Right -click anywher e in t he plot r egion.

2 Select t he Plot Type menu, and t hen t he Bode submenu it em.

Specifying Another Analysis Model

Once an analysis model is specified on a Simulink diagr am, you can specify

ot her analysis models fr om t he same Simulink diagr am in one of t he following

t hr ee ways:

•Modify any of t he model par amet er s.

•Change t he oper at ing condit ions.

•Change t he locat ion of any of t he Input Point or Out put Point blocks.

For t he van der Pol example, we want t o cr eat e a second analysis model by

modifying a model par amet er . Specifically, we modify t he Gain block labeled

Mu. To do t his:

•Ret ur n t o t he Simulink model, and open t he Mu Gain block by double-clicking

on it .

•Change t he gain t o 10; click on OK.

Comparing the Bode Plots of the Two Linearized Analysis Models

Having just specified a new analysis model, let ’s load it s linear izat ion int o t he

LTI Viewer and compar e t he Bode plot s of t he t wo models. To do t his, r eselect

t he Get Li ne ari zed Mode l menu it em under Si muli nk on t he LTI Viewer .

6 The LTI Viewer

6-64

As is shown below, t he linear ized model for t he new value of Mu appear s as t he

last it em in t he Syste ms submenu, and t he Bode plot s for bot h models ar e

displayed.

As you might expect , changing t he gain alt er s t he Bode plot .

After reselecting Get

Linearized Model, the

Systems submenu contains

two model names with

different version numbers.

The Bode plots for both

models are displayed in

different colors.

Simulink LTI Viewer

6-65

Not ice t he following about t he models list ed in t he Systems list on t he

r ight -click menu:

•The names r eflect t he t it le of t he Simulink model.

•The ver sion number is incr ement ed ever y t ime Get Li neari zed Mode l is

select ed.

•The LTI Viewer simult aneously displays t he r esponse plot s of all of t he

checked models list ed.

Saving Analysis Models

The analysis models obt ained each t ime you select Ge t Li ne ari zed Model ar e

st or ed only in t he Simulink LTI Viewer wor kspace. You can save t hese models

int o t he main MATLAB wor kspace by select ing Export fr om t he Simulink LTI

Viewer Fi le menu.

Select ing Export opens t he window shown below.

Lists all the analysis models

currently in the Simulink LTI Viewer

Store the selected

analysis model in

a MAT-file.

Store the selected

analysis model in

the MATLAB workspace.

workspace.

6 The LTI Viewer

6-66

To expor t analysis models fr om t he LTI Viewer wor kspace:

1 Highlight t he models you want t o save in t he Export Li s t. (You can

mult iselect models on t he list by holding down t he cont r ol key while

select ing list it ems).

2 Save t he select ed models by clicking on t he appr opr iat e but t on on t his GUI.

You can expor t t he linear ized models t o eit her :

a A MAT-file

b The MATLAB wor kspace

Note: If you save models t o a MAT-file, you ar e pr ompt ed t o name t he file.

The var iable names cont ained in t hat file ar e t he same as t hose you select ed

fr om t he Export Li s t. The var iable names of each model you save t o t he

MATLAB wor kspace ar e also t he same as t hose list ed in t he Export Li s t. It ’s

up t o you t o modify t he names of t hese var iables aft er you’ve saved t hem.

7

Cont r ol Design Tools

Root Locus Desi gn . . . . . . . . . . . . . . . . . 7-3

Pole Placement . . . . . . . . . . . . . . . . . . . 7-5

St at e-Feedback Gain Select ion . . . . . . . . . . . . . 7-5

St at e Est imat or Design . . . . . . . . . . . . . . . . 7-5

Pole Placement Tools . . . . . . . . . . . . . . . . . 7-6

LQG Desi gn . . . . . . . . . . . . . . . . . . . . 7-8

Opt imal St at e-Feedback Gain . . . . . . . . . . . . . 7-9

Kalman St at e Est imat or . . . . . . . . . . . . . . . . 7-9

LQG Regulat or . . . . . . . . . . . . . . . . . . . 7-10

LQG Design Tools . . . . . . . . . . . . . . . . . . 7-10

7 Control Design Tools

7-2

We use t he t er m cont r ol syst em design t o r efer t o t he pr ocess of select ing

feedback gains in a closed-loop cont r ol syst em. Most design met hods ar e

it er at ive, combining par amet er select ion wit h analysis, simulat ion, and

physical insight .

The Cont r ol Syst em Toolbox offer s funct ions t o:

•Design t he cont r ol syst em gains using eit her classical r oot locus t echniques

or moder n pole placement and LQG t echniques.

•Close t he loop for simulat ion and validat ion pur poses.

Root Locus Design

7-3

Root Locus Design

The r oot locus met hod is used t o descr ibe t he t r aject or ies of t he closed-loop

poles of a feedback syst em as one par amet er var ies over a cont inuous r ange of

values. Typically, t he r oot locus met hod is used t o t une a feedback gain so as t o

specify t he closed-loop poles of a SISO cont r ol syst em.

Consider , for example, t he t r acking loop

wher e is t he plant , is t he sensor dynamics, and is a scalar gain t o

be adjust ed. The closed-loop poles ar e t he r oot s of

The r oot locus t echnique consist s of plot t ing t he closed-loop pole t r aject or ies in

t he complex plane as var ies. You can use t his plot t o ident ify t he gain value

associat ed wit h a given set of closed-loop poles on t he locus.

The command rltool opens t he Root Locus Design GUI. In addit ion t o plot t ing

t he r oot locus, t he Root Locus Design GUI can be used t o design a compensat or

int er act ively t o meet some syst em design specificat ions.

The Root Locus Design GUI can be used t o:

•Analyze t he r oot locus plot for a SISO LTI feedback loop

•Specify feedback compensat or par amet er s: poles, zer os, and gain

•Examine how t he compensat or par amet er s change t he r oot locus, as well as

var ious open and closed-loop syst em r esponses (st ep r esponse, Bode plot ,

Nyquist plot , or Nichols char t )

Chapt er 8 pr ovides mor e det ail on t he Root Locus Design GUI.

P s ( )

+

H s ( ) k

r

–

y

P s ( ) H s ( ) k

q s ( ) 1 k P s ( )H s ( ) + =

k

7 Control Design Tools

7-4

If you ar e int er est ed in just t he r oot locus plot , use t he command rlocus. This

command t akes one ar gument : a SISO model of t he open loop syst em, cr eat ed

wit h ss, tf, or zpk. In t he t r acking loop depict ed on t he pr evious page, t his

model would r epr esent . You can also use t he funct ion rlocfind t o

select a point on t he r oot locus plot and det er mine t he cor r esponding gain .

The following t able summar izes t he commands for r oot locus design.

Root Locus Design

pzmap Pole-zer o map.

rltool Root Locus Design GUI.

rlocfind Int er act ive r oot locus gain select ion.

rlocus Evans r oot locus plot .

sgrid Cont inuous gr id for r oot locus.

zgrid Discr et e gr id for r oot locus.

P s ( )H s ( )

k

ω

n

ζ ,

ω

n

ζ ,

Pole Placement

7-5

Pole Placement

The closed-loop pole locat ions have a dir ect impact on t ime r esponse

char act er ist ics such as r ise t ime, set t ling t ime, and t r ansient oscillat ions. This

suggest s t he following met hod for t uning t he closed-loop behavior :

1 Based on t he t ime r esponse specificat ions, select desir able locat ions for t he

closed-loop poles.

2 Comput e feedback gains t hat achieve t hese locat ions.

This design t echnique is known as pole placement.

Pole placement r equir es a st at e-space model of t he syst em (use ss t o conver t

ot her LTI models t o st at e space). In cont inuous t ime, t his model should be of

t he for m

wher e is t he vect or of cont r ol input s and is t he vect or of measur ement s.

Designing a dynamic compensat or for t his syst em involves t wo st eps:

st at e-feedback gain select ion, and st at e est imat or design.

State-Feedback Gain Selection

Under st at e feedback , t he closed-loop dynamics ar e given by

and t he closed-loop poles ar e t he eigenvalues of . Using pole placement

algor it hms, you can comput e a gain mat r ix t hat assigns t hese poles t o any

desir ed locat ions in t he complex plane (pr ovided t hat is cont r ollable).

State Estimator Design

You cannot implement t he st at e-feedback law unless t he full st at e

is measur ed. However , you can const r uct a st at e est imat e such t hat t he

law r et ains t he same pole assignment pr oper t ies. This is achieved by

designing a st at e est imat or (or obser ver ) of t he for m

x

·

Ax Bu + =

y Cx Du + =

u y

u Kx – =

x

·

A BK – ( ) x =

A BK –

K

A B , ( )

u Kx – =

x ξ

u Kξ – =

7 Control Design Tools

7-6

The est imat or poles ar e t he eigenvalues of , which can be ar bit r ar ily

assigned by pr oper select ion of t he est imat or gain mat r ix . As a r ule of

t humb, t he est imat or dynamics should be fast er t han t he cont r oller dynamics

(eigenvalues of ).

Replacing by it s est imat e in yields t he dynamic out put -feedback

compensat or

Not e t hat t he r esult ing closed-loop dynamics ar e

Hence, you act ually assign all closed-loop poles by independent ly placing t he

eigenvalues of and .

Pole Placement Tools

The Cont r ol Syst em Toolbox cont ains funct ions t o:

•Comput e gain mat r ices and t hat achieve t he desir ed closed-loop pole

locat ions

•For m t he st at e est imat or and dynamic compensat or using t hese gains

ξ

·

Aξ Bu L y Cξ – Du – ( ) + + =

A L C –

L

A BK –

x ξ u Kx – =

ξ

·

A L C – B L D – ( )K –

ξ L y + =

u Kξ – =

x

·

e

·

A BK – BK

0 A L C –

x

e

, = e x ξ – =

A BK – A L C –

K L

Pole Placement

7-7

The funct ion acker is limit ed t o SISO syst ems and should only be used for

syst ems wit h a small number of st at es. The funct ion place is a mor e gener al

and numer ically r obust alt er nat ive t o acker.

Caution: Pole placement can be badly condit ioned if you choose unr ealist ic

pole locat ions. In par t icular , you should avoid:

•Placing mult iple poles at t he same locat ion

•Moving poles t hat ar e weakly cont r ollable or obser vable. This t ypically

r equir es high gain, which in t ur n makes t he ent ir e closed-loop

eigenst r uct ur e ver y sensit ive t o per t ur bat ions.

Pole Placement

acker SISO pole placement .

estim For m st at e est imat or given est imat or gain.

place MIMO pole placement .

reg For m out put -feedback compensat or given

st at e-feedback and est imat or gains.

7 Control Design Tools

7-8

LQG Design

Linear -Quadr at ic-Gaussian (LQG) cont r ol is a moder n st at e-space t echnique

for designing opt imal dynamic r egulat or s. It enables you t o t r ade off r egulat ion

per for mance and cont r ol effor t , and t o t ake int o account pr ocess and

measur ement noise. Like pole placement , LQG design r equir es a st at e-space

model of t he plant (use ss t o conver t ot her LTI models t o st at e space). This

sect ion focuses on t he cont inuous-t ime case (see r elat ed Refer ence pages for

det ails on discr et e-t ime LQG design).

LQG design addr esses t he following r egulat ion pr oblem.

The goal is t o r egulat e t he out put ar ound zer o. The plant is dr iven by t he

pr ocess noise and t he cont r ols , and t he r egulat or r elies on t he noisy

measur ement s t o gener at e t hese cont r ols. The plant st at e and

measur ement equat ions ar e of t he for m

and bot h and ar e modeled as whit e noise.

The LQG r egulat or consist s of an opt imal st at e-feedback gain and a Kalman

st at e est imat or . You can design t hese t wo component s independent ly as shown

next .

w

u

y

v

+

+

y

v

Plant

Regulat or

y

w u

y

v

y v + =

x

·

Ax Bu Gw + + =

y

v

Cx Du Hw v + + + =

w v

LQG Design

7-9

Optimal State-Feedback Gain

In LQG cont r ol, t he r egulat ion per for mance is measur ed by a quadr at ic

per for mance cr it er ion of t he for m

The weight ing mat r ices ar e user specified and define t he t r ade-off

bet ween r egulat ion per for mance (how fast goes t o zer o) and cont r ol effor t .

The fir st design st ep seeks a st at e-feedback law t hat minimizes t he

cost funct ion . The minimizing gain mat r ix is obt ained by solving an

algebr aic Riccat i equat ion. This gain is called t he LQ-optimal gain.

Kalman State Estimator

As for pole placement , t he LQ-opt imal st at e feedback is not

implement able wit hout full st at e measur ement . However , we can der ive a

st at e est imat e such t hat r emains opt imal for t he out put -feedback

pr oblem. This st at e est imat e is gener at ed by t he Kalman filt er .

wit h input s (cont r ols) and (measur ement s). The noise covar iance dat a

det er mines t he Kalman gain t hr ough an algebr aic Riccat i equat ion.

The Kalman filt er is an opt imal est imat or when dealing wit h Gaussian whit e

noise. Specifically, it minimizes t he asympt ot ic covar iance

of t he est imat ion er r or .

J u ( ) x

T

Qx 2x

T

N u u

T

R u + + { } t d

0

∞

∫

=

Q N R , ,

x t ( )

u Kx – =

J u ( ) K

u Kx – =

xˆ u Kxˆ – =

x

ˆ

·

Axˆ Bu L y

v

Cxˆ – Du – ( ) + + =

u y

v

E ww

T

( ) Q

n

, = E v v

T

( ) R

n

, = E wv

T

( ) N

n

=

L

E x xˆ – ( ) x xˆ – ( )

T

( )

t ∞ →

lim

x xˆ –

xˆ

u

y

v

Kalman

est imat or

7 Control Design Tools

7-10

LQG Regulator

To for m t he LQG r egulat or , simply connect t he Kalman filt er and LQ-opt imal

gain as shown below:

This r egulat or has st at e-space equat ions

LQG Design Tools

The Cont r ol Syst em Toolbox cont ains funct ions t o per for m t he t hr ee LQG

design st eps out lined above. These funct ions cover bot h cont inuous and

K

w

u

y

v

+

+ y

v

xˆ

K –

LQG r egulat or

u

Plant

Kalman

filt er

x

ˆ

·

A L C – B L D – ( )K –

xˆ L y

v

+ =

u Kxˆ – =

LQG Design

7-11

discr et e pr oblems as well as t he design of discr et e LQG r egulat or s for

cont inuous plant s.

See t he case st udy on page 9-31 for an example of LQG design. You can also use

t he funct ions kalman and kalmd t o per for m Kalman filt er ing; see t he case st udy

on page 9-50 for det ails.

LQG Design

care Solve cont inuous-t ime algebr aic Riccat i equat ions.

dare Solve discr et e-t ime algebr aic Riccat i equat ions.

dlqr LQ-opt imal gain for discr et e syst ems.

kalman Kalman est imat or.

kalmd Discr et e Kalman est imat or for cont inuous plant .

lqgreg For m LQG r egulat or given LQ gain and Kalman

filt er.

lqr LQ-opt imal gain for cont inuous syst ems.

lqrd Discr et e LQ gain for cont inuous plant .

lqry LQ-opt imal gain wit h out put weight ing.

7 Control Design Tools

7-12

8

The Root Locus Design

GUI

Introduct i on . . . . . . . . . . . . . . . . . . . . 8-2

A Servomechani sm Example . . . . . . . . . . . . 8-4

Cont roller De si gn Us i ng the Root Locus De s i gn GUI . . 8-6

Opening t he Root Locus Design GUI . . . . . . . . . . . 8-6

Impor t ing Models int o t he Root Locus Design GUI . . . . . 8-7

Changing t he Gain Set Point and Zooming . . . . . . . . 8-13

Displaying Syst em Responses . . . . . . . . . . . . . 8-20

Designing a Compensat or t o Meet Specificat ions . . . . . . 8-22

Saving t he Compensat or and Models . . . . . . . . . . 8-36

Addi ti onal Root Locus Des i gn GUI Features . . . . . 8-38

Specifying Design Models: Gener al Concept s . . . . . . . 8-38

Get t ing Help wit h t he Root Locus Design GUI . . . . . . . 8-39

Er asing Compensat or Poles and Zer os . . . . . . . . . . 8-41

List ing Poles and Zer os . . . . . . . . . . . . . . . . 8-41

Pr int ing t he Root Locus . . . . . . . . . . . . . . . . 8-44

Dr awing a Simulink Diagr am . . . . . . . . . . . . . 8-44

Conver t ing Bet ween Cont inuous and Discr et e Models . . . . 8-45

Clear ing Dat a . . . . . . . . . . . . . . . . . . . . 8-46

Refe re nce s . . . . . . . . . . . . . . . . . . . . . 8-48

8 The Root Locus Design GUI

8-2

Introduction

The r oot locus met hod is used t o descr ibe t he t r aject or ies in t he complex plane

of t he closed-loop poles of a SISO feedback syst em as one par amet er (usually a

gain) var ies over a cont inuous r ange of values.

Along wit h t he MATLAB command line funct ion rlocus, t he Cont r ol Syst em

Toolbox pr ovides t he Root Locus Design gr aphical user int er face (GUI) for

implement ing r oot locus met hods on single-input /single-out put (SISO) LTI

models defined using zpk, tf, or ss.

In addit ion t o plot t ing r oot loci, t he Root Locus Design GUI is an int er act ive

design t ool t hat can be used t o:

•Analyze t he r oot locus plot for a SISO LTI cont r ol syst em

•Specify t he par amet er s of a feedback compensat or : poles, zer os, and gain

•Examine how changing t he compensat or par amet er s effect s changes in t he

r oot locus and var ious closed-loop syst em r esponses (st ep r esponse, Bode

plot , Nyquist plot , or Nichols char t )

This chapt er explains how t o use t he Root Locus Design GUI, in par t , t hr ough

an example involving an elect r ohydr aulic ser vomechanism compr ised of an

elect r ohydr aulic amplifier , a valve, and a r am. These t ypes of

ser vomechanisms can be made quit e small, and ar e used for posit ion cont r ol.

Det ails on t he modeling of elect r ohydr aulic posit ion cont r ol mechanisms can be

found in [1].

Aft er an explanat ion of t he ser vomechanism cont r ol syst em, t he following

oper at ions on t he Root Locus Design GUI ar e cover ed in t he sect ion, “Cont r oller

Design Using t he Root Locus Design GUI” on page 8-6:

•Opening t he Root Locus Design GUI

•Impor t ing models int o t he Root Locus Design GUI

•Changing t he gain set point and zooming

•Displaying syst em r esponses

•Designing t he compensat or t o meet specificat ions:

- Specifying t he design r egion boundar ies on t he r oot locus

- Placing compensat or poles and zer os

Introduction

8-3

- Edit ing t he compensat or pole and zer o locat ions

- Opening t he LTI Viewer

•Saving t he compensat or and models t o t he wor kspace or t he disk

Ot her impor t ant feat ur es list ed below and not cover ed t hr ough t his example

ar e descr ibed in t he sect ion, “Addit ional Root Locus Design GUI Feat ur es” on

page 8-38:

•Specifying design models: gener al concept s

•Get t ing help wit h t he Root Locus Design GUI

•Er asing compensat or poles and zer os

•List ing poles and zer os

•Pr int ing t he r oot locus

•Dr awing a Simulink diagr am of t he closed-loop model

•Conver t ing bet ween cont inuous and discr et e models

•Clear ing dat a

8 The Root Locus Design GUI

8-4

A Servomechanism Example

A simple ver sion of an elect r ohydr aulic ser vomechanism model consist s of:

•A push-pull amplifier (a pair of elect r omagnet s)

•A sliding spool in a vessel of high pr essur e hydr aulic fluid

•Valve openings in t he vessel t o allow for fluid t o flow

•A cent r al chamber wit h a pist on-dr iven r am t o deliver for ce t o a load

•A symmet r ical fluid r et ur n vessel

The for ce on t he spool is pr opor t ional t o t he cur r ent in t he elect r omagnet coil.

As t he spool moves, t he valve opens, allowing t he high pr essur e hydr aulic fluid

t o flow t hr ough t he chamber . The moving fluid for ces t he pist on t o move in t he

opposit e dir ect ion of t he spool. In [1], linear ized models for t he elect r omagnet ic

amplifier , t he valve spool dynamics, and t he r am dynamics ar e der ived, and a

det ailed descr ipt ion of t his t ype of ser vomechanism is pr ovided.

A schemat ic of t his ser vomechanism is depict ed below.

If you want t o use t his ser vomechanism for posit ion cont r ol, you can use t he

input volt age t o t he elect r omagnet t o cont r ol t he r am posit ion. When

measur ement s of t he r am posit ion ar e available, you can use feedback for t he

r am posit ion cont r ol.

Return

Pressure

Load

Push-pull

amplifier

Push-pull

amplifier

Piston-driven ram

Spool

Hydraulic fluid

A Servomechanism Example

8-5

A closed-loop model for t he elect r ohydr aulic valve posit ion cont r ol can be set up

as follows.

Figure 8-1: Feedback Control for an Electrohydraulic

Servomechanism

K(s) r epr esent s t he compensat or for you t o design. This compensat or can be

eit her a gain or a mor e gener al LTI syst em.

A linear ized plant model for t he elect r ohydr aulic posit ion cont r ol mechanism is

given by

For t his example, you want t o design a cont r oller so t hat t he st ep r esponse of

t he closed-loop syst em meet s t he following specificat ions:

•The t wo-per cent set t ling t ime is less t han 0.05 seconds.

•The maximum over shoot is less t han 5 per cent .

For det ails on how t hese specificat ions ar e defined, see [2].

In t he r emainder of t his chapt er you lear n how t o use t he Root Locus Design

GUI. In t he pr ocess, you design a cont r oller t o meet t hese specificat ions.

+

–

G

s er v o

s ( )

K(s)

Compensator

Servomechanism

Ram Position

Desired Ram

Position

Linearized

G

s er v o

s ( )

4 10

7

×

s s 250 + ( ) s

2

40s 9 10

4

× + + ( )

------------------------------------------------------------------------------- =

8 The Root Locus Design GUI

8-6

Controller Design Using the Root Locus Design GUI

In t his sect ion, we use t he ser vomechanism example t o descr ibe some of t he

main Root Locus Design GUI feat ur es and oper at ions:

•Opening t he Root Locus Design GUI

•Impor t ing models int o t he Root Locus Design GUI:

- Opening t he Import LTI De si gn Model window

- Choosing a feedback st r uct ur e

- Specifying t he design model

•Changing t he gain set point and zooming:

- Dr agging closed-loop poles t o change t he gain set point

- Zooming

- St or ing and r et r ieving axes limit s

•Displaying syst em r esponses

•Designing t he compensat or t o meet specificat ions:

- Specifying t he design r egion boundar ies on t he r oot locus

- Placing compensat or poles and zer os: gener al infor mat ion

- Placing compensat or poles and zer os using t he r oot locus t oolbar

- Edit ing compensat or pole and zer o locat ions

•Saving t he compensat or and models t o t he wor kspace or t he disk

Opening the Root Locus Design GUI

To open t he Root Locus Design GUI, at t he MATLAB pr ompt t ype

rltool

Controller Design Using the Root Locus Design GUI

8-7

This br ings up t he following GUI.

Importing Models into the Root Locus Design GUI

The Root Locus Design GUI oper at es on SISO LTI models const r uct ed using

eit her tf, zpk, or ss (for det ail on cr eat ing models, see “Cr eat ing LTI Models”

in Chapt er 2).

Status bar for providing

Click on these boxes to open

Zoom into or out of

Save/retrieve root locus

axes limits and aspect ratios

the root locus plot.

Click on K to view/change the

compensator, and on P, F, or H to view

the design model characteristics.

The feedback structure:

system response analysis tools.

These are the main menus for importing/

exporting of models, and editing them. You

can also perform discrete/continuous conversion.

Edit the gain set

point to change

the closed-loop

pole locations.

Compensator de-

scription: The de-

fault compensator

is K=1.

Root locus toolbar buttons to

drag, add, or erase compensa-

tor poles and zeros, or to drag

the closed-loop poles

Plot region to display

the root locus

Toggle between

positive/negative

feedback.

information

8 The Root Locus Design GUI

8-8

Ther e ar e four ways t o impor t SISO LTI models int o t he Root Locus Design

GUI:

•Load a model fr om t he MATLAB wor kspace.

•Load a model fr om a MAT-file on your disk.

•Load SISO LTI blocks fr om an open or saved Simulink diagr am.

•Cr eat e models using tf, ss, or zpk wit hin t he GUI.

You can also use any combinat ion of t hese met hods t o impor t models for r oot

locus analysis and design. However , befor e you can impor t a model int o t he

Root Locus Design GUI fr om t he MATLAB wor kspace, you must have at least

one SISO LTI model loaded int o your wor kspace. Similar r equir ement s hold for

loading models fr om t he disk or an open Simulink diagr am.

For t his example, we impor t our ser vomechanism model for r oot locus analysis

fr om t he MATLAB wor kspace. You can find a zer o-pole-gain model for

in a set of LTI models pr ovided in t he file LTIexamples.MAT.

To load t hese LTI models, at t he MATLAB pr ompt t ype

load LTIexamples

The model for t he posit ion cont r ol syst em is cont ained in t he var iable Gservo.

To view t he infor mat ion on t his model, at t he MATLAB pr ompt t ype

Gservo

Now t hat a model for is loaded int o t he wor kspace, you can begin

your r oot locus analysis and design for t his example.

Ther e ar e t hr ee st eps involved in impor t ing a model for our example cover ed in

t his sect ion:

•Opening t he Import LTI Des i gn Model window

•Choosing a feedback st r uct ur e

•Specifying t he design model

G

s er v o

s ( )

G

s er v o

s ( )

Controller Design Using the Root Locus Design GUI

8-9

Opening the Import LTI Design Model Window

To impor t t he linear ized elect r ohydr aulic ser vomechanism model int o t he Root

Locus Design GUI, fir st open t he Import LTI Des i gn Model window. To do

t his, select t he Import Model menu it em in t he Fi le menu.

The Import LTI Des i gn Model window t hat appear s on your scr een is as

follows.

8 The Root Locus Design GUI

8-10

Choosing a Feedback Structure

The Root Locus design t ool can be applied t o SISO LTI syst ems whose feedback

st r uct ur e is in one of t he following t wo configur at ions.

Diagram of feedback

structure

F,P, and H compose

the design model.

Click on the appropriate arrow to

transfer a model from the list to a

design model component.

Toggle button

for the feedback

structure

Edit the name of the

overall design model.

This name appears on

the title bar of the Root

Locus Design GUI.

Variable names for the design

model components appear here if

you use the transfer arrows. You

can also use tf, zpk, and ss

to create a model in the text box.

Model listbox: lists available LTI

models or blocks.

SISO LTI models can be imported from either

the workspace or disk. SISO LTI blocks can be

imported from saved or open Simulink models.

Default feedback structure

Controller Design Using the Root Locus Design GUI

8-11

The Fe edback Structure por t ion of t he Import LTI De si gn Mode l window

shows t he cur r ent select ion for t he closed-loop st r uct ur e. The Other but t on

t oggles t he locat ion of t he compensat or bet ween t he t wo configur at ions shown

above. For t his example you want t he compensat or in t he for war d pat h.

Specifying the Design Model

The SISO LTI models in eit her feedback configur at ion ar e coded as follows:

•F r epr esent s a pr e-filt er .

•P is t he plant model.

•H is t he sensor dynamics.

•K is t he compensat or t o be designed.

In t er ms of t he GUI design pr ocedur e, once t hey ar e set , F, P, and H ar e fixed

in t he feedback st r uct ur e. This t r iple, along wit h t he choice of feedback

st r uct ur e, is r efer r ed t o t hr oughout t his chapt er as t he design model.

The default values for F, P, H, and K ar e all 1.

When you specify your design model, in addit ion t o F, P, H, and t he feedback

st r uct ur e, you can specify t he design model name. To name t he design model,

click in t he edit able t ext box in t he Import LTI De si gn Mode l window below

Name , and ent er t he name you want for t he design model. For t his example,

change t he design model name t o Gservo.

To specify F, P, and H for t his example, we use t he Works pace r adio but t on,

which is t he default select ion. A list of t he LTI object s in your wor kspace

appear s in t he model list box under Workspace Conte nts.

In gener al, t o impor t design model component s fr om t he wor kspace t o t he GUI:

1 Select a given model in t he Workspace Contents list box t o be loaded int o

eit her F, P, or H.

2 Click on t he ar r ow but t ons next t o t he design model component you want t o

specify.

8 The Root Locus Design GUI

8-12

To specify t he design model component s for t his ser vomechanism example:

1 Load t he linear ized ser vomechanism model Gservo int o t he plant P, by fir st

select ing it and t hen select ing t he ar r ow but t on.

The Import LTI Desi gn Model window looks like t his aft er you specify bot h

t he plant , P, and t he model name as Gservo.

2 Pr ess t he OK but t on.

Use the arrow buttons to transfer selected models

from the listbox to the design model components,

in this case, to the plant, P.

Controller Design Using the Root Locus Design GUI

8-13

The r oot locus of t he design model is displayed in t he plot r egion of t he GUI.

Your Root Locus Design GUI looks like t his.

Not ice t hat t he design model name appear s in t he t it le bar .

Changing the Gain Set Point and Zooming

The gain set point is t he value of t he gain you apply t o t he compensat or t o

det er mine t he closed-loop poles. This value appear s in t he Gai n t ext box on t he

GUI.

In t his sect ion, we use some of t he basic funct ions of t he Root Locus Design GUI

t o analyze a r oot locus in t he plot r egion. We cover how t o change t he gain set

point , along wit h t he closed-loop pole locat ions, and how t o use t he GUI zoom

t ools.

Let ’s begin by seeing how much gain you can apply t o t he compensat or and st ill

r et ain st abilit y of t he closed-loop syst em.

The r ed squar es on each br anch of t he r oot locus mar k t he locat ions of t he

closed-loop poles associat ed wit h t he gain set point . The syst em becomes

.

The (red) squares

are the closed-loop

poles corresponding

to the value of the

compensator gain.

The feedback structure

selected in the Import LTI

Design Model window

8 The Root Locus Design GUI

8-14

unst able if t he gain set point is incr eased so as t o place any of t he closed-loop

poles in t he r ight -half of t he complex plane.

You can t est t he limit s of st abilit y by eit her :

•Dr agging t he closed-loop poles ar ound t he locus t o change t he gain set point

•Changing t he gain set point manually

In t his example we do t he for mer .

Dragging Closed-loop Poles to Change the Gain Set Point

To see by how much t he gain can be incr eased while maint aining t he

closed-loop poles in t he left -half of t he complex plane:

1 Move t he mouse point er over a r ed squar e mar king one of t he complex poles

near est t he imaginar y axis. Not ice how t he point er becomes a hand.

2 Gr ab t he closed-loop pole by holding down t he left mouse but t on when t he

hand appear s.

3 Dr ag t he pole close t o t he imaginar y axis.

4 Release t he mouse but t on. The gain changes as t he closed-loop set point is

r ecomput ed.

Controller Design Using the Root Locus Design GUI

8-15

The following t wo figur es capt ur e t his pr ocedur e.

The r ight -most pair of closed-loop poles seem t o be on t he imaginar y axis.

Act ually, t hey ar e only close. Let ’s use t he zoom cont r ols t o impr ove t his r esult .

Zooming

You can use t he Zoom cont r ols on t he lower r ight of t he Root Locus Design GUI

t o zoom in on a r egion of t he locus, or zoom out t o show t he ent ir e locus.

As you get close to a closed-

loop pole on the locus, the

mouse pointer becomes a hand.

The poles appear to be on the imaginary

axis.

8 The Root Locus Design GUI

8-16

The Zoom cont r ols ar e shown below.

Once it is select ed, you can oper at e any of t he fir st t hr ee Zoom but t ons in one

of t wo ways.

•Use your mouse t o rubberband ar ound t he ar ea on t he plot r egion you want

t o focus on. Rubber banding involves clicking and holding t he mouse down,

while dr agging t he mouse point er ar ound t he r egion of int er est on t he scr een.

•Click in t he plot r egion in t he vicinit y on which you want t o focus.

To move t he closed-loop poles closer t o t he imaginar y axis on your r oot locus by

zooming wit h t he r ubber band met hod:

1 Zoom in X-Y by select ing t he left -most Zoom but t on.

2 Use your mouse t o r ubber band t he r egion of t he imaginar y axis near t he

closed-loop pole t her e.

3 Readjust t he closed-loop pole posit ion by gr abbing it wit h t he mouse and

moving it unt il it r est s on t he imaginar y axis.

4 Zoom out by clicking on t he four t h Zoom but t on, (t he icon is a pair of

binocular s).

Zoom in both the x- and

y- directions.

Zoom in the x-direction.

Zoom in the y-direction.

Zoom out to full view.

Controller Design Using the Root Locus Design GUI

8-17

The use of zooming t o find t he limit s of st abilit y on t he r oot locus is depict ed in

t he following t hr ee figur es.

After you drag that pole close to

the imaginary axis, use the left-most

Zoom button to zoom in.

Move the closed-loop pole to

the imaginary axis to fine-tune

your gain adjustment.

8 The Root Locus Design GUI

8-18

The cr it ical gain value for st abilit y is appr oximat ely 43.9.

Note: You can also t est how much t he gain can be incr eased while

maint aining st abilit y by ar bit r ar ily applying differ ent values of t he gain in

t he t ext ar ea next t o Gai n (pr essing t he Ente r key aft er ent er ing each value)

unt il one pair of complex poles r eaches t he imaginar y axis.

Aft er using t he zoom t ools on t he GUI, you may want t o st or e one set of zoom

focus set t ings so t hat you may lat er r et ur n t o focus on t hat same r egion of t he

locus.

Use the right-most Zoom button

to zoom out.

The limiting gain set point for

stability

You can also store this zoom focus set-

ting using the Axes settings described

in the next section.

Controller Design Using the Root Locus Design GUI

8-19

Storing and Retrieving Axes Limits

You can st or e and change axes limit s in t wo ways:

•Using t he Axe s se tti ngs t oolbar

•Using t he Set Axes Pre ferences menu it em fr om t he Tools menu

For mor e infor mat ion on squar e axes and/or equal axes, t ype help axis at t he

command line.

To use t he Axes se tti ngs t oolbar t o save t he cur r ent axes limit s, select t he

left -most but t on shown below.

If you change t he axes limit s by zooming, you can always r et ur n t o t he saved

axes limit s by select ing t he second Axes se tti ngs but t on.

To t r y out t hese t ools:

•Select t he left -most Axes setti ngs but t on.

•Zoom in on a r egion of t he r oot locus.

•Select t he second Axes setti ngs but t on.

Save current axes

limits.

Retrieve a set of

saved axes limits.

Toggle the axes between

a square and rectangle.

Toggle the aspect ratio

of the axes between

equal and unequal.

8 The Root Locus Design GUI

8-20

You can also set or r evise axes limit s and ot her axes pr efer ences in t he Root

Locus Axes Pre ferences window. To open t his window, select Set Axes

Prefere nces fr om t he Tools menu.

If you have alr eady st or ed axes limit s using Axes s etti ngs , t hese limit s appear

in t his window in t he Li mi ts field. You can r eset t hese limit s by t yping in new

values. To apply any changes t o t he ent r ies in t his window, click on OK aft er

making t he changes.

Displaying System Responses

Befor e you design your compensat or , you may want t o conduct some r esponse

analysis of your closed-loop syst em evaluat ed at a fixed value of t he gain.

You can access some of t he syst em r esponse analysis capabilit ies of t he LTI

Viewer (see Chapt er 6, “The LTI Viewer ”) t hr ough t he checkboxes locat ed in

t he lower por t ion of t he Root Locus Design GUI. Checking one or sever al of

t hese boxes opens an LTI Viewer window t hat displays t he cor r esponding plot s.

The LTI Viewer window t hat opens is dynamically linked t o t he Root Locus

Design GUI: any changes made t o t he syst em on t he GUI t hat affect t he gain

set point will effect a cor r esponding change on t he displayed LTI Viewer plot s.

For t his example, we want t o know if t he st ep r esponse meet s our design

cr it er ia. The cur r ent value for t he gain set point is about 44. Clear ly t his value

of t he gain would t est t he limit s of st abilit y of our syst em. Let ’s choose a

r easonable value for t he gain (say, 20) and look at t he st ep r esponse.

You can also use this window to change the

colors of the root locus plot and the compen-

sator poles and zeros, and the color and type

of marker used for the closed-loop poles.

Type of marker used to desig-

nate the closed-loop poles

Select Apply to implement changes and keep this window

open. Select OK to implement changes and close the window.

Controller Design Using the Root Locus Design GUI

8-21

Change t he gain t o 20 by edit ing t he t ext box next t o Gai n, and pr essing t he

Enter key. Not ice t hat t he locat ions of t he closed-loop poles on t he r oot locus

ar e r ecalculat ed for t he new gain set point .

Your Root Locus Design GUI looks like t his now.

8 The Root Locus Design GUI

8-22

Check t he Ste p box, as shown below.

Once you check t he Step box, an LTI Viewer window opens. The plot t ype for

t his LTI Viewer is t he st ep r esponse and t his cannot be changed.

This closed-loop r esponse does not meet t he desir ed set t ling t ime r equir ement

(.05 seconds or less). You can design a compensat or so t hat you do meet t he

r equir ed specificat ions.

Designing a Compensator to Meet Specifications

Since t he cur r ent closed-loop syst em doesn’t meet bot h of t he r equir ed design

specificat ions, let ’s fir st t r y incr easing t he gain t o about 33. You can incr ease

t he gain in t wo ways:

•Edit t he Gai n t ext box and pr ess t he Ente r key.

•Move t he closed loop set point ar ound wit h t he mouse, while incr easing t he

gain.

Controller Design Using the Root Locus Design GUI

8-23

To incr ease t he gain t o about 33 using your mouse:

1 Hold your mouse but t on down as you click on any of t he r ed squar es.

2 Dr ag t he squar e in t he dir ect ion of incr easing gain, wit hout allowing any of

t he closed-loop poles t o ent er t he r ight half of t he complex plane. If, when

you st ar t t o move t he r ed squar e, you see t he gain value in t he Gai n box

decr easing, dr ag it in t he opposit e dir ect ion.

3 Release t he mouse but t on when t he gain is near 33.

Your GUI looks like t his.

8 The Root Locus Design GUI

8-24

The st ep r esponse plot on t he dynamically linked LTI Viewer aut omat ically

updat es when you r elease t he mouse but t on.

As you may have not iced, t he r esponse t ime decr eases wit h incr easing gain,

while t he over shoot incr eases. Her e we no longer meet t he over shoot

r equir ement . Since t his gain is alr eady r elat ively lar ge, it ’s likely t hat we will

not be able t o meet bot h design r equir ement s using only a gain for t he

compensat or . This conject ur e is suppor t ed when you specify t he design r egion

boundar ies on t he r oot locus for t hese design r equir ement s. We do t his in t he

next subsect ion.

Specifying Design Region Boundaries on the Root Locus

If, as in our example, your design cr it er ia ar e specified in t er ms of st ep

r esponse char act er ist ics, you may want t o use t he gr id and boundar y

const r aint opt ions t hat ar e accessible fr om t he Add Gri d/Boundary menu it em

in t he Tools menu on t he Root Locus Design GUI. These opt ions allow you t o

use second or der syst em design cr it er ia t o inscr ibe t he boundar ies of design

r egion dir ect ly on t he r oot locus plot , or apply a gr id t o t he plot .

Note: The boundar ies you apply t o t he Root Locus Design GUI based on LTI

syst em design cr it er ia (set t ling t ime, damping r at io, nat ur al fr equency, and

peak over shoot ) ar e comput ed r elat ive t o second-or der syst ems only.

Ther efor e, for higher or der syst ems, t hese boundar ies pr ovide appr oximat ions

t o t he design r egion.

Controller Design Using the Root Locus Design GUI

8-25

Let ’s place appr oximat e design r egion boundar ies on our r oot locus plot based

on our design specificat ions. To do so, select t he Add Gri d/Boundary menu

it em in t he Tools menu.

Our design specificat ions r equir e t hat t he (2 per cent ) set t ling t ime be less t han

.05 seconds, and t he maximum over shoot less t han 5 per cent . For second-or der

syst ems, t he over shoot r equir ement can be t r anslat ed dir ect ly as a

r equir ement on t he damping r at io of about .7 (see [2]).

Aft er you ent er t hese values in t he appr opr iat e t ext fields for our specificat ions,

your Gri d and Cons trai nt Opti ons window looks like t his.

Check this box to place a grid on the root locus,

either for lines of constant damping ratio (with circles

of constant natural frequency), or lines of constant peak

overshoot.

You can enter lists of numbers here to

specify several boundaries for any of

these criteria. Separate numbers in a

list by spaces or commas.

Checks in these boxes indicate the boundaries will appear on the root

locus once you select OK or Apply. Unchecking them toggles the

boundary off.

8 The Root Locus Design GUI

8-26

Aft er you pr ess OK, t he Root Locus Design GUI calculat es and displays t he

specified boundar ies.

Not all four br anches of t he r oot locus ar e wit hin t he design r egion. Let ’s t r y

adding poles and zer os t o our compensat or t o see if we can meet t he design

cr it er ia.

Placing Compensator Poles and Zeros: General Information

Ther e ar e t hr ee t ypes of par amet er s specifying t he compensat or :

•Poles

•Zer os

•Gain

Damping ratio boundary

Settling time boundary

The design region lies

within this wedge to the

left of the settling time

boundary.

Controller Design Using the Root Locus Design GUI

8-27

Once you have t he gain specified, you can add poles or zer os t o t he

compensat or . You can add poles and zer os t o t he compensat or (or r emove t hem)

in t wo ways:

•Use but t ons on t he r oot locus t oolbar sect ion of t he GUI for pole/zer o

placement .

•Use t he Edi t Compens ator menu it em on t he Tools menu.

The r oot locus t oolbar is convenient for graphically placing compensat or poles

and zer os so t hat you meet t he design specificat ions for a given gain set point .

This met hod may r equir e a cer t ain amount of t r ial and er r or .

You can use t he Edi t Compe nsator menu it em t o:

•Fine-t une compensat or par amet er values for design implement at ion.

•Revise or implement an exist ing compensat or design.

For t his example we fir st use t he r oot locus t oolbar t o place compensat or poles

and zer os on t he r oot locus, and t hen use t he Edi t Compens ator menu it em t o

set t he compensat or pole and zer o locat ions for a specific compensat or solut ion.

Placing Compensator Poles and Zeros Using the Root Locus Toolbar

The r oot locus t oolbar is locat ed on t he left side of t he GUI, above t he plot

r egion. The figur e below descr ibes t he r oot locus t oolbar but t ons.

Drag compensator poles

and zeros and closed-loop

Operate in default mode:

Add compensator

poles.

Add compensator

zeros.

Erase compensator

poles/zeros.

Edit the compensator gain.

poles.

8 The Root Locus Design GUI

8-28

The default mode for t he t oolbar is t he drag mode. In t his mode, you can:

•Click on a specific locat ion on t he r oot locus t o place a closed-loop pole t her e

(and consequent ly r eassign t he gain set point ).

•Dr ag any of t he closed-loop poles along it s br anch of t he r oot locus (also

r eassigning t he gain set point ).

•Dr ag any of t he compensat or poles or zer os ar ound t he complex plane t o

change t he compensat or .

To add a complex conjugat e compensat or pole pair on t he r oot locus plot :

1 Select t he add pole but t on (t he second but t on in t he r oot locus t oolbar ).

2 Click on t he plot r egion wher e you would like t o add one of t he complex poles.

Some of t he feat ur es of using t he r oot locus t oolbar t o add a pole ar e:

•While t he add pole but t on is depr essed, t he cur sor changes t o an ar r ow wit h

an x at it s t ip whenever it is over t he plot r egion. This indicat es t he t oolbar

is in t he “add pole” mode.

•Aft er you add t he poles, t he add pole but t on pops back up and t he default

drag mode is r est or ed. The added compensat or poles appear in a differ ent

color . The default color is r ed.

•The LTI Viewer r esponse plot s change as soon as t he pole is added.

•The t ext displayed in t he Current Compens ator r egion of t he GUI now

displays t he new pair of poles.

Controller Design Using the Root Locus Design GUI

8-29

Tr y placing a pair of complex poles just above t he r ight -most r eal closed-loop

pole. The r esult ing r oot locus plot looks like t his.

Similar ly, t o add a pair of complex zer os t o t he compensat or :

1 Select t he add zero but t on fr om t he r oot locus t oolbar (t hir d but t on fr om t he

left ).

2 Click on t he plot r egion wher e you would like t o add one of t he complex zer os.

Add compensator poles here.

8 The Root Locus Design GUI

8-30

Tr y adding a pair of complex zer os just t o t he left of and a lit t le bit below t he

complex closed-loop poles closest t o t he imaginar y axis. The r esult ing r oot locus

and st ep r esponse plot s ar e as follows.

If your st ep r esponse is unst able, lower t he gain. In t his example, t he r esult ing

st ep r esponse is st able, but it st ill doesn’t meet t he design cr it er ia.

As you can see, t he compensat or design pr ocess can involve some t r ial and

er r or . You can t r y dr agging t he compensat or poles, compensat or zer os, or t he

closed-loop poles ar ound t he r oot locus unt il you meet t he design cr it er ia.

Alt er nat ively, you can edit t he compensat or using t he solut ion pr ovided in t he

next sect ion.

Note: You can follow t he same pr ocedur e t o add a single r eal pole or zer o t o

t he compensat or by clicking on t he r eal axis.

Add compensator zeros here.

Controller Design Using the Root Locus Design GUI

8-31

Editing Compensator Pole and Zero Locations

In t his sect ion we use t he Edi t Compe nsator window t o design a compensat or

wit h t he following char act er ist ics:

•Gain:

•Poles:

•Zer os:

You can access t he Edi t Compensator window in one of t hr ee ways:

•Double-click on any of t he Current Compe ns ator t ext .

•Click on t he (blue) compensat or block in t he feedback st r uct ur e on t he GUI.

•Select Edi t Compensator fr om t he Tools menu.

This figur e shows how t o choose t his menu it em on t he GUI.

Wit h eit her met hod, you open t he Edi t Compensator window shown in t he

figur e below.

9.7

110 – 140i t

70 – 270i t

8 The Root Locus Design GUI

8-32

You can use t he Edi t Compens ator window t o:

•Edit t he locat ions of compensat or poles and zer os.

•Add compensat or poles and zer os.

•Delet e compensat or poles and zer os.

•Change t he name of t he compensat or (This name is used when expor t ing t he

compensat or ).

For t his example, edit t he poles and zer os t o be at and

r espect ively.

Your GUI looks like t his.

If, in addit ion, you want t o add poles t o t he compensat or :

1 Click on Add Pole . A new edit able t ext field appear s.

2 Ent er t he new pole locat ion in t he t ext field.

The pr ocedur e is t he same for adding zer os, only use t he Add Zero but t on in

place of t he Add Pole but t on. To er ase any poles or zer os, select t he Dele te

checkbox.

Befor e closing t his window by select ing OK, you can also opt ionally change t he

name of t he compensat or .

Note: You can also er ase poles or zer os on t he r oot locus using t he er ase

but t on on t he r oot locus t oolbar. See “Er asing Compensat or Poles and Zer os”

on page 8-41

110 – 140i , t

70 – 270i , t

Controller Design Using the Root Locus Design GUI

8-33

Wit h t he gain set point at 9.7, your r oot locus looks as follows.

Note: Whenever t he numer at or or denominat or ar e t oo long for t he Current

Compens ator field, a default numK or denK is displayed. To display t he

act ual numer at or or denominat or, r esize t he Root Locus Design GUI.

8 The Root Locus Design GUI

8-34

To check wher e t he closed-loop r oot s ar e wit h r espect t o t he boundar y of t he

design r egion, let ’s zoom in a bit .

We don’t have all of t he closed-loop poles in t he design r egion, but let ’s see if we

meet t he st ep r esponse specificat ions. The updat ed LTI Viewer plot of t he st ep

r esponse looks like t his.

Controller Design Using the Root Locus Design GUI

8-35

The st ep r esponse looks good. However , t o be cer t ain t hat you’ve met your

design specificat ions, you can check t he set t ling t ime and peak r esponse

char act er ist ics fr om t he r ight -click menu. To do t his:

1 Right -click anywher e in t he plot r egion.

2 Select Settli ng Ti me fr om t he Characte ri s ti cs menu.

3 Set your mouse point er t o t he set t ling t ime mar ker and click t o display t he

value.

The LTI Viewer will look like t his.

As you can see, t he set t ling t ime is less t han .05 seconds, and t he over shoot is

less t han 5 per cent . You’ve met t he design specificat ions and you’r e done. You

didn’t need your closed-loop poles t o be ent ir ely in t he design r egion, because

you act ually have a sixt h-or der syst em wit h some fast dynamics, as opposed t o

having only a second-or der syst em.

Marker for the

settling time

8 The Root Locus Design GUI

8-36

Saving the Compensator and Models

Now t hat you have successfully designed your compensat or , you may want t o

save your design par amet er s for fut ur e implement at ion. You can do t his by

select ing Export fr om t he Fi le menu on t he Root Locus Design GUI. The

window shown below opens.

The var iable list ed in t he Export Li s t on t he Export LTI Mode ls /

Compe nsators GUI ar e eit her pr eviously named by you (on t he Li st Mode l

Poles /Ze ros or t he Edi t Compe nsator windows) or have default names. They

ar e coded as follows:

•DM: The design model

•OL: The open-loop model

•CL: The closed-loop model

•K: The compensat or

To expor t your compensat or t o t he wor kspace:

1 Select t he compensat or in t he Export Li s t.

2 Click on t he Export to Works pace but t on.

The Export LTI Model/Compens ators window is closed when you click on one

of t he expor t but t ons. If you go t o t he MATLAB pr ompt and t ype

who

Save to the disk as a

file with a .mat extension.

Save to the workspace.

Use your mouse to select or multi-

select models to save.

Controller Design Using the Root Locus Design GUI

8-37

t he compensat or is now in t he wor kspace, in t he var iable named comp.

Then t ype

comp

t o see t hat t his var iable is st or ed in zpk for mat .

8 The Root Locus Design GUI

8-38

Additional Root Locus Design GUI Features

This sect ion descr ibes sever al feat ur es of t he Root Locus Design GUI not

cover ed in t he ser vomechanism example. These ar e list ed as follows:

•Specifying design models: gener al concept s:

- Cr eat ing models manually wit hin t he GUI

- Designat ing t he model sour ce

•Get t ing help wit h t he Root Locus Design GUI

•Er asing compensat or poles and zer os

•List ing poles and zer os

•Pr int ing t he r oot locus

•Dr awing a Simulink diagr am of t he closed-loop model

•Conver t ing bet ween cont inuous and discr et e models

•Clear ing dat a

Specifying Design Models: General Concepts

In t his sect ion we pr ovide gener al concept s for specifying t he design model by

using one or bot h of t he following met hods:

•Cr eat ing models manually wit hin t he GUI

•Designat ing t he model sour ce:

- The MATLAB wor kspace

- A MAT-file

- An open or saved Simulink model

Creating Models Manually Within the GUI

You can cr eat e models for r oot locus analysis manually in t he Import LTI

De si gn Mode l window using tf, ss, or zpk. To do so, just edit t he t ext boxes

next t o P, F, or H using any of t hese MATLAB expr essions. You can also use a

scalar number t o specify P, F, or H.

Additional Root Locus Design GUI Features

8-39

Designating the Model Source

The sour ce of your design model dat a is indicat ed in t he Import From field

shown below.

If you ar e loading your models fr om MAT-files or Simulink models saved on

your disk, you ar e pr ompt ed t o ent er t he name of t he file in t he edit able t ext

box below t he Import From r adio but t ons. You can also select t he Brows e

but t on t o sear ch for and select t he file. The Si muli nk r adio but t on also allows

you t o load SISO LTI blocks fr om an open Simulink model, by ent er ing t he

name of t he model in t he t ext box.

When you select t he model sour ce, it s cont ent s ar e shown in t he model list box

locat ed in t he cent r al por t ion of t he Import LTI De si gn Mode l window. The

model list box cont ains t he following dat a:

•For Works pace or MAT-fi le : All LTI models in t he wor kspace, or in t he

select ed MAT-file

•For Si muli nk: All t he LTI blocks in t he select ed Simulink diagr am

Note: If you want t o load models saved in mor e t han one MAT-file, load t hese

int o t he MATLAB wor kspace before select ing Import Mode l on t he Root Locus

Design GUI.

Getting Help with the Root Locus Design GUI

You can obt ain inst r uct ions on how t o use t he Root Locus Design GUI eit her

using t he He lp menu, fr om t he st at us bar , or by using t he t oolt ips.

8 The Root Locus Design GUI

8-40

Using the Help Menu

Click on t he He lp menu and you find t hat it cont ains five menu it ems:

•Mai n Help

•Edi t Compensator

•Convert Model

•Add Gri d/Boundary

•Se t Axi s Pre fe rence s

The fir st menu it em, Mai n Help, opens a help window t hat descr ibes how t o

use t he cont r ols locat ed on t he Root Locus Design GUI. The r emaining menu

it ems pr ovide addit ional infor mat ion on t he feat ur es you can access fr om t he

Tools menu.

Using the Status Bar for Help

The st at us bar at t he bot t om of t he Root Locus Design GUI:

•Pr ovides you wit h infor mat ion, hint s, and er r or messages as you pr oceed

t hr ough your design.

•Let s you know if you have t r ied t o under t ake an act ion t he GUI is not capable

of, or if a GUI oper at ion you have per for med has successfully been

complet ed.

•Pr ovides infor mat ion about t he locat ion of newly placed compensat or poles

and zer os, as well as t he damping r at io, nat ur al fr equency, and locat ion of

poles and zer os as you dr ag t hem.

Tooltips

You can obt ain simple r eminder s (t oolt ips) on how t o use t he Root Locus Design

GUI by moving your mouse and put t ing t he cur sor over one of t hese feat ur es.

For example, if you put t he cur sor over t he Ste p checkbox, it s t oolt ip,

Clos ed-loop s te p re sponse , appear s just below t he but t on. When a t oolt ip is

available, a small bubble cont aining infor mat ion about t he feat ur e you select ed

appear s. This bubble disappear s when you move t he mouse again.

Additional Root Locus Design GUI Features

8-41

Erasing Compensator Poles and Zeros

You can delet e any compensat or poles and zer os in one of t wo ways:

•Check t he associat ed Dele te box on t he Edi t Compens ator... window

obt ained fr om t he Tools menu.

•Click on t he er ase but t on (four t h fr om left on t he r oot locus t oolbar ) and click

on t he pole or zer o t o delet e.

Aft er using t he r oot locus t oolbar er ase but t on t o delet e a pole or zer o, t he

following occur s:

•The er ase but t on pops up and t he default drag mode is r est or ed.

•The zer o or pole you er ased (and, if applicable, it s conjugat e) is r emoved fr om

t he r oot locus and fr om t he Curre nt Compensator t ext .

•The r oot locus plot and any linked LTI Viewer r esponse plot s ar e

r ecalculat ed.

Listing Poles and Zeros

At any point when t he Root Locus Design GUI is open, you can view:

•The closed-loop pole locat ions associat ed wit h t he cur r ent Gai n set t ing

•The poles, zer os, and gain of each design model component

8 The Root Locus Design GUI

8-42

To view t he cur r ent closed-loop poles:

•Select Li s t Close d-Loop Pole s fr om t he Tools menu. If you select t his menu,

a window list ing t he closed-loop poles associat ed wit h t he cur r ent gain set

point opens.

•Click on t he OK but t on t o close t he window.

Note: You cannot edit t he closed-loop pole locat ions list ed in t his window.

To view t he design model poles and zer os, you can eit her :

•Select t he Li s t Model Pole s/Zeros it em fr om t he Tools menu.

•Click on any of t he design model blocks in t he Fe edback Structure . These

ar e t he yellow F, P, and H blocks.

Additional Root Locus Design GUI Features

8-43

The following window opens.

For each component of t he design model, t his window t ells you:

•The component name

•The t ype of LTI model t hat t he component is (t hat is, ss, zpk, or tf)

•The component ’s pole and zer o locat ions

•The associat ed numer at or and denominat or of t he model t r ansfer funct ion

You can edit any of t he model names in t he t ext boxes pr ovided. Select ing OK

closes t his window and implement s t he changes you made t o design model

names.

Befor e closing t his window, you can also use t he Show Obje ct but t ons in t his

window t o pr ovide a MATLAB display of t he associat ed LTI model. The

following is t he infor mat ion pr ovided for t he plant .

Select OK t o close t his window.

8 The Root Locus Design GUI

8-44

Note: The names you ent er in t his window ar e only used when you gener at e

a Simulink diagr am of t he closed-loop st r uct ur e.

To list t he denominat or , (r espect ively, t he numer at or , including t he gain)

associat ed wit h a given component of t he design model, in t he Li st Mode l

Poles /Ze ros window, click on Pole s, (r espect ively, Zeros) of t hat component .

When you do, a window pr oviding t he select ed infor mat ion opens.

The Show Object but t on in t his window opens a dialog t hat displays t he LTI

model exact ly as it would be shown at t he MATLAB pr ompt .

Printing the Root Locus

You can pr int t he locus t he GUI is displaying by:

1 Select ing Pri nt Locus fr om t he Fi le menu

2 Clicking t he OK but t on on t he pr int er dialog t hat appear s

When you select Pri nt Locus a new MATLAB figur e window cont aining t he

locus appear s. This is t he figur e t hat is pr int ed when you pr ess OK.

Note: You can also gener at e t his r oot locus MATLAB figur e window by

select ing Se nd Locus to Fi gure fr om t he Fi le menu. This figur e r emains open

unt il you close it .

Drawing a Simulink Diagram

If you have Simulink, you can use t he Root Locus Design GUI t o aut omat ically

dr aw a Simulink diagr am of t he closed-loop st r uct ur e. To do t his:

1 Select Draw Si muli nk Di agram fr om t he Fi le menu.

2 Answer Yes t o t he subsequent dialog box quest ion t o confir m t hat you want

t he design model dat a t o be st or ed in t he wor kspace using it s cur r ent names,

or answer No t o t his quest ion, if you want t o abor t dr awing t he diagr am.

Additional Root Locus Design GUI Features

8-45

If you answer ed Ye s, a Simulink diagr am such as t his appear s.

The Simulink diagr am is linked t o t he wor kspace, not t o t he Root Locus Design

GUI. If you change your compensat or design in t he Root Locus Design GUI, you

must expor t it t o t he wor kspace in or der t o r eflect t hese changes in t he

Simulink diagr am.

Converting Between Continuous and Discrete

Models

The Root Locus Design GUI can be applied t o eit her discr et e or

cont inuous-t ime syst ems, and you can conver t bet ween t he t wo t ypes of

syst ems at any t ime dur ing t he design pr ocess. However , t he design model and

compensat or must bot h be eit her cont inuous or discr et e.

To obt ain t he discr et e equivalent of your cur r ent compensat or design, select

Conve rt Model/Compens ator fr om t he Tools menu.

The plant, P (Gservo)

The root locus

design compensator, K

Sensor dynamics, H

Pre-filter, F

8 The Root Locus Design GUI

8-46

The Conve rt Model/Compens ator window, shown below, opens.

Once you select a discr et izat ion met hod, sampling t ime, and cr it ical fr equency

(if r equir ed), click on t he OK but t on. The Convert Mode l/Compe nsator

window closes and t he discr et izat ion is per for med. At t his point :

•The design model and compensat or ar e discr et ized.

•The Current Compens ator t ext displays a syst em using t he complex

var iable 'z'.

•The r oot locus for t he discr et e-t ime syst em r epr esent ing t he conver t ed

cont inuous-t ime syst em is plot t ed.

•Any linked LTI Viewer r esponse plot s ar e updat ed.

•The gr ids and boundar ies ar e conver t ed int o t he discr et e plane.

You can also use t he Convert Mode l/Compe nsator GUI t o r et r ieve t he

cont inuous syst em, or t o r e-sample t he discr et e syst em using a differ ent

sampling t ime. These opt ions ar e select ed fr om t he r adio but t ons at t he t op of

t his GUI.

Clearing Data

You can clear t he design model and/or compensat or fr om t he Root Locus Design

GUI using opt ions available in t he Tools menu:

•Clear Mode l: r emoves t he plant , pr e-filt er , and sensor dynamics and

r eplaces t hem all wit h unit y gains.

•Cle ar Compens ator: r emoves t he compensat or poles and zer os, and r eset s

t he gain t o one.

Choose the discretization

method here.

Enter the sampling time.

Critical frequency is only

required for the Tustin

method.

Click on OK to convert

the model to your

specifications and close

this window.

Additional Root Locus Design GUI Features

8-47

To t est t hese feat ur es, select Clear Mode l. Not ice t hat your compensat or is not

alt er ed, and it s poles and zer os r emain plot t ed in t he r oot locus plot r egion of

t he GUI.

Now, select Cle ar Compens ator. The Root Locus Design GUI r et ur ns t o t he

st at e it was in when you fir st opened it and you ar e r eady t o st ar t a new design.

8 The Root Locus Design GUI

8-48

References

[1] Clar k, R.N., Control S ystem Dynamics, Cambr idge Univer sit y Pr ess, 1996.

[2] Dor f, R.C. and R.H. Bishop, Modern Control S ystems, 8t h Edit ion, Addison

Wesley, 1997.

9

Design Case St udies

Yaw Damper for a 747 J et Transport . . . . . . . . . 9-3

Open-Loop Analysis . . . . . . . . . . . . . . . . . 9-6

Root Locus Design . . . . . . . . . . . . . . . . . . 9-9

Washout Filt er Design . . . . . . . . . . . . . . . . 9-14

Hard-Di sk Re ad/Wri te Head Controlle r . . . . . . . . 9-20

LQG Regulati on . . . . . . . . . . . . . . . . . . 9-31

Pr ocess and Dist ur bance Models . . . . . . . . . . . . 9-31

LQG Design for t he x-Axis . . . . . . . . . . . . . . . 9-34

LQG Design for t he y-Axis . . . . . . . . . . . . . . . 9-42

Cr oss-Coupling Bet ween Axes . . . . . . . . . . . . . 9-43

MIMO LQG Design . . . . . . . . . . . . . . . . . . 9-47

Kalman Fi lt ering . . . . . . . . . . . . . . . . . . 9-50

Discr et e Kalman Filt er . . . . . . . . . . . . . . . . 9-50

St eady-St at e Design . . . . . . . . . . . . . . . . . 9-51

Time-Var ying Kalman Filt er . . . . . . . . . . . . . . 9-57

Time-Var ying Design . . . . . . . . . . . . . . . . . 9-58

Refer ences . . . . . . . . . . . . . . . . . . . . . 9-63

9 Design Case Studies

9-2

This chapt er cont ains four det ailed case st udies of cont r ol syst em design and

analysis using t he Cont r ol Syst em Toolbox.

Demonst r at ion files for t hese case st udies ar e available as jetdemo.m,

diskdemo.m, milldemo.m, and kalmdemo.m. To r un any of t hese demonst r at ions,

t ype t he cor r esponding name at t he command line, for example,

jetdemo

Case St udy 1 A yaw damper for a 747 jet t r anspor t air cr aft t hat

illust r at es t he classical design pr ocess.

Case St udy 2 A har d-disk r ead/wr it e head cont r oller t hat illust r at es

classical digit al cont r oller design.

Case St udy 3 LQG r egulat ion of t he beam t hickness in a st eel r olling

mill.

Case St udy 4 Kalman filt er ing t hat illust r at es bot h st eady-st at e and

t ime-var ying Kalman filt er design and simulat ion.

Yaw Damper for a 747 Jet Transport

9-3

Yaw Damper for a 747 Jet Transport

This case st udy demonst r at es t he t ools for classical cont r ol design by st epping

t hr ough t he design of a yaw damper for a 747 jet t r anspor t air cr aft .

The jet model dur ing cr uise flight at MACH = 0.8 and H = 40,000 ft . is

A = [–0.0558 –0.9968 0.0802 0.0415

0.5980 –0.1150 –0.0318 0

–3.0500 0.3880 –0.4650 0

0 0.0805 1.0000 0];

B = [ 0.0729 0.0000

–4.7500 0.00775

1.5300 0.1430

0 0];

C = [0 1 0 0

0 0 0 1];

D = [0 0

0 0];

The following commands specify t his st at e-space model as an LTI object and

at t ach names t o t he st at es, input s, and out put s.

states = {'beta' 'yaw' 'roll' 'phi'};

inputs = {'rudder' 'aileron'};

output = {'yaw' 'bank angle'};

sys = ss(A,B,C,D,'statename',states,...

'inputname',inputs,...

'outputname',outputs);

9 Design Case Studies

9-4

You can display t he LTI model sys by t yping sys. MATLAB r esponds wit h

a =

beta yaw roll phi

beta -0.0558 -0.9968 0.0802 0.0415

yaw 0.598 -0.115 -0.0318 0

roll -3.05 0.388 -0.465 0

phi 0 0.0805 1 0

b =

rudder aileron

beta 0.00729 0

yaw -0.475 0.00775

roll 0.153 0.143

phi 0 0

c =

beta yaw roll phi

yaw 0 1 0 0

bank angle 0 0 0 1

d =

rudder aileron

yaw 0 0

bank angle 0 0

Continuous-time model.

The model has t wo input s and t wo out put s. The unit s ar e r adians for beta

(sideslip angle) and phi (bank angle) and r adians/sec for yaw (yaw r at e) and

roll (r oll r at e). The r udder and ailer on deflect ions ar e in r adians as well.

Yaw Damper for a 747 Jet Transport

9-5

Comput e t he open-loop eigenvalues and plot t hem in t he -plane.

damp(sys)

Eigenvalue Damping Freq. (rad/s)

-7.28e-003 1.00e+000 7.28e-003

-5.63e-001 1.00e+000 5.63e-001

-3.29e-002 + 9.47e-001i 3.48e-002 9.47e-001

-3.29e-002 - 9.47e-001i 3.48e-002 9.47e-001

pzmap(sys)

This model has one pair of light ly damped poles. They cor r espond t o what is

called t he “Dut ch r oll mode.”

s

9 Design Case Studies

9-6

Suppose you want t o design a compensat or t hat incr eases t he damping of t hese

poles, so t hat t he r esult ing complex poles have a damping r at io wit h

nat ur al fr equency r ad/sec. You can do t his using t he Cont r ol Syst em

t oolbox analysis t ools.

Open-Loop Analysis

Fir st per for m some open-loop analysis t o det er mine possible cont r ol st r at egies.

St ar t wit h t he t ime r esponse (you could use step or impulse her e).

impulse(sys)

The impulse r esponse confir ms t hat t he syst em is light ly damped. But t he t ime

fr ame is much t oo long because t he passenger s and t he pilot ar e mor e

ζ 0.35 >

ω

n

1 <

Yaw Damper for a 747 Jet Transport

9-7

concer ned about t he behavior dur ing t he fir st few seconds r at her t han t he fir st

few minut es. Next look at t he r esponse over a smaller t ime fr ame of 20 seconds.

impulse(sys,20)

Look at t he plot fr om ailer on (input 2) t o bank angle (out put 2). The air cr aft is

oscillat ing ar ound a nonzer o bank angle. Thus, t he air cr aft is t ur ning in

r esponse t o an ailer on impulse. This behavior will pr ove impor t ant lat er in t his

case st udy.

9 Design Case Studies

9-8

Typically, yaw damper s ar e designed using t he yaw r at e as sensed out put and

t he r udder as cont r ol input . Look at t he cor r esponding fr equency r esponse

(input 1 t o out put 1).

bode(sys(1,1))

Fr om t his Bode diagr am, you can see t hat t he r udder has significant effect

ar ound t he light ly damped Dut ch r oll mode (t hat is, near r ad/sec). To

make t he design easier , select t he subsyst em fr om r udder t o yaw r at e.

% Select system with input 1 and output 1

sys11 = sys(1,1);

ω 1 =

Yaw Damper for a 747 Jet Transport

9-9

Root Locus Design

Since t he simplest compensat or is a st at ic gain, fir st t r y t o det er mine

appr opr iat e gain values using t he r oot locus t echnique.

% Plot the root locus for the (1,1) channel

rlocus(sys11)

9 Design Case Studies

9-10

This is t he r oot locus for negat ive feedback and shows t hat t he syst em goes

unst able almost immediat ely. If, inst ead, you use posit ive feedback, you may

be able t o keep t he syst em st able.

rlocus(–sys11)

sgrid

This looks bet t er . J ust using simple feedback you can achieve a damping r at io

of . You can gr aphically select some pole locat ions and det er mine t he

cor r esponding gain wit h rlocfind.

[k,poles] = rlocfind(–sys11)

ζ 0.45 =

Yaw Damper for a 747 Jet Transport

9-11

The '+' mar ks on t he pr evious figur e show a possible select ion. The

cor r esponding gain and closed-loop poles ar e

k

k =

2.7615

damp(poles)

Eigenvalue Damping Freq. (rad/s)

-1.01e+000 1.00e+000 1.01e+000

-3.03e-001 + 6.18e-001i 4.41e-001 6.89e-001

-3.03e-001 - 6.18e-001i 4.41e-001 6.89e-001

-3.33e-001 1.00e+000 3.33e-001

Next , for m t he closed-loop syst em so t hat you can analyze t his design.

cl11 = feedback(sys11,–k); % negative feedback by default

The closed-loop poles should mat ch t he ones chosen above (and t hey do).

damp(cl11)

Eigenvalue Damping Freq. (rad/s)

-3.33e-001 1.00e+000 3.33e-001

-3.03e-001 + 6.18e-001i 4.41e-001 6.89e-001

-3.03e-001 - 6.18e-001i 4.41e-001 6.89e-001

-1.01e+000 1.00e+000 1.01e+000

9 Design Case Studies

9-12

Plot t he closed-loop impulse r esponse for a dur at ion of 20 seconds.

impulse(cl11,20)

The r esponse set t les quickly and does not oscillat e much.

Now close t he loop on t he or iginal model and see how t he r esponse fr om t he

ailer on looks. The feedback loop involves input 1 and out put 1 of t he plant (use

Yaw Damper for a 747 Jet Transport

9-13

feedback wit h index vect or s select ing t his input /out put pair ). At t he MATLAB

pr ompt , t ype

cloop = feedback(sys,–k,1,1);

damp(cloop) % closed-loop poles

Eigenvalue Damping Freq. (rad/s)

-3.33e-001 1.00e+000 3.33e-001

-3.03e-001 + 6.18e-001i 4.41e-001 6.89e-001

-3.03e-001 - 6.18e-001i 4.41e-001 6.89e-001

-1.01e+000 1.00e+000 1.01e+000

9 Design Case Studies

9-14

Plot t he MIMO impulse r esponse.

impulse(cloop,20)

Look at t he plot fr om ailer on (input 2) t o bank angle (out put 2). When you move

t he ailer on, t he syst em no longer cont inues t o bank like a nor mal air cr aft . You

have over -st abilized t he spir al mode. The spir al mode is t ypically a ver y slow

mode and allows t he air cr aft t o bank and t ur n wit hout const ant ailer on input .

Pilot s ar e used t o t his behavior and will not like your design if it does not allow

t hem t o fly nor mally. This design has moved t he spir al mode so t hat it has a

fast er fr equency.

Washout Filter Design

What you need t o do is make sur e t he spir al mode does not move fur t her int o

t he left -half plane when you close t he loop. One way flight cont r ol designer s

have addr essed t his pr oblem is t o use a washout filt er wher e k H s ( )

Yaw Damper for a 747 Jet Transport

9-15

The washout filt er places a zer o at t he or igin, which const r ains t he spir al mode

pole t o r emain near t he or igin. We choose for a t ime const ant of

t hr ee seconds and use t he r oot locus t echnique t o select t he filt er gain . Fir st

specify t he fixed par t of t he washout by

H = zpk(0,–0.333,1);

Connect t he washout in ser ies wit h t he design model sys11 (r elat ion bet ween

input 1 and out put 1) t o obt ain t he open-loop model

oloop = H * sys11;

H s ( )

s

s a +

------------ =

a 0.333 =

k

s s a + ( ) ⁄

9 Design Case Studies

9-16

and dr aw anot her r oot locus for t his open-loop model.

rlocus(–oloop)

sgrid

Now t he maximum damping is about . You can select t he gain

pr oviding maximum damping gr aphically by

[k,poles] = rlocfind(–oloop)

ζ 0.25 =

Yaw Damper for a 747 Jet Transport

9-17

The select ed pole locat ions ar e mar ked by '+' on t he r oot locus above. The

r esult ing gain value and closed-loop dynamics ar e found by t yping

k

k =

2.5832

damp(poles)

Eigenvalue Damping Freq. (rad/s)

-1.37e+000 1.00e+000 1.37e+000

-1.76e-001 + 6.75e-001i 2.52e-001 6.98e-001

-1.76e-001 - 6.75e-001i 2.52e-001 6.98e-001

-4.74e-001 1.00e+000 4.74e-001

-3.88e-003 1.00e+000 3.88e-003

9 Design Case Studies

9-18

Look at t he closed-loop r esponse fr om r udder t o yaw r at e.

cl11 = feedback(oloop,–k);

impulse(cl11,20)

The r esponse set t les nicely but has less damping t han your pr evious design.

Finally, you can ver ify t hat t he washout filt er has fixed t he spir al mode

pr oblem. Fir st for m t he complet e washout filt er (washout + gain).

WOF = –k * H;

k H s ( )

Yaw Damper for a 747 Jet Transport

9-19

Then close t he loop ar ound t he fir st I/O pair of t he MIMO model sys and

simulat e t he impulse r esponse.

cloop = feedback(sys,WOF,1,1);

% Final closed-loop impulse response

impulse(cloop,20)

The bank angle r esponse (out put 2) due t o an ailer on impulse (input 2) now has

t he desir ed near ly const ant behavior over t his shor t t ime fr ame. Alt hough you

did not quit e meet t he damping specificat ion, your design has incr eased t he

damping of t he syst em subst ant ially and now allows t he pilot t o fly t he air cr aft

nor mally.

9 Design Case Studies

9-20

Hard-Disk Read/Write Head Controller

This case st udy demonst r at es t he abilit y t o per for m classical digit al cont r ol

design by going t hr ough t he design of a comput er har d-disk r ead/wr it e head

posit ion cont r oller .

Using Newt on’s law, a simple model for t he r ead/wr it e head is t he differ ent ial

equat ion

wher e is t he iner t ia of t he head assembly, is t he viscous damping

coefficient of t he bear ings, is t he r et ur n spr ing const ant , is t he mot or

t or que const ant , is t he angular posit ion of t he head, and is t he input

cur r ent .

Taking t he Laplace t r ansfor m, t he t r ansfer funct ion fr om t o is

Hard Disk Drive

Disk Platen

Disk Drive Motor

Read/Write

Head

Solenoid

Ω

θ

l

J

d

2

θ

d t

2

---------- C

d θ

d t

------- Kθ + + K

i

i =

J C

K K

i

θ i

i θ

H s ( )

K

i

J s

2

Cs K + +

---------------------------------- =

Hard-Disk Read/Write Head Controller

9-21

Using t he values kg , Nm/(r ad/sec), Nm/r ad,

and Nm/r ad, for m t he t r ansfer funct ion descr ipt ion of t his syst em.

At t he MATLAB pr ompt , t ype

J = .01; C = 0.004; K = 10; Ki = .05;

num = Ki;

den = [J C K];

H = tf(num,den)

MATLAB r esponds wit h

Transfer function:

0.05

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

0.01 s^2 + 0.004 s + 10

The t ask her e is t o design a digit al cont r oller t hat pr ovides accur at e posit ioning

of t he r ead/wr it e head. The design is per for med in t he digit al domain. Fir st ,

discr et ize t he cont inuous plant . Because our plant will be equipped wit h a

digit al-t o-analog conver t er (wit h a zer o-or der hold) connect ed t o it s input , use

c2d wit h t he 'zoh' discr et izat ion met hod. Type

Ts = 0.005; % sampling period = 0.005 second

Hd = c2d(H,Ts,'zoh')

Transfer function:

6.233e–05 z + 6.229e–05

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

z^2 – 1.973 z + 0.998

Sampling time: 0.005

J 0.01 = m

2

C 0.004 = K 10 =

K

i

0.05 =

9 Design Case Studies

9-22

You can compar e t he Bode plot s of t he cont inuous and discr et ized models wit h

bode(H,'-',Hd,'--')

Hard-Disk Read/Write Head Controller

9-23

To analyze t he discr et e syst em, plot it s st ep r esponse, t ype

step(Hd)

The syst em oscillat es quit e a bit . This is pr obably due t o ver y light damping.

You can check t his by comput ing t he open-loop poles. Type

% Open–loop poles of discrete model

damp(Hd)

Eigenvalue Magnitude Equiv. Damping Equiv. Freq.

9.87e–01 + 1.57e–01i 9.99e–01 6.32e–03 3.16e+01

9.87e–01 – 1.57e–01i 9.99e–01 6.32e–03 3.16e+01

The poles have ver y light equivalent damping and ar e near t he unit cir cle. You

need t o design a compensat or t hat incr eases t he damping of t hese poles.

9 Design Case Studies

9-24

The simplest compensat or is just a gain, so t r y t he r oot locus t echnique t o select

an appr opr iat e feedback gain.

rlocus(Hd)

As shown in t he r oot locus, t he poles quickly leave t he unit cir cle and go

unst able. You need t o int r oduce some lead or a compensat or wit h some zer os.

Tr y t he compensat or

wit h and .

D z ( )

z a +

z b +

------------ =

a 0.85 – = b 0 =

Hard-Disk Read/Write Head Controller

9-25

The cor r esponding open-loop model

is obt ained by t he ser ies connect ion

D = zpk(0.85,0,1,Ts)

oloop = Hd * D

Now see how t his compensat or modifies t he open-loop fr equency r esponse.

bode(Hd,'--',oloop,'-')

y D z ( )

Plant

u H

d

z ( )

Compensator

9 Design Case Studies

9-26

The plant r esponse is t he dashed line and t he open-loop r esponse wit h t he

compensat or is t he solid line.

The plot above shows t hat t he compensat or has shift ed up t he phase plot

(added lead) in t he fr equency r ange r ad/sec. ω 10 >

Hard-Disk Read/Write Head Controller

9-27

Now t r y t he r oot locus again wit h t he plant and compensat or as open loop.

rlocus(oloop)

zgrid

This t ime, t he poles st ay wit hin t he unit cir cle for some t ime (t he lines dr awn

by zgrid show t he damping r at ios fr om t o 1 in st eps of 0.1). This plot

shows a set of poles '+' select ed using rlocfind. At t he MATLAB pr ompt , t ype

[k,poles] = rlocfind(oloop)

k

k =

4.1179e+03

ζ 0 =

9 Design Case Studies

9-28

Type

ddamp(poles,Ts)

t o see t he equivalent damping and nat ur al fr equency for each of t he

eigenvalues.

To analyze t his design, for m t he closed-loop syst em and plot t he closed-loop

st ep r esponse.

cloop = feedback(oloop,k);

step(cloop)

This r esponse depends on your closed loop set point . The one shown her e is

r elat ively fast and set t les in about 0.07 seconds. Ther efor e, t his closed loop disk

dr ive syst em has a seek t ime of about 0.07 seconds. This is slow by t oday's

st andar ds, but you also st ar t ed wit h a ver y light ly damped syst em.

Hard-Disk Read/Write Head Controller

9-29

Now look at t he r obust ness of your design. The most common classical

r obust ness cr it er ia ar e t he gain and phase mar gins. Use t he funct ion margin t o

det er mine t hese mar gins. Wit h out put ar gument s, margin r et ur ns t he gain and

phase mar gins as well as t he cor r esponding cr ossover fr equencies. Wit hout

out put ar gument , margin plot s t he Bode r esponse and displays t he mar gins

gr aphically.

To comput e t he mar gins, fir st for m t he unit y-feedback open loop by connect ing

t he compensat or , plant model, and feedback gain in ser ies.

olk = k * oloop;

Next apply margin t o t his open-loop model. Type

[Gm,Pm,Wcg,Wcp] = margin(olk);

Margins = [Gm Wcg Pm Wcp]

Margins =

3.7809 295.3172 43.1686 106.4086

To obt ain t he gain mar gin in dB, t ype

20*log10(Gm)

ans =

11.5760

You can also display t he mar gins gr aphically by t yping

margin(olk)

D z ( ) k

u y D z ( )

Plant

k

–

+

oloop

9 Design Case Studies

9-30

The command pr oduces t he plot shown below.

This design is r obust and can t oler at e a 11 dB gain incr ease or a 40 degr ee

phase lag in t he open-loop syst em wit hout going unst able. By cont inuing t his

design pr ocess, you may be able t o find a compensat or t hat st abilizes t he

open-loop syst em and allows you t o r educe t he seek t ime.

Frequency (rad/sec)

P

h

a

s

e

(

d

e

g

)

;

M

a

g

n

i

t

u

d

e

(

d

B

)

Bode Diagrams

−100

−50

0

50

100

Gm=11.6 dB (Wcg=296.1); Pm=43.1 deg. (Wcp=106.5)

10

0

10

1

10

2

10

3

−300

−200

−100

0

100

LQG Regulation

9-31

LQG Regulation

This case st udy demonst r at es t he use of t he LQG design t ools in a pr ocess

cont r ol applicat ion. The goal is t o r egulat e t he hor izont al and ver t ical t hickness

of t he beam pr oduced by a hot st eel r olling mill. This example is adapt ed fr om

[1]. The full plant model is MIMO and t he example shows t he advant age of

dir ect MIMO LQG design over separ at e SISO designs for each axis. Type

milldemo

at t he command line t o r un t his demonst r at ion int er act ively.

Process and Disturbance Models

The r olling mill is used t o shape r ect angular beams of hot met al. The desir ed

out going shape is sket ched below.

r olling cylinder s

shaped beam

x

y

9 Design Case Studies

9-32

This shape is impr essed by t wo pair s of r olling cylinder s (one per axis)

posit ioned by hydr aulic act uat or s. The gap bet ween t he t wo cylinder s is called

t he roll gap.

The object ive is t o maint ain t he beam t hickness along t he x- and y-axes wit hin

t he qualit y assur ance t oler ances. Var iat ions in out put t hickness can ar ise fr om

t he following:

• Var iat ions in t he t hickness/har dness of t he incoming beam

• Eccent r icit y in t he r olling cylinder s

Feedback cont r ol is necessar y t o r educe t he effect of t hese dist ur bances.

Because t he r oll gap cannot be measur ed close t o t he mill st and, t he r olling

for ce is used inst ead for feedback.

The input t hickness dist ur bance is modeled as a low pass filt er dr iven by whit e

noise. The eccent r icit y dist ur bance is appr oximat ely per iodic and it s fr equency

is a funct ion of t he r olling speed. A r easonable model for t his dist ur bance is a

second-or der bandpass filt er dr iven by whit e noise.

-axis

incoming beam shaped beam

r olling cylinder s

r olling mill st and

x

LQG Regulation

9-33

This leads t o t he following gener ic model for each axis of t he r olling pr ocess.

Figure 9-1: Open-loop model for x- or y-axis

The measur ed r olling for ce var iat ion is a combinat ion of t he incr ement al

for ce deliver ed by t he hydr aulic act uat or and of t he dist ur bance for ces due t o

eccent r icit y and input t hickness var iat ion. Not e t hat :

• The out put s of , and ar e t he incr ement al for ces deliver ed

by each component .

• An incr ease in hydr aulic or eccent r icit y for ce reduces t he out put t hickness

gap .

• An incr ease in input t hickness increases t his gap.

hydr aulic act uat or

eccent r icit y model

+

+

–

input dist ur bance model

+

+

+

H s ( )

F

i

s ( )

F

e

s ( )

δ

w

i

w

e

u

g

x

f

u command

δ t hickness gap (in mm)

f incr ement al r olling for ce

w

i

w

e

, dr iving whit e noise for dist ur bance models

f

2

f

1

for ce-t o-gap gain

f

H s ( ) F

e

s ( ) , F

i

s ( )

δ

9 Design Case Studies

9-34

The model dat a for each axis is summar ized below.

Model Data for the x-Axis

Model Data for the y-Axis

LQG Design for the x-Axis

As a fir st appr oximat ion, ignor e t he cr oss-coupling bet ween t he - and -axes

and t r eat each axis independent ly. That is, design one SISO LQG r egulat or for

each axis. The design object ive is t o r educe t he t hickness var iat ions and

due t o eccent r icit y and input t hickness dist ur bances.

H

x

s ( )

2.4 10

8

×

s

2

72s 90

2

+ +

------------------------------------- =

F

i x

s ( )

10

4

s 0.05 +

-------------------- =

F

ex

s ( )

3 10

4

× s

s

2

0.125s 6

2

+ +

------------------------------------------ =

g

x

10

6 –

=

H

y

s ( )

7.8 10

8

×

s

2

71s 88

2

+ +

------------------------------------- =

F

i y

s ( )

2 10

4

×

s 0.05 +

-------------------- =

F

ey

s ( )

10

5

s

s

2

0.19s 9.4

2

+ +

-------------------------------------------- =

g

y

0.5 10

6 –

× =

x y

δ

x

δ

y

LQG Regulation

9-35

St ar t wit h t he -axis. Fir st specify t he model component s as t r ansfer funct ion

object s.

% Hydraulic actuator (with input "u-x")

Hx = tf(2.4e8,[1 72 90^2],'inputname','u-x')

% Input thickness/hardness disturbance model

Fix = tf(1e4,[1 0.05],'inputn','w-ix')

% Rolling eccentricity model

Fex = tf([3e4 0],[1 0.125 6^2],'inputn','w-ex')

% Gain from force to thickness gap

gx = 1e–6;

Next build t he open-loop model shown in Figur e 9-1 above. You could use t he

funct ion connect for t his pur pose, but it is easier t o build t his model by

element ar y append and series connect ions.

% I/O map from inputs to forces f1 and f2

Px = append([ss(Hx) Fex],Fix)

% Add static gain from f1,f2 to outputs ”x-gap” and ”x-force”

Px = [–gx gx;1 1] * Px

% Give names to the outputs:

set(Px,'outputn',{'x-gap' 'x-force'})

Note: To obt ain minimal st at e-space r ealizat ions, always conver t t r ansfer

funct ion models t o st at e space before connect ing t hem. Combining t r ansfer

funct ions and t hen conver t ing t o st at e space may pr oduce nonminimal

st at e-space models.

x

9 Design Case Studies

9-36

The var iable Px now cont ains an open-loop st at e-space model complet e wit h

input and out put names.

Px.inputname

ans =

'u-x'

'w-ex'

'w-ix'

Px.outputname

ans =

'x-gap'

'x-force'

The second out put 'x-force' is t he r olling for ce measur ement . The LQG

r egulat or will use t his measur ement t o dr ive t he hydr aulic act uat or and r educe

dist ur bance-induced t hickness var iat ions .

The LQG design involves t wo st eps:

1 Design a full-st at e-feedback gain t hat minimizes an LQ per for mance

measur e of t he for m

2 Design a Kalman filt er t hat est imat es t he st at e vect or given t he for ce

measur ement s 'x-force'.

The per for mance cr it er ion penalizes low and high fr equencies equally.

Because low-fr equency var iat ions ar e of pr imar y concer n, eliminat e t he

δ

x

J u

x

( ) qδ

x

2

ru

x

2

+

¹ ¹

' ;

¹ ¹

t d

0

∞

∫

=

J u

x

( )

LQG Regulation

9-37

high-fr equency cont ent of wit h t he low-pass filt er and use t he

filt er ed value in t he LQ per for mance cr it er ion.

lpf = tf(30,[1 30])

% Connect low-pass filter to first output of Px

Pxdes = append(lpf,1) * Px

set(Pxdes,'outputn',{'x-gap*' 'x-force'})

% Design the state-feedback gain using LQRY and q=1, r=1e–4

kx = lqry(Pxdes(1,1),1,1e–4)

Note: lqry expect s all input s t o be commands and all out put s t o be

measur ement s. Her e t he command 'u-x' and t he measur ement 'x-gap*'

(filt er ed gap) ar e t he fir st input and fir st out put of Pxdes. Hence, use t he

synt ax Pxdes(1,1) t o specify just t he I/O r elat ion bet ween 'u-x' and

'x-gap*'.

Next , design t he Kalman est imat or wit h t he funct ion kalman. The pr ocess noise

has unit covar iance by const r uct ion. Set t he measur ement noise covar iance t o

1000 t o limit t he high fr equency gain, and keep only t he measur ed out put

'x-force' for est imat or design.

estx = kalman(Pxdes(2,:),eye(2),1000)

Finally, connect t he st at e-feedback gain kx and st at e est imat or estx t o for m

t he LQG r egulat or .

Regx = lqgreg(estx,kx)

This complet es t he LQG design for t he -axis.

δ

x

30 s 30 + ( ) ⁄

w

x

w

ex

w

i x

=

x

9 Design Case Studies

9-38

Let ’s look at t he r egulat or Bode r esponse bet ween 0.1 and 1000 r ad/sec.

bode(Regx,{0.1 1000})

The phase r esponse has an int er est ing physical int er pr et at ion. Fir st , consider

an incr ease in input t hickness. This low-fr equency dist ur bance boost s bot h

out put t hickness and r olling for ce. Because t he r egulat or phase is

appr oximat ely 0

o

at low fr equencies, t he feedback loop t hen adequat ely r eact s

by incr easing t he hydr aulic for ce t o offset t he t hickness incr ease. Now consider

t he effect of eccent r icit y. Eccent r icit y causes fluct uat ions in t he r oll gap (gap

bet ween t he r olling cylinder s). When t he r oll gap is minimal, t he r olling for ce

incr eases and t he beam t hickness diminishes. The hydr aulic for ce must t hen

be r educed (negat ive for ce feedback) t o r est or e t he desir ed t hickness. This is

exact ly what t he LQG r egulat or does as it s phase dr ops t o –180

o

near t he

nat ur al fr equency of t he eccent r icit y dist ur bance (6 r ad/sec).

LQG Regulation

9-39

Next , compar e t he open- and closed-loop r esponses fr om dist ur bance t o

t hickness gap. Use feedback t o close t he loop. To help specify t he feedback

connect ion, look at t he I/O names of t he plant Px and r egulat or Regx.

Px.inputname

ans =

'u-x'

'w-ex'

'w-ix'

Regx.outputname

ans =

'u-x'

Px.outputname

ans =

'x-gap'

'x-force'

Regx.inputname

ans =

'x-force'

This indicat es t hat you must connect t he fir st input and second out put of Px t o

t he r egulat or .

clx = feedback(Px,Regx,1,2,+1) % Note: +1 for positive feedback

9 Design Case Studies

9-40

You ar e now r eady t o compar e t he open- and closed-loop Bode r esponses fr om

dist ur bance t o t hickness gap.

bode(Px(1,2:3),'--',clx(1,2:3),'-',{0.1 100})

The dashed lines show t he open-loop r esponse. Not e t hat t he peak gain of t he

eccent r icit y-t o-gap r esponse and t he low-fr equency gain of t he

input -t hickness-t o-gap r esponse have been r educed by about 20 dB.

Finally, use lsim t o simulat e t he open- and closed-loop t ime r esponses t o t he

whit e noise input s and . Choose dt=0.01 as sampling per iod for t he

Frequency (rad/sec)

P

h

a

s

e

(

d

e

g

)

;

M

a

g

n

i

t

u

d

e

(

d

B

)

Bode Diagrams

−100

−80

−60

−40

−20

0

From: w−ex From: w−ix

10

−1

10

0

10

1

10

2

−300

−250

−200

−150

−100

−50

0

T

o

:

x

−

g

a

p

10

−1

10

0

10

1

10

2

w

ex

w

i x

LQG Regulation

9-41

simulat ion, and der ive equivalent discr et e whit e noise input s for t his sampling

r at e.

dt = 0.01

t = 0:dt:50 % time samples

% Generate unit-covariance driving noise wx = [w-ex;w-ix].

% Equivalent discrete covariance is 1/dt

wx = sqrt(1/dt) * randn(2,length(t))

lsim(Px(1,2:3),':',clx(1,2:3),'-',wx,t)

The dot t ed lines cor r espond t o t he open-loop r esponse. In t his simulat ion, t he

LQG r egulat ion r educes t he peak t hickness var iat ion by a fact or 4.

9 Design Case Studies

9-42

LQG Design for the y-Axis

The LQG design for t he -axis (r egulat ion of t he t hickness) follows t he exact

same st eps as for t he -axis.

% Specify model components

Hy = tf(7.8e8,[1 71 88^2],'inputn','u-y')

Fiy = tf(2e4,[1 0.05],'inputn','w-iy')

Fey = tf([1e5 0],[1 0.19 9.4^2],'inputn','w-ey')

gy = 0.5e–6 % force-to-gap gain

% Build open-loop model

Py = append([ss(Hy) Fey],Fiy)

Py = [–gy gy;1 1] * Py

set(Py,'outputn',{'y-gap' 'y-force'})

% State-feedback gain design

Pydes = append(lpf,1) * Py % Add low-freq. weigthing

set(Pydes,'outputn',{'y-gap*' 'y-force'})

ky = lqry(Pydes(1,1),1,1e–4)

% Kalman estimator design

esty = kalman(Pydes(2,:),eye(2),1e3)

% Form SISO LQG regulator for y-axis and close the loop

Regy = lqgreg(esty,ky)

cly = feedback(Py,Regy,1,2,+1)

y y

x

LQG Regulation

9-43

Compar e t he open- and closed-loop r esponse t o t he whit e noise input

dist ur bances.

dt = 0.01

t = 0:dt:50

wy = sqrt(1/dt) * randn(2,length(t))

lsim(Py(1,2:3),':',cly(1,2:3),'-',wy,t)

The dot t ed lines cor r espond t o t he open-loop r esponse. The simulat ion r esult s

ar e compar able t o t hose for t he -axis.

Cross-Coupling Between Axes

The / t hickness r egulat ion, is a MIMO pr oblem. So far you have t r eat ed

each axis separ at ely and closed one SISO loop at a t ime. This design is valid as

long as t he t wo axes ar e fair ly decoupled. Unfor t unat ely, t his r olling mill

x

x y

9 Design Case Studies

9-44

pr ocess exhibit s some degr ee of cr oss-coupling bet ween axes. Physically, an

incr ease in hydr aulic for ce along t he -axis compr esses t he mat er ial, which in

t ur n boost s t he r epelling for ce on t he -axis cylinder s. The r esult is an incr ease

in -t hickness and an equivalent (r elat ive) decr ease in hydr aulic for ce along

t he -axis.

The coupling bet ween axes is as follows.

Figure 9-2: Coupling between the x- and y-axes

x

y

y

y

w

ex

w

i x

u

y

w

ey

w

i y

δ

x

g

xy

g

y

u

x

+

+

+

+

+

–

f

x

f

y

δ

y

+

g

yx

g

x

–

x-axis

model

y-axis

model

g

xy

0.1 =

g

yx

0.4 =

LQG Regulation

9-45

Accor dingly, t he t hickness gaps and r olling for ces ar e r elat ed t o t he out put s

of t he - and -axis models by

Let ’s see how t he pr evious “decoupled” LQG design far es when cr oss-coupling

is t aken int o account . To build t he t wo-axes model shown in Figur e 9-2, append

t he models Px and Py for t he - and -axes.

P = append(Px,Py)

For convenience, r eor der t he input s and out put s so t hat t he commands and

t hickness gaps appear fir st .

P = P([1 3 2 4],[1 4 2 3 5 6])

P.outputname

ans =

'x-gap'

'y-gap'

'x-force'

'y-force'

Finally, place t he cr oss-coupling mat r ix in ser ies wit h t he out put s.

gxy = 0.1; gyx = 0.4;

CCmat = [eye(2) [0 gyx*gx;gxy*gy 0] ; zeros(2) [1 –gyx;–gxy 1]]

Pc = CCmat * P

Pc.outputname = P.outputname

To simulat e t he closed-loop r esponse, also for m t he closed-loop model by

feedin = 1:2 % first two inputs of Pc are the commands

feedout = 3:4 % last two outputs of Pc are the measurements

cl = feedback(Pc,append(Regx,Regy),feedin,feedout,+1)

δ

x

f

x

... , , x y

δ

x

δ

y

f

x

f

y

1 0 0 g

y x

g

x

0 1 g

x y

g

y

0

0 0 1 g

yx

–

0 0 g

xy

– 1

δ

x

δ

y

f

x

f

y

=

cross-coupling matrix

¹ ¹ ¹ ¹ ¹ ¹ ' ¹ ¹ ¹ ¹ ¹ ¹

x y

9 Design Case Studies

9-46

You ar e now r eady t o simulat e t he open- and closed-loop r esponses t o t he

dr iving whit e noises wx (for t he -axis) and wy (for t he -axis).

wxy = [wx ; wy]

lsim(Pc(1:2,3:6),':',cl(1:2,3:6),'-',wxy,t)

The r esponse r eveals a sever e det er ior at ion in r egulat ion per for mance along

t he -axis (t he peak t hickness var iat ion is about four t imes lar ger t han in t he

simulat ion wit hout cr oss-coupling). Hence, designing for one loop at a t ime is

inadequat e for t his level of cr oss-coupling, and you must per for m a joint -axis

MIMO design t o cor r ect ly handle coupling effect s.

x y

x

LQG Regulation

9-47

MIMO LQG Design

St ar t wit h t he complet e t wo-axis st at e-space model Pc der ived above. The

model input s and out put s ar e

Pc.inputname

ans =

'u-x'

'u-y'

'w-ex'

'w-ix'

'w_ey'

'w_iy'

P.outputname

ans =

'x-gap'

'y-gap'

'x-force'

'y-force'

As ear lier , add low-pass filt er s in ser ies wit h t he 'x-gap' and 'y-gap' out put s

t o penalize only low-fr equency t hickness var iat ions.

Pdes = append(lpf,lpf,eye(2)) * Pc

Pdes.outputn = Pc.outputn

Next , design t he LQ gain and st at e est imat or as befor e (t her e ar e now t wo

commands and t wo measur ement s).

k = lqry(Pdes(1:2,1:2),eye(2),1e–4*eye(2)) % LQ gain

est = kalman(Pdes(3:4,:),eye(4),1e3*eye(2)) % Kalman estimator

RegMIMO = lqgreg(est,k) % form MIMO LQG regulator

9 Design Case Studies

9-48

The r esult ing LQG r egulat or RegMIMO has t wo input s and t wo out put s.

RegMIMO.inputname

ans =

'x-force'

'y-force'

RegMIMO.outputname

ans =

'u-x'

'u-y'

Plot it s singular value r esponse (pr incipal gains).

sigma(RegMIMO)

LQG Regulation

9-49

Next , plot t he open- and closed-loop t ime r esponses t o t he whit e noise input s

(using t he MIMO LQG r egulat or for feedback).

% Form the closed-loop model

cl = feedback(Pc,RegMIMO,1:2,3:4,+1);

% Simulate with LSIM using same noise inputs

lsim(Pc(1:2,3:6),':',cl(1:2,3:6),'-',wxy,t)

The MIMO design is a clear impr ovement over t he separ at e SISO designs for

each axis. In par t icular , t he level of / t hickness var iat ion is now compar able

t o t hat obt ained in t he decoupled case. This example illust r at es t he benefit s of

dir ect MIMO design for mult ivar iable syst ems.

x y

9 Design Case Studies

9-50

Kalman Filtering

This final case st udy illust r at es t he use of t he Cont r ol Syst em Toolbox for

Kalman filt er design and simulat ion. Bot h st eady-st at e and t ime-var ying

Kalman filt er s ar e consider ed.

Consider t he discr et e plant

wit h addit ive Gaussian noise on t he input and dat a

A = [1.1269 –0.4940 0.1129

1.0000 0 0

0 1.0000 0];

B = [–0.3832

0.5919

0.5191];

C = [1 0 0];

Our goal is t o design a Kalman filt er t hat est imat es t he out put given t he

input s and t he noisy out put measur ement s

wher e is some Gaussian whit e noise.

Discrete Kalman Filter

The equat ions of t he st eady-st at e Kalman filt er for t his pr oblem ar e given as

follows.

Measureme nt update

Ti me update

x n 1 + [ ] Ax n [ ] B u n [ ] w n [ ] + ( ) + =

y n [ ] Cx n [ ] =

w n [ ] u n [ ]

y n [ ]

u n [ ]

y

v

n [ ] Cx n [ ] v n [ ] + =

v n [ ]

xˆ n n [ ] xˆ n n 1 – [ ] M y

v

n [ ] Cxˆ n n 1 – [ ] – ( ) + =

xˆ n 1 n + [ ] Axˆ n n [ ] Bu n [ ] + =

Kalman Filtering

9-51

In t hese equat ions:

• is t he est imat e of given past measur ement s up t o

• is t he updat ed est imat e based on t he last measur ement

Given t he cur r ent est imat e , t he t ime updat e pr edict s t he st at e value at

t he next sample (one-st ep-ahead pr edict or ). The measur ement updat e

t hen adjust s t his pr edict ion based on t he new measur ement . The

cor r ect ion t er m is a funct ion of t he innovation, t hat is, t he discr epancy.

bet ween t he measur ed and pr edict ed values of . The innovat ion gain

is chosen t o minimize t he st eady-st at e covar iance of t he est imat ion er r or

given t he noise covar iances

You can combine t he t ime and measur ement updat e equat ions int o one

st at e-space model (t he Kalman filt er ).

This filt er gener at es an opt imal est imat e of . Not e t hat t he filt er

st at e is .

Steady-State Design

You can design t he st eady-st at e Kalman filt er descr ibed above wit h t he

funct ion kalman. Fir st specify t he plant model wit h t he pr ocess noise.

xˆ n n 1 – [ ] x n [ ] y

v

n 1 – [ ]

xˆ n n [ ] y

v

n [ ]

xˆ n n [ ]

n 1 +

y

v

n 1 + [ ]

y

v

n 1 + [ ] Cxˆ n 1 + n [ ] – C x n 1 + [ ] xˆ n 1 + n [ ] – ( ) =

y n 1 + [ ]

M

E w n [ ]w n [ ]

T

( ) Q , = E v n [ ]v n [ ]

T

( ) R =

xˆ n 1 n + [ ] A I MC – ( ) xˆ n n 1 – [ ] B AM

u n [ ]

y

v

n [ ]

+ =

yˆ n n [ ] C I MC – ( ) xˆ n n 1 – [ ] CM y

v

n [ ] + =

yˆ n n [ ] y n [ ]

xˆ n n 1 – [ ]

x n 1 + [ ] Ax n [ ] Bu n [ ] Bw n [ ] + + = (st at e equat ion)

y n [ ] Cx n [ ] = (measur ement equat ion)

9 Design Case Studies

9-52

This is done by

% Note: set sample time to –1 to mark model as discrete

Plant = ss(A,[B B],C,0,–1,'inputname',{'u' 'w'},...

'outputname','y');

Assuming t hat , you can now design t he discr et e Kalman filt er by

Q = 1; R = 1;

[kalmf,L,P,M] = kalman(Plant,Q,R);

This r et ur ns a st at e-space model kalmf of t he filt er as well as t he innovat ion

gain

M

M =

3.7980e–01

8.1732e–02

–2.5704e–01

The input s of kalmf ar e and , and it s out put s ar e t he plant out put and

st at e est imat es and .

Q R 1 = =

u y

v

y

e

yˆ n n [ ] = xˆ n n [ ]

kalmf

Kalman filter

u

xˆ n n [ ] y

v

y

e

Kalman Filtering

9-53

Because you ar e int er est ed in t he out put est imat e , keep only t he fir st out put

of kalmf. Type

kalmf = kalmf(1,:);

kalmf

a =

x1_e x2_e x3_e

x1_e 0.76830 –0.49400 0.11290

x2_e 0.62020 0 0

x3_e –0.08173 1.00000 0

b =

u y

x1_e –0.38320 0.35860

x2_e 0.59190 0.37980

x3_e 0.51910 0.08173

c =

x1_e x2_e x3_e

y_e 0.62020 0 0

d =

u y

y_e 0 0.37980

Sampling time: unspecified

Discrete-time system.

To see how t he filt er wor ks, gener at e some input dat a and r andom noise and

compar e t he filt er ed r esponse wit h t he t r ue r esponse . You can eit her

gener at e each r esponse separ at ely, or gener at e bot h t oget her . To simulat e each

r esponse separ at ely, use lsim wit h t he plant alone fir st , and t hen wit h t he

plant and filt er hooked up t oget her . The joint simulat ion alt er nat ive is det ailed

next .

y

e

y

e

y

9 Design Case Studies

9-54

The block diagr am below shows how t o gener at e bot h t r ue and filt er ed out put s.

You can const r uct a st at e-space model of t his block diagr am wit h t he funct ions

parallel and feedback. Fir st build a complet e plant model wit h as

input s and and (measur ement s) as out put s.

a = A;

b = [B B 0*B];

c = [C;C];

d = [0 0 0;0 0 1];

P = ss(a,b,c,d,–1,'inputname',{'u' 'w' 'v'},...

'outputname',{'y' 'yv'});

Then use parallel t o for m t he following par allel connect ion.

sys = parallel(P,kalmf,1,1,[],[])

Plant

Kalman

filt er

y

u

Pr ocess noise Sensor noise

y

y

v

y

e

u w v , ,

y y

v

P

Kalman

filt er

u

y

v

w

y

v

y

v

y

e

Kalman Filtering

9-55

Finally, close t he sensor loop by connect ing t he plant out put t o t he filt er

input wit h posit ive feedback.

% Close loop around input #4 and output #2

SimModel = feedback(sys,1,4,2,1)

% Delete yv from I/O list

SimModel = SimModel([1 3],[1 2 3])

The r esult ing simulat ion model has as input s and as out put s.

SimModel.input

ans =

'w'

'v'

'u'

SimModel.output

ans =

'y'

'y_e'

You ar e now r eady t o simulat e t he filt er behavior . Gener at e a sinusoidal input

and pr ocess and measur ement noise vect or s and .

t = [0:100]';

u = sin(t/5);

n = length(t)

randn('seed',0)

w = sqrt(Q)*randn(n,1);

v = sqrt(R)*randn(n,1);

Now simulat e wit h lsim.

[out,x] = lsim(SimModel,[w,v,u]);

y = out(:,1); % true response

ye = out(:,2); % filtered response

yv = y + v; % measured response

y

v

y

v

w v u , , y y

e

,

u w v

9 Design Case Studies

9-56

and compar e t he t r ue and filt er ed r esponses gr aphically.

subplot(211), plot(t,y,'--',t,ye,'-'),

xlabel('No. of samples'), ylabel('Output')

subplot(212), plot(t,y–yv,'-.',t,y–ye,'-'),

xlabel('No. of samples'), ylabel('Error')

The fir st plot shows t he t r ue r esponse (dashed line) and t he filt er ed out put

(solid line). The second plot compar es t he measur ement er r or (dash-dot )

wit h t he est imat ion er r or (solid). This plot shows t hat t he noise level has been

significant ly r educed. This is confir med by t he following er r or covar iance

comput at ions.

MeasErr = y–yv;

MeasErrCov = sum(MeasErr.*MeasErr)/length(MeasErr);

EstErr = y–ye;

EstErrCov = sum(EstErr.*EstErr)/length(EstErr);

y

y

e

Kalman Filtering

9-57

The er r or covar iance befor e filt er ing (measur ement er r or ) is

MeasErrCov

MeasErrCov =

1.1138

while t he er r or covar iance aft er filt er ing (est imat ion er r or ) is only

EstErrCov

EstErrCov =

0.2722

Time-Varying Kalman Filter

The t ime-var ying Kalman filt er is a gener alizat ion of t he st eady-st at e filt er for

t ime-var ying syst ems or LTI syst ems wit h nonst at ionar y noise covar iance.

Given t he plant st at e and measur ement equat ions

t he t ime-var ying Kalman filt er is given by t he r ecur sions

Meas ure ment update

Ti me update

x n 1 + [ ] Ax n [ ] Bu n [ ] Gw n [ ] + + =

y

v

n [ ] Cx n [ ] v n [ ] + =

xˆ n n [ ] xˆ n n 1 – [ ] M n [ ] y

v

n [ ] Cxˆ n n 1 – [ ] – ( ) + =

M n [ ] P n n 1 – [ ]C

T

R n [ ] CP n n 1 – [ ]C

T

+ ( )

1 –

=

P n n [ ] I M n [ ]C – ( ) P n n 1 – [ ] =

xˆ n 1 n + [ ] Axˆ n n [ ] Bu n [ ] + =

P n 1 n + [ ] AP n n [ ]A

T

GQ n [ ]G

T

+ =

9 Design Case Studies

9-58

wit h and as defined on page 9-50, and in t he following.

For simplicit y, we have dr opped t he subscr ipt s indicat ing t he t ime dependence

of t he st at e-space mat r ices.

Given init ial condit ions and , you can it er at e t hese equat ions t o

per for m t he filt er ing. Not e t hat you must updat e bot h t he st at e est imat es

and er r or covar iance mat r ices at each t ime sample.

Time-Varying Design

Alt hough t he Cont r ol Syst em Toolbox does not offer specific commands t o

per for m t ime-var ying Kalman filt er ing, it is easy t o implement t he filt er

r ecur sions in MATLAB. This sect ion shows how t o do t his for t he st at ionar y

plant consider ed above.

Fir st gener at e noisy out put measur ement s

% Use process noise w and measurement noise v generated above

sys = ss(A,B,C,0,–1);

y = lsim(sys,u+w); % w = process noise

yv = + v; % v = measurement noise

Given t he init ial condit ions

xˆ n n 1 – [ ] xˆ n n [ ]

Q n [ ] E w n [ ]w n [ ]

T

( ) =

R n [ ] E v n [ ]v n [ ]

T

( ) =

P n n [ ] E x n [ ] x n n [ ] – { } x n [ ] x n n [ ] – { }

T

( ) =

P n n 1 – [ ] E x n [ ] x n n 1 – [ ] – { } x n [ ] x n n 1 – [ ] – { }

T

( ) =

x 1 0 [ ] P 1 0 [ ]

x n . [ ] P n . [ ]

x 1 0 [ ] 0 , = P 1 0 [ ] BQB

T

=

Kalman Filtering

9-59

you can implement t he t ime-var ying filt er wit h t he following for loop.

P = B*Q*B'; % Initial error covariance

x = zeros(3,1); % Initial condition on the state

ye = zeros(length(t),1);

ycov = zeros(length(t),1);

for i=1:length(t)

% Measurement update

Mn = P*C'/(C*P*C'+R);

x = x + Mn*(yv(i)–C*x); % x[n|n]

P = (eye(3)–Mn*C)*P; % P[n|n]

ye(i) = C*x;

errcov(i) = C*P*C';

% Time update

x = A*x + B*u(i); % x[n+1|n]

P = A*P*A' + B*Q*B'; % P[n+1|n]

end

9 Design Case Studies

9-60

You can now compar e t he t r ue and est imat ed out put gr aphically.

subplot(211), plot(t,y,'--',t,ye,'-')

subplot(212), plot(t,y-yv,'-.',t,y-ye,'-')

The fir st plot shows t he t r ue r esponse (dashed line) and t he filt er ed r esponse

(solid line). The second plot compar es t he measur ement er r or (dash-dot )

wit h t he est imat ion er r or (solid).

y

y

e

Kalman Filtering

9-61

The t ime-var ying filt er also est imat es t he covar iance errcov of t he est imat ion

er r or at each sample. Plot it t o see if your filt er r eached st eady st at e (as

you expect wit h st at ionar y input noise).

subplot(211)

plot(t,errcov), ylabel('Error covar')

Fr om t his covar iance plot , you can see t hat t he out put covar iance did indeed

r each a st eady st at e in about five samples. Fr om t hen on, your t ime-var ying

filt er has t he same per for mance as t he st eady-st at e ver sion.

y y

e

–

9 Design Case Studies

9-62

Compar e wit h t he est imat ion er r or covar iance der ived fr om t he exper iment al

dat a. Type

EstErr = y–ye;

EstErrCov = sum(EstErr.*EstErr)/length(EstErr)

EstErrCov =

0.2718

This value is smaller t han t he t heor et ical value errcov and close t o t he value

obt ained for t he st eady-st at e design.

Finally, not e t hat t he final value and t he st eady-st at e value of t he

innovat ion gain mat r ix coincide.

Mn, M

Mn =

0.3798

0.0817

–0.2570

M =

0.3798

0.0817

–0.2570

M n [ ] M

Kalman Filtering

9-63

References

[1] Gr imble, M.J ., Robust Industrial Control: Optimal Design Approach for

Polynomial S ystems, Pr ent ice Hall, 1994, p. 261 and pp. 443–456.

9 Design Case Studies

9-64

10

Reliable Comput at ions

Condi ti oni ng and Nume ri cal Stabi li ty . . . . . . . . 10-4

Condit ioning . . . . . . . . . . . . . . . . . . . . 10-4

Numer ical St abilit y . . . . . . . . . . . . . . . . . . 10-6

Choi ce of LTI Mode l . . . . . . . . . . . . . . . . 10-8

St at e Space . . . . . . . . . . . . . . . . . . . . . 10-8

Tr ansfer Funct ion . . . . . . . . . . . . . . . . . . 10-8

Zer o-Pole-Gain Models . . . . . . . . . . . . . . . 10-14

Scali ng . . . . . . . . . . . . . . . . . . . . . 10-15

Summary . . . . . . . . . . . . . . . . . . . . 10-17

Refe re nce s . . . . . . . . . . . . . . . . . . . . 10-18

10 Reliable Computations

10-2

When wor king wit h low-or der SISO models (less t han five st at es), comput er s

ar e usually quit e for giving and insensit ive t o numer ical pr oblems. You

gener ally won't encount er any numer ical difficult ies and MATLAB will give

you accur at e answer s r egar dless of t he model or conver sion met hod you choose.

For high or der SISO models and MIMO models, however , t he finit e-pr ecision

ar it hmet ic of a comput er is not so for giving and you must exer cise caut ion.

In gener al, t o get a numer ically accur at e answer fr om a comput er , you need:

• A well-condit ioned pr oblem

• An algor it hm t hat is numer ically st able in finit e-pr ecision ar it hmet ic

• A good soft war e implement at ion of t he algor it hm

A pr oblem is said t o be well-condit ioned if small changes in t he dat a cause only

small cor r esponding changes in t he solut ion. If small changes in t he dat a have

t he pot ent ial t o induce lar ge changes in t he solut ion, t he pr oblem is said t o be

ill-condit ioned. An algor it hm is numer ically st able if it does not int r oduce any

mor e sensit ivit y t o per t ur bat ion t han is alr eady inher ent in t he pr oblem. Many

numer ical linear algebr a algor it hms can be shown t o be backwar d st able; i.e.,

t he comput ed solut ion can be shown t o be (near ) t he exact solut ion of a slight ly

per t ur bed or iginal pr oblem. The solut ion of a slight ly per t ur bed or iginal

pr oblem will be close t o t he t r ue solut ion if t he pr oblem is well-condit ioned.

Thus, a st able algor it hm cannot be expect ed t o solve an ill-condit ioned pr oblem

any mor e accur at ely t han t he dat a war r ant , but an unst able algor it hm can

pr oduce poor solut ions even t o well-condit ioned pr oblems. For fur t her det ails

and r efer ences t o t he lit er at ur e see [5].

While most of t he t ools in t he Cont r ol Syst em Toolbox use r eliable algor it hms,

some of t he t ools do not use st able algor it hms and some solve ill-condit ioned

pr oblems. These unr eliable t ools wor k quit e well on some pr oblems (low-or der

syst ems) but can encount er numer ical difficult ies, oft en sever e, when pushed

on higher -or der pr oblems. These t ools ar e pr ovided because:

• They ar e quit e useful for low-or der syst ems, which for m t he bulk of

r eal-wor ld engineer ing pr oblems.

• Many cont r ol engineer s t hink in t er ms of t hese t ools.

• A mor e r eliable alt er nat ive t ool is usually available in t his t oolbox.

• They ar e convenient for pedagogical pur poses.

10-3

At t he same t ime, it is impor t ant t o appr eciat e t he limit at ions of comput er

analyses. By following a few guidelines, you can avoid cer t ain t ools and models

when t hey ar e likely t o get you int o t r ouble. The following sect ions t r y t o

illust r at e, t hr ough examples, some of t he numer ical pit falls t o be avoided. We

also encour age you t o get t he most out of t he good algor it hms by ensur ing, if

possible, t hat your models give r ise t o pr oblems t hat ar e well-condit ioned.

10 Reliable Computations

10-4

Conditioning and Numerical Stability

Two of t he key concept s in numer ical analysis ar e t he condit ioning of pr oblems

and t he st abilit y of algor it hms.

Conditioning

Consider t he linear syst em given by

A =

0.7800 0.5630

0.9130 0.6590

b =

0.2170

0.2540

The t r ue solut ion is x = [1, –1]' and you can calculat e it appr oximat ely using

MATLAB.

x = A\b

x =

1.0000

–1.0000

format long, x

x =

0.99999999991008

–0.99999999987542

Of cour se, in r eal pr oblems you almost never have t he luxur y of knowing t he

t r ue solut ion. This pr oblem is ver y ill-condit ioned. To see t his, add a small

per t ur bat ion t o A

E =

0.0010 0.0010

–0.0020 –0.0010

and solve t he per t ur bed syst em

xe = (A+E)\b

xe =

–5.0000

7.3085

Ax b =

A E + ( )x b =

Conditioning and Numerical Stability

10-5

Not ice how much t he small change in t he dat a is magnified in t he solut ion.

One way t o measur e t he magnificat ion fact or is by means of t he quant it y

called t he condit ion number of wit h r espect t o inver sion. The condit ion

number det er mines t he loss in pr ecision due t o r oundoff er r or s in Gaussian

eliminat ion and can be used t o est imat e t he accur acy of r esult s obt ained fr om

mat r ix inver sion and linear equat ion solut ion. It ar ises nat ur ally in

per t ur bat ion t heor ies t hat compar e t he per t ur bed solut ion wit h t he

t r ue solut ion .

In MATLAB, t he funct ion cond calculat es t he condit ion number in 2-nor m.

cond(A) is t he r at io of t he lar gest singular value of A t o t he smallest . Tr y it for

t he example above. The usual r ule is t hat t he exponent log10(cond(A)) on t he

condit ion number indicat es t he number of decimal places t hat t he comput er

can lose t o r oundoff er r or s.

IEEE st andar d double pr ecision number s have about 16 decimal digit s of

accur acy, so if a mat r ix has a condit ion number of 10

10

, you can expect only six

digit s t o be accur at e in t he answer . If t he condit ion number is much gr eat er

t han 1/sqrt(eps), caut ion is advised for subsequent comput at ions. For IEEE

ar it hmet ic, t he machine pr ecision, eps, is about

-16

, and 1/sqrt(eps)

=

8

.

Anot her impor t ant aspect of condit ioning is t hat , in gener al, r esiduals ar e

r eliable indicat or s of accur acy only if t he pr oblem is well-condit ioned. To

illust r at e, t r y comput ing t he r esidual vect or for t he t wo candidat e

solut ions x = [0.999 –1.001]' and x = [0.341 –0.087]'. Not ice t hat t he

second, while clear ly a much less accur at e solut ion, gives a far smaller

r esidual. The conclusion is t hat r esiduals ar e unr eliable indicat or s of r elat ive

solut ion accur acy for ill-condit ioned pr oblems. This is a good r eason t o be

concer ned wit h comput ing or est imat ing accur at ely t he condit ion of your

pr oblem.

Anot her simple example of an ill-condit ioned pr oblem is t he -by- mat r ix

wit h ones on t he fir st upper -diagonal.

A = diag(ones(1,n–1),1);

This mat r ix has eigenvalues at 0. Now consider a small per t ur bat ion of t he

dat a consist ing of adding t he number t o t he fir st element in t he last ( t h)

A A

1 –

A

A E + ( )

1 –

b

A

1 –

b

2.2 10 ×

6.7 10 ×

r Ax b – =

n n

n

2

n –

n

10 Reliable Computations

10-6

r ow of A. This per t ur bed mat r ix has n dist inct eigenvalues wit h

. Thus, you can see t hat t his small per t ur bat ion in t he

dat a has been magnified by a fact or on t he or der of t o r esult in a r at her

lar ge per t ur bat ion in t he solut ion (t he eigenvalues of A). Fur t her det ails and

r elat ed examples ar e t o be found in [7].

It is impor t ant t o r ealize t hat a mat r ix can be ill-condit ioned wit h r espect t o

inver sion but have a well-condit ioned eigenpr oblem, and vice ver sa. For

example, consider an upper t r iangular mat r ix of ones (zer os below t he

diagonal) given by

A = triu(ones(n));

This mat r ix is ill-condit ioned wit h r espect t o it s eigenpr oblem (t r y small

per t ur bat ions in A(n,1) for , say, n=20), but is well-condit ioned wit h r espect t o

inver sion (check it s condit ion number ). On t he ot her hand, t he mat r ix

has a well-condit ioned eigenpr oblem, but is ill-condit ioned wit h r espect t o

inver sion for small .

Numerical Stability

Numer ical st abilit y is somewhat mor e difficult t o illust r at e meaningfully.

Consult t he r efer ences in [5], [6], and [7] for fur t her det ails. Her e is one small

example t o illust r at e t he differ ence bet ween st abilit y and condit ioning.

Gaussian eliminat ion wit h no pivot ing for solving t he linear syst em is

known t o be numer ically unst able. Consider

All comput at ions ar e car r ied out in t hr ee-significant -figur e decimal ar it hmet ic.

The t r ue answer is appr oximat ely

λ

1

... λ

n

, ,

λ

k

1 2 ⁄ j 2πk n ⁄ ( ) exp =

2

n

A

1 1

1 1 δ +

=

δ

Ax b =

A

0.001 1.000

1.000 1.000 –

= b

1.000

0.000

=

x A

1 –

b =

x

0.999

0.999

=

Conditioning and Numerical Stability

10-7

Using r ow 1 as t he pivot r ow (i.e., subt r act ing 1000 t imes r ow 1 fr om r ow 2) you

ar r ive at t he equivalent t r iangular syst em.

Not e t hat t he coefficient mult iplying in t he second equat ion should be

, but because of r oundoff, becomes . As a r esult , t he second

equat ion yields , a good appr oximat ion, but now back-subst it ut ion

in t he fir st equat ion

yields . This ext r emely bad appr oximat ion of is t he r esult of

numer ical inst abilit y. The pr oblem it self can be shown t o be quit e

well-condit ioned. Of cour se, MATLAB implement s Gaussian eliminat ion wit h

pivot ing.

0.001 1.000

0 1000 –

x

1

x

2

1.000

1000 –

=

x

2

1001 – 1000 –

x

2

1.000 =

0.001x

1

1.000 1.000 ( ) 1.000 ( ) – =

x

1

0.000 = x

1

10 Reliable Computations

10-8

Choice of LTI Model

Now t ur n t o t he implicat ions of t he r esult s in t he last sect ion on t he linear

modeling t echniques used for cont r ol engineer ing. The Cont r ol Syst em Toolbox

includes t he following t ypes of LTI models t hat ar e applicable t o discussions of

comput at ional r eliabilit y:

• St at e space

• Tr ansfer funct ion, polynomial for m

• Tr ansfer funct ion, fact or ed zer o-pole-gain for m

The following subsect ions show t hat st at e space is most pr efer able for

numer ical comput at ions.

State Space

The st at e-space r epr esent at ion is t he most r eliable LTI model t o use for

comput er analysis. This is one of t he r easons for t he popular it y of “moder n”

st at e-space cont r ol t heor y. St able comput er algor it hms for eigenvalues,

fr equency r esponse, t ime r esponse, and ot her pr oper t ies of t he

quadr uple ar e known [5] and implement ed in t his t oolbox. The st at e-space

model is also t he most nat ur al model in MATLAB's mat r ix envir onment .

Even wit h st at e-space models, however , accur at e r esult s ar e not guar ant eed,

because of t he pr oblems of finit e-wor d-lengt h comput er ar it hmet ic discussed in

t he last sect ion. A well-condit ioned pr oblem is usually a pr er equisit e for

obt aining accur at e r esult s and makes it impor t ant t o have r easonable scaling

of t he dat a. Scaling is discussed fur t her in t he “Scaling” sect ion lat er in t his

chapt er .

Transfer Function

Tr ansfer funct ion models, when expr essed in t er ms of expanded polynomials,

t end t o be inher ent ly ill-condit ioned r epr esent at ions of LTI syst ems. For

syst ems of or der gr eat er t han 10, or wit h ver y lar ge/small polynomial

coefficient s, difficult ies can be encount er ed wit h funct ions like roots, conv,

bode, step, or conver sion funct ions like ss or zpk.

A B C D , , , ( )

Choice of LTI Model

10-9

A major difficult y is t he ext r eme sensit ivit y of t he r oot s of a polynomial t o it s

coefficient s. This example is adapt ed fr om Wilkinson, [6] as an illust r at ion.

Consider t he t r ansfer funct ion

The mat r ix of t he companion r ealizat ion of is

Despit e t he benign looking poles of t he syst em (at –1,–2,..., –20) you ar e faced

wit h a r at her lar ge r ange in t he element s of , fr om 1 t o . But

t he difficult ies don’t st op her e. Suppose t he coefficient of in t he t r ansfer

funct ion (or ) is per t ur bed fr om 210 t o ( ).

Then, comput ed on a VAX (IEEE ar it hmet ic has enough mant issa for only

), t he poles of t he per t ur bed t r ansfer funct ion (equivalent ly, t he

eigenvalues of ) ar e

eig(A)'

ans =

Columns 1 through 7

–19.9998 –19.0019 –17.9916 –17.0217 –15.9594 –15.0516 –13.9504

Columns 8 through 14

–13.0369 –11.9805 –11.0081 –9.9976 –9.0005 –7.9999 –7.0000

Columns 15 through 20

–6.0000 –5.0000 –4.0000 –3.0000 –2.0000 –1.0000

The pr oblem her e is not r oundoff. Rat her , high-or der polynomials ar e simply

int r insically ver y sensit ive, even when t he zer os ar e well separ at ed. In t his

case, a r elat ive per t ur bat ion of t he or der of induced r elat ive

per t ur bat ions of t he or der of in some r oot s. But some of t he r oot s changed

H s ( )

1

s 1 + ( ) s 2 + ( )... s 20 + ( )

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

1

s

20

210s

19

... 20! + + +

----------------------------------------------------------- = =

A H s ( )

A

0 1 0 ... 0

0 0 1 ... 0

: : . . :

0 0 ... . 1

20! – . ... . 210 –

=

A 20! 2.4 10

18

× ≈

s

19

A n n , ( ) 210 2

23 –

+ 2

23 –

1.2 10

7 –

× ≈

n 17 =

A

10

9 –

10

2 –

10 Reliable Computations

10-10

ver y lit t le. This is t r ue in gener al. Differ ent r oot s have differ ent sensit ivit ies t o

differ ent per t ur bat ions. Comput ed r oot s may t hen be quit e meaningless for a

polynomial, par t icular ly high-or der , wit h impr ecisely known coefficient s.

Finding all t he r oot s of a polynomial (equivalent ly, t he poles of a t r ansfer

funct ion or t he eigenvalues of a mat r ix in cont r ollable or obser vable canonical

for m) is oft en an int r insically sensit ive pr oblem. For a clear and det ailed

t r eat ment of t he subject , including t he t r icky numer ical pr oblem of deflat ion,

consult [6].

It is t her efor e pr efer able t o wor k wit h t he fact or ed for m of polynomials when

available. To comput e a st at e-space model of t he t r ansfer funct ion

defined above, for example, you could expand t he denominat or of , conver t

t he t r ansfer funct ion model t o st at e space, and ext r act t he st at e-space dat a by

H1 = tf(1,poly(1:20))

H1ss = ss(H1)

[a1,b1,c1] = ssdata(H1)

However , you should r at her keep t he denominat or in fact or ed for m and wor k

wit h t he zer o-pole-gain r epr esent at ion of .

H2 = zpk([],1:20,1)

H2ss = ss(H2)

[a2,b2,c2] = ssdata(H2)

Indeed, t he r esult ing st at e mat r ix a2 is bet t er condit ioned.

[cond(a1) cond(a2)]

ans =

2.7681e+03 8.8753e+01

H s ( )

H

H s ( )

Choice of LTI Model

10-11

and t he conver sion fr om zer o-pole-gain t o st at e space incur s no loss of accur acy

in t he poles.

format long e

[sort(eig(a1)) sort(eig(a2))]

ans =

9.999999999998792e-01 1.000000000000000e+00

2.000000000001984e+00 2.000000000000000e+00

3.000000000475623e+00 3.000000000000000e+00

3.999999981263996e+00 4.000000000000000e+00

5.000000270433721e+00 5.000000000000000e+00

5.999998194359617e+00 6.000000000000000e+00

7.000004542844700e+00 7.000000000000000e+00

8.000013753274901e+00 8.000000000000000e+00

8.999848908317270e+00 9.000000000000000e+00

1.000059459550623e+01 1.000000000000000e+01

1.099854678336595e+01 1.100000000000000e+01

1.200255822210095e+01 1.200000000000000e+01

1.299647702454549e+01 1.300000000000000e+01

1.400406940833612e+01 1.400000000000000e+01

1.499604787386921e+01 1.500000000000000e+01

1.600304396718421e+01 1.600000000000000e+01

1.699828695210055e+01 1.700000000000000e+01

1.800062935148728e+01 1.800000000000000e+01

1.899986934359322e+01 1.900000000000000e+01

2.000001082693916e+01 2.000000000000000e+01

Ther e is anot her difficult y wit h t r ansfer funct ion models when r ealized in

st at e-space for m wit h ss. They may give r ise t o badly condit ioned eigenvect or

mat r ices, even if t he eigenvalues ar e well separ at ed. For example, consider t he

nor mal mat r ix

A = [5 4 1 1

4 5 1 1

1 1 4 2

1 1 2 4]

10 Reliable Computations

10-12

It s eigenvect or s and eigenvalues ar e given as follows.

[v,d] = eig(A)

v =

0.7071 –0.0000 –0.3162 0.6325

–0.7071 0.0000 –0.3162 0.6325

0.0000 0.7071 0.6325 0.3162

–0.0000 –0.7071 0.6325 0.3162

d =

1.0000 0 0 0

0 2.0000 0 0

0 0 5.0000 0

0 0 0 10.0000

The condit ion number (wit h r espect t o inver sion) of t he eigenvect or mat r ix is

cond(v)

ans =

1.000

Now conver t a st at e-space model wit h t he above A mat r ix t o t r ansfer funct ion

for m, and back again t o st at e-space for m.

b = [1 ; 1 ; 0 ; –1];

c = [0 0 2 1];

H = tf(ss(A,b,c,0)); % transfer function

[Ac,bc,cc] = ssdata(H) % convert back to state space

The new A mat r ix is

Ac =

18.0000 –6.0625 2.8125 –1.5625

16.0000 0 0 0

0 4.0000 0 0

0 0 1.0000 0

Not e t hat Ac is not a st andar d companion mat r ix and has alr eady been

balanced as par t of t he ss conver sion (see ssbal for det ails).

Choice of LTI Model

10-13

Not e also t hat t he eigenvect or s have changed.

[vc,dc] = eig(Ac)

vc =

–0.5017 0.2353 0.0510 0.0109

–0.8026 0.7531 0.4077 0.1741

–0.3211 0.6025 0.8154 0.6963

–0.0321 0.1205 0.4077 0.6963

dc =

10.0000 0 0 0

0 5.0000 0 0

0 0 2.0000 0

0 0 0 1.0000

The condit ion number of t he new eigenvect or mat r ix

cond(vc)

ans =

34.5825

is t hir t y t imes lar ger .

The phenomenon illust r at ed above is not unusual. Mat r ices in companion for m

or cont r ollable/obser vable canonical for m (like Ac) t ypically have

wor se-condit ioned eigensyst ems t han mat r ices in gener al st at e-space for m

(like A). This means t hat t heir eigenvalues and eigenvect or s ar e mor e sensit ive

t o per t ur bat ion. The pr oblem gener ally get s far wor se for higher -or der syst ems.

Wor king wit h high-or der t r ansfer funct ion models and conver t ing t hem back

and for t h t o st at e space is numer ically r isky.

In summar y, t he main numer ical pr oblems t o be awar e of in dealing wit h

t r ansfer funct ion models (and hence, calculat ions involving polynomials) ar e:

• The pot ent ially lar ge r ange of number s leads t o ill-condit ioned pr oblems,

especially when such models ar e linked t oget her giving high-or der

polynomials.

10 Reliable Computations

10-14

• The pole locat ions ar e ver y sensit ive t o t he coefficient s of t he denominat or

polynomial.

• The balanced companion for m pr oduced by ss, while bet t er t han t he

st andar d companion for m, oft en r esult s in ill-condit ioned eigenpr oblems,

especially wit h higher -or der syst ems.

The above st at ement s hold even for syst ems wit h dist inct poles, but ar e

par t icular ly r elevant when poles ar e mult iple.

Zero-Pole-Gain Models

The t hir d major r epr esent at ion used for LTI models in MATLAB is t he

fact or ed, or zer o-pole-gain (ZPK) r epr esent at ion. It is somet imes ver y

convenient t o descr ibe a model in t his way alt hough most major design

met hodologies t end t o be or ient ed t owar ds eit her t r ansfer funct ions or

st at e-space.

In cont r ast t o polynomials, t he ZPK r epr esent at ion of syst ems can be mor e

r eliable. At t he ver y least , t he ZPK r epr esent at ion t ends t o avoid t he

ext r aor dinar y ar it hmet ic r ange difficult ies of polynomial coefficient s, as

illust r at ed in t he “Tr ansfer Funct ion”sect ion. The t r ansfor mat ion fr om st at e

space t o zer o-pole-gain is st able, alt hough t he handling of infinit e zer os can

somet imes be t r icky, and r epeat ed r oot s can cause pr oblems.

If possible, avoid r epeat ed swit ching bet ween differ ent model r epr esent at ions.

As discussed in t he pr evious sect ions, when t r ansfor mat ions bet ween models

ar e not numer ically st able, r oundoff er r or s ar e amplified.

Scaling

10-15

Scaling

St at e space is t he pr efer r ed model for LTI syst ems, especially wit h higher or der

models. Even wit h st at e-space models, however , accur at e r esult s ar e not

guar ant eed, because of t he finit e-wor d-lengt h ar it hmet ic of t he comput er . A

well-condit ioned pr oblem is usually a pr er equisit e for obt aining accur at e

r esult s.

You should gener ally nor malize or scale t he mat r ices of a syst em

t o impr ove t heir condit ioning. An example of a poor ly scaled pr oblem might be

a dynamic syst em wher e t wo st at es in t he st at e vect or have unit s of light year s

and millimet er s. You would expect t he mat r ix t o cont ain bot h ver y lar ge and

ver y small number s. Mat r ices cont aining number s widely spr ead in value ar e

oft en poor ly condit ioned bot h wit h r espect t o inver sion and wit h r espect t o t heir

eigenpr oblems, and inaccur at e r esult s can ensue.

Nor malizat ion also allows meaningful st at ement s t o be made about t he degr ee

of cont r ollabilit y and obser vabilit y of t he var ious input s and out put s.

A set of mat r ices can be nor malized using diagonal scaling

mat r ices , , and t o scale u, x, and y.

so t he nor malized syst em is

wher e

Choose t he diagonal scaling mat r ices accor ding t o some appr opr iat e

nor malizat ion pr ocedur e. One cr it er ion is t o choose t he maximum r ange of each

of t he input , st at e, and out put var iables. This met hod or iginat ed in t he days of

analog simulat ion comput er s when , , and wer e for ced t o be bet ween

Volt s. A second met hod is t o for m scaling mat r ices wher e t he diagonal

ent r ies ar e t he smallest deviat ions t hat ar e significant t o each var iable. An

A B C D , , , ( )

A

A B C D , , , ( )

N

u

N

x

N

y

u N

u

u

n

= x N

x

x

n

= y N

y

y

n

=

x

·

n

A

n

x

n

B

n

u

n

+ =

y

n

C

n

x

n

D

n

u

n

+ =

A

n

N

x

1 –

AN

x

= B

n

N

x

1 –

BN

u

=

C

n

N

y

1 –

CN

x

= D

n

N

y

1 –

DN

u

=

u

n

x

n

y

n

10 t

10 Reliable Computations

10-16

excellent discussion of scaling is given in t he int r oduct ion t o t he LINPACK

Users’ Guide, [1].

Choose scaling based upon physical insight t o t he pr oblem at hand. If you

choose not t o scale, and for many small pr oblems scaling is not necessar y, be

awar e t hat t his choice affect s t he accur acy of your answer s.

Finally, not e t hat t he funct ion ssbal per for ms aut omat ic scaling of t he st at e

vect or . Specifically, it seeks t o minimize t he nor m of

by using diagonal scaling mat r ices . Such diagonal scaling is an economical

way t o compr ess t he numer ical r ange and impr ove t he condit ioning of

subsequent st at e-space comput at ions.

N

x

1 –

AN

x

N

x

1 –

B

CN

x

0

N

x

Summary

10-17

Summary

This chapt er has descr ibed numer ous t hings t hat can go wr ong when

per for ming numer ical comput at ions. You won’t encount er most of t hese

difficult ies when you solve pr act ical lower -or der pr oblems. The pr oblems

descr ibed her e per t ain t o all comput er analysis packages. MATLAB has some

of t he best algor it hms available, and, wher e possible, not ifies you when t her e

ar e difficult ies. The impor t ant point s t o r emember ar e:

• St at e-space models ar e, in gener al, t he most r eliable models for subsequent

comput at ions.

• Scaling model dat a can impr ove t he accur acy of your r esult s.

• Numer ical comput ing is a t r icky business, and vir t ually all comput er t ools

can fail under cer t ain condit ions.

10 Reliable Computations

10-18

References

[1] Dongar r a, J .J ., J .R. Bunch, C.B. Moler , and G.W. St ewar t , LINPACK Users

Guide, SIAM Publicat ions, Philadelphia, PA, 1978.

[2] Fr anklin, G.F. and J .D. Powell, Digital Control of Dynamic S ystems,

Addison-Wesley, 1980.

[3] Kailat h, T., Linear S ystems, Pr ent ice-Hall, 1980.

[4] Laub, A.J ., “Numer ical Linear Algebr a Aspect s of Cont r ol Design

Comput at ions,” IEEE Transactions on Automatic Control, Vol. AC-30, No. 2,

Febr uar y 1985, pp. 97-108.

[5] Wilkinson, J .H., Rounding Errors in Algebraic Processes, Pr ent ice-Hall,

1963.

[6] Wilkinson, J .H., The Algebraic Eigenvalue Problem, Oxfor d Univer sit y

Pr ess, 1965.

11

Refer ence

11 Reference

11-2

This chapt er cont ains det ailed descr ipt ions of all Cont r ol Syst em Toolbox

funct ions. It begins wit h a list of funct ions gr ouped by subject ar ea and

cont inues wit h t he r efer ence ent r ies in alphabet ical or der . Infor mat ion is also

available t hr ough t he online Help facilit y.

Category Tables

11-3

Category Tables

Table 11-1: LTI Models

Function Name Description

drss Gener at e r andom discr et e st at e-space model.

dss Cr eat e descr ipt or st at e-space model.

filt Cr eat e discr et e filt er wit h DSP convent ion.

frd Cr eat e a fr equency r esponse dat a (FRD) model.

frdata Ret r ieve dat a fr om an FRD model.

get Quer y LTI model pr oper t ies.

ltimodels Infor mat ion on LTI models

ltiprops Infor mat ion on all LTI pr oper t ies.

set Set LTI or r esponse object pr oper t ies.

rss Gener at e r andom cont inuous st at e-space model.

ss Cr eat e st at e-space model.

ssdata, dssdata Ret r ieve st at e-space dat a or cover t dat a t o cell

ar r ay for mat .

tf Cr eat e t r ansfer funct ion.

tfdata Ret r ieve t r ansfer funct ion dat a.

totaldelay Pr ovide t he aggr egat e delay for an LTI model.

zpk Cr eat e zer o-pole-gain model.

zpkdata Ret r ieve zer o-pole-gain dat a.

11 Reference

11-4

Table 11-2: Model Characteristics

Function Name Description

class Display model t ype ('tf', 'zpk', 'ss', or 'frd').

hasdelay Test t r ue if LTI model has any t ype of delay.

isa Test t r ue if LTI model is of specified t ype.

isct Test t r ue for cont inuous-t ime models.

isdt Test t r ue for discr et e-t ime models.

isempty Test t r ue for empt y LTI models.

isproper Test t r ue for pr oper LTI models.

issiso Test t r ue for SISO models.

ndims Get t he number of model/ar r ay dimensions.

size Get out put /input /ar r ay dimensions or model or der.

Table 11-3: Model Conversion

Function Name Description

c2d Conver t fr om cont inuous- t o discr et e-t ime models.

chgunits Conver t t he units pr oper t y for FRD models.

d2c Conver t fr om discr et e- t o cont inuous-t ime models.

d2d Resample discr et e-t ime models.

delay2z Conver t delays in discr et e-t ime models or FRD

models.

frd Conver t t o a fr equency r esponse dat a model.

pade Comput e t he Padé appr oximat ion of delays.

reshape Change t he shape of an LTI ar r ay

Category Tables

11-5

residue Pr ovide par t ial fr act ion expansion (see Using

MATLAB).

ss Conver t t o a st at e space model.

tf Conver t t o a t r ansfer funct ion model.

zpk Conver t t o a zer o-pole-gain model.

Table 11-4: Model Order Reduction

Function Name Description

balreal Calculat e an I/O balanced r ealizat ion.

minreal Calculat e minimal r ealizat ion or pole/zer o

cancellat ion.

modred Delet e st at es in I/O balanced r ealizat ion.

sminreal Calculat e st r uct ur ed model r educt ion.

Table 11-5: State-Space Realizations

Function Name Description

canon Canonical st at e-space r ealizat ions.

ctrb Cont r ollabilit y mat r ix.

ctrbf Cont r ollabilit y st air case for m.

gram Cont r ollabilit y and obser vabilit y gr amians.

obsv Obser vabilit y mat r ix.

obsvf Obser vabilit y st air case for m.

Table 11-3: Model Conversion (Continued)

Function Name Description

11 Reference

11-6

ss2ss St at e coor dinat e t r ansfor mat ion.

ssbal Diagonal balancing of st at e-space r ealizat ions.

Table 11-6: Model Dynamics

Function Name Description

damp Calculat e nat ur al fr equency and damping.

dcgain Calculat e low-fr equency (DC) gain.

covar Calculat e covar iance of r esponse t o whit e noise.

dsort Sor t discr et e-t ime poles by magnit ude.

esort Sor t cont inuous-t ime poles by r eal par t .

norm Calculat e nor ms of LTI models ( and ).

pole, eig Calculat e t he poles of an LTI model.

pzmap Plot t he pole/zer o map of an LTI model.

roots Calculat e r oot s of polynomial (see Using MATLAB).

zero Calculat e zer os of an LTI model.

Table 11-7: Model Building

Function Name Description

append Append models in a block diagonal configur at ion.

augstate Augment out put by appending st at es.

Table 11-5: State-Space Realizations (Continued)

Function Name Description

H

2

L

∞

Category Tables

11-7

connect Connect t he subsyst ems of a block-diagonal model

accor ding t o an int er connect ion scheme of your

choice.

conv Convolve t wo polynomials (see Using MATLAB).

drmodel, drss Gener at e r andom discr et e-t ime model.

feedback Calculat e t he feedback connect ion of models.

lft Calculat e t he st ar pr oduct (LFT int er connect ion).

ord2 Gener at e second-or der model.

pade Comput e t he Padé appr oximat ion of t ime delays.

parallel Cr eat e a gener alized par allel connect ion.

rmodel, rss Gener at e r andom cont inuous model.

series Cr eat e a gener alized ser ies connect ion.

stack Concat enat e LTI models along ar r ay dimensions.

Table 11-8: Time Response

Function Name Description

filter Simulat e discr et e SISO filt er (see Using MATLAB).

gensig Gener at e an input signal.

impulse Calculat e impulse r esponse.

initial Calculat e init ial condit ion r esponse.

lsim Simulat e r esponse of LTI model t o ar bit r ar y input s.

Table 11-7: Model Building (Continued)

Function Name Description

11 Reference

11-8

ltiview Open t he LTI Viewer for linear r esponse analysis.

step Calculat e st ep r esponse.

Table 11-9: Frequency Response

Function Name Description

bode Calculat e bode plot .

evalfr Evaluat e r esponse at single complex fr equency.

freqresp Evaluat e fr equency r esponse for select ed

fr equencies.

linspace Cr eat e a vect or of evenly spaced fr equencies.

logspace Cr eat e a vect or of logar it hmically spaced

fr equencies.

ltiview Open t he LTI Viewer for linear r esponse analysis.

margin Calculat e gain and phase mar gins.

ngrid Super impose gr id lines on a Nichols plot .

nichols Calculat e Nichols plot .

nyquist Calculat e Nyquist plot .

pzmap Calculat e pole/zer o map.

rlocus Calculat e r oot locus.

rlocfind Find gain/pole on r oot locus.

rltool Open Root Locus Design GUI.

sgrid Super impose s-plane gr id on r oot locus or pole/zer o

map.

Table 11-8: Time Response (Continued)

Function Name Description

Category Tables

11-9

sigma Calculat e singular value plot .

zgrid Super impose z-plane gr id on r oot locus or pole/zer o

map.

Table 11-10: Pole Placement

Function Name Description

acker Calculat e SISO pole placement design.

place Calculat e MIMO pole placement design.

estim For m st at e est imat or given est imat or gain.

reg For m out put -feedback compensat or given

st at e-feedback and est imat or gains.

rltool Open Root Locus Design GUI

Table 11-11: LQG Design

Function Name Description

lqr Calculat e t he LQ-opt imal gain for cont inuous

models.

dlqr Calculat e t he LQ-opt imal gain for discr et e models.

lqry Calculat e t he LQ-opt imal gain wit h out put

weight ing.

lqrd Calculat e t he discr et e LQ gain for cont inuous

models.

kalman Calculat e t he Kalman est imat or.

Table 11-9: Frequency Response (Continued)

Function Name Description

11 Reference

11-10

kalmd Calculat e t he discr et e Kalman est imat or for

cont inuous models.

lqgreg For m LQG r egulat or given LQ gain and Kalman

filt er.

Table 11-12: Equation Solvers

Function Name Description

care Solve cont inuous-t ime algebr aic Riccat i equat ions.

dare Solve discr et e-t ime algebr aic Riccat i equat ions.

lyap Solve cont inuous-t ime Lyapunov equat ions.

dlyap Solve discr et e-t ime Lyapunov equat ions.

Table 11-13: Graphical User Interfaces for Model Analysis and Design

Function Name Description

ltiview Open t he LTI Viewer for linear r esponse analysis.

rltool Open t he Root Locus Design GUI.

Table 11-11: LQG Design (Continued)

Function Name Description

acker

11-11

11acker

Purpose Pole placement design for single-input syst ems

Syntax k = acker(A,b,p)

Description Given t he single-input syst em

and a vect or p of desir ed closed-loop pole locat ions, acker (A,b,p)uses

Acker mann’s for mula [1] t o calculat e a gain vect or k such t hat t he st at e

feedback places t he closed-loop poles at t he locat ions p. In ot her

wor ds, t he eigenvalues of mat ch t he ent r ies of p (up t o or der ing). Her e

A is t he st at e t r ansmit t er mat r ix and b is t he input t o st at e t r ansmission vect or .

You can also use acker for est imat or gain select ion by t r ansposing t he mat r ix

A and subst it ut ing c' for b when y = cx is a single out put .

l = acker(a',c',p).'

Limitations acker is limit ed t o single-input syst ems and t he pair must be

cont r ollable.

Not e t hat t his met hod is not numer ically r eliable and st ar t s t o br eak down

r apidly for pr oblems of or der gr eat er t han 5 or for weakly cont r ollable syst ems.

See place for a mor e gener al and r eliable alt er nat ive.

See Also lqr Opt imal LQ r egulat or

place Pole placement design

rlocus, rlocfind Root locus design

References [1] Kailat h, T., Linear S ystems, Pr ent ice-Hall, 1980, p. 201.

x

·

Ax bu + =

u k x – =

A bk –

A b , ( )

append

11-12

11append

Purpose Gr oup LTI models by appending t heir input s and out put s

Syntax sys = append(sys1,sys2,...,sysN)

Description append appends t he input s and out put s of t he LTI models sys1,...,sysN t o for m

t he augment ed model sys depict ed below.

For syst ems wit h t r ansfer funct ions ,..., , t he r esult ing syst em sys

has t he block-diagonal t r ansfer funct ion

For st at e-space models sys1 and sys2 wit h dat a and

, append(sys1,sys2) pr oduces t he following st at e-space

model.

:

:

sys1

sys2

sysN

u

1

u

2

u

N

y

1

y

2

y

N

sys

H

1

s ( ) H

N

s ( )

H

1

s ( ) 0 .. 0

0 H

2

s ( ) . :

: . . 0

0 .. 0 H

N

s ( )

A

1

B

1

C

1

D

1

, , , ( )

A

2

B

2

C

2

D

2

, , , ( )

append

11-13

Arguments The input ar gument s sys1,..., sysN can be LTI models of any t ype. Regular

mat r ices ar e also accept ed as a r epr esent at ion of st at ic gains, but t her e should

be at least one LTI object in t he input list . The LTI models should be eit her all

cont inuous, or all discr et e wit h t he same sample t ime. When appending models

of differ ent t ypes, t he r esult ing t ype is det er mined by t he pr ecedence r ules (see

“Pr ecedence Rules” on page 2-5 for det ails).

Ther e is no limit at ion on t he number of input s.

Example The commands

sys1 = tf(1,[1 0])

sys2 = ss(1,2,3,4)

sys = append(sys1,10,sys2)

pr oduce t he st at e-space model

sys

a =

x1 x2

x1 0 0

x2 0 1.00000

b =

u1 u2 u3

x1 1.00000 0 0

x2 0 0 2.00000

x

·

1

x

·

2

A

1

0

0 A

2

x

1

x

2

B

1

0

0 B

2

u

1

u

2

+ =

y

1

y

2

C

1

0

0 C

2

x

1

x

2

D

1

0

0 D

2

u

1

u

2

+ =

append

11-14

c =

x1 x2

y1 1.00000 0

y2 0 0

y3 0 3.00000

d =

u1 u2 u3

y1 0 0 0

y2 0 10.00000 0

y3 0 0 4.00000

Continuous-time system.

See Also connect Modeling of block diagr am int er connect ions

feedback Feedback connect ion

parallel Par allel connect ion

series Ser ies connect ion

augstate

11-15

11augst at e

Purpose Append t he st at e vect or t o t he out put vect or

Syntax asys = augstate(sys)

Description Given a st at e-space model sys wit h equat ions

(or t heir discr et e-t ime count er par t ), augstate appends t he st at es t o t he

out put s t o for m t he model

This command pr epar es t he plant so t hat you can use t he feedback command

t o close t he loop on a full-st at e feedback .

Limitation Because augstate is only meaningful for st at e-space models, it cannot be used

wit h TF, ZPK or FRD models.

See Also feedback Feedback connect ion

parallel Par allel connect ion

series Ser ies connect ion

x

·

Ax Bu + =

y Cx Du + =

x

y

x

·

Ax Bu + =

y

x

C

I

x

D

0

u + =

u K – x =

balreal

11-16

11balr eal

Purpose Input /out put balancing of st at e-space r ealizat ions

Syntax sysb = balreal(sys)

[sysb,g,T,Ti] = balreal(sys)

Description sysb = balreal(sys) pr oduces a balanced r ealizat ion sysb of t he LTI model

sys wit h equal and diagonal cont r ollabilit y and obser vabilit y gr amians (see

gram for a definit ion of gr amian). balreal handles bot h cont inuous and discr et e

syst ems. If sys is not a st at e-space model, it is fir st and aut omat ically

conver t ed t o st at e space using ss.

[sysb,g,T,Ti] = balreal(sys) also r et ur ns t he vect or g cont aining t he

diagonal of t he balanced gr amian, t he st at e similar it y t r ansfor mat ion

used t o conver t sys t o sysb, and t he inver se t r ansfor mat ion Ti = .

If t he syst em is nor malized pr oper ly, t he diagonal g of t he joint gr amian can be

used t o r educe t he model or der . Because g r eflect s t he combined cont r ollabilit y

and obser vabilit y of individual st at es of t he balanced model, you can delet e

t hose st at es wit h a small g(i) while r et aining t he most impor t ant input -out put

char act er ist ics of t he or iginal syst em. Use modred t o per for m t he st at e

eliminat ion.

Example Consider t he zer o-pole-gain model

sys = zpk([–10 –20.01],[–5 –9.9 –20.1],1)

Zero/pole/gain:

(s+10) (s+20.01)

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

(s+5) (s+9.9) (s+20.1)

A st at e-space r ealizat ion wit h balanced gr amians is obt ained by

[sysb,g] = balreal(sys)

The diagonal ent r ies of t he joint gr amian ar e

g'

ans =

1.0062e–01 6.8039e–05 1.0055e–05

x

b

T x =

T

1 –

balreal

11-17

which indicat es t hat t he last t wo st at es of sysb ar e weakly coupled t o t he input

and out put . You can t hen delet e t hese st at es by

sysr = modred(sysb,[2 3],'del')

t o obt ain t he following fir st -or der appr oximat ion of t he or iginal syst em.

zpk(sysr)

Zero/pole/gain:

1.0001

--------

(s+4.97)

Compar e t he Bode r esponses of t he or iginal and r educed-or der models.

bode(sys,'-',sysr,'x')

Frequency (rad/sec)

P

h

a

s

e

(

d

e

g

)

;

M

a

g

n

i

t

u

d

e

(

d

B

)

Bode Diagrams

−50

−40

−30

−20

−10

10

0

10

1

10

2

−100

−80

−60

−40

−20

0

balreal

11-18

Algorithm Consider t he model

wit h cont r ollabilit y and obser vabilit y gr amians and . The st at e

coor dinat e t r ansfor mat ion pr oduces t he equivalent model

and t r ansfor ms t he gr amians t o

The funct ion balreal comput es a par t icular similar it y t r ansfor mat ion such

t hat

See [1,2] for det ails on t he algor it hm.

Limitations The LTI model sys must be st able. In addit ion, cont r ollabilit y and

obser vabilit y ar e r equir ed for st at e-space models.

See Also gram Cont r ollabilit y and obser vabilit y gr amians

minreal Minimal r ealizat ions

modred Model or der r educt ion

References [1] Laub, A.J ., M.T. Heat h, C.C. Paige, and R.C. War d, “Comput at ion of Syst em

Balancing Tr ansfor mat ions and Ot her Applicat ions of Simult aneous

Diagonalizat ion Algor it hms,” IEEE Trans. Automatic Control, AC-32 (1987),

pp. 115–122.

[2] Moor e, B., “Pr incipal Component Analysis in Linear Syst ems:

Cont r ollabilit y, Obser vabilit y, and Model Reduct ion,” IEEE Transactions on

Automatic Control, AC-26 (1981), pp. 17–31.

[3] Laub, A.J ., “Comput at ion of Balancing Tr ansfor mat ions,” Proc. ACC, San

Fr ancisco, Vol.1, paper FA8-E, 1980.

x

·

Ax Bu + =

y Cx Du + =

W

c

W

o

x T x =

x

·

T AT

1 –

x T Bu + =

y CT

1 –

x Du + =

W

c

T W

c

T

T

= , W

o

T

T –

W

o

T

1 –

=

T

Wc Wo d i ag g ( ) = =

bode

11-19

11bode

Purpose Comput e t he Bode fr equency r esponse of LTI models

Syntax bode(sys)

bode(sys,w)

bode(sys1,sys2,...,sysN)

bode(sys1,sys2,...,sysN,w)

bode(sys1,'PlotStyle1',...,sysN,'PlotStyleN')

[mag,phase,w] = bode(sys)

Description bode comput es t he magnit ude and phase of t he fr equency r esponse of LTI

models. When invoked wit hout left -hand ar gument s, bode pr oduces a Bode plot

on t he scr een. The magnit ude is plot t ed in decibels (dB), and t he phase in

degr ees. The decibel calculat ion for mag is comput ed as

20*log10(abs(frsys)), wher e frsys is t he fr equency r esponse of sys. Bode

plot s ar e used t o analyze syst em pr oper t ies such as t he gain mar gin, phase

mar gin, DC gain, bandwidt h, dist ur bance r eject ion, and st abilit y.

bode(sys) plot s t he Bode r esponse of an ar bit r ar y LTI model sys. This model

can be cont inuous or discr et e, and SISO or MIMO. In t he MIMO case, bode

pr oduces an ar r ay of Bode plot s, each plot showing t he Bode r esponse of one

par t icular I/O channel. The fr equency r ange is det er mined aut omat ically based

on t he syst em poles and zer os.

bode(sys,w) explicit ly specifies t he fr equency r ange or fr equency point s t o be

used for t he plot . To focus on a par t icular fr equency int er val [wmin,wmax], set

w = {wmin,wmax}. To use par t icular fr equency point s, set w t o t he vect or of

desir ed fr equencies. Use logspace t o gener at e logar it hmically spaced

fr equency vect or s. All fr equencies should be specified in r adians/sec.

bode(sys1,sys2,...,sysN) or bode(sys1,sys2,...,sysN,w) plot s t he Bode

r esponses of sever al LTI models on a single figur e. All syst ems must have t he

same number of input s and out put s, but may ot her wise be a mix of cont inuous

and discr et e syst ems. This synt ax is useful t o compar e t he Bode r esponses of

mult iple syst ems.

bode(sys1,'PlotStyle1',...,sysN,'PlotStyleN') specifies which color ,

linest yle, and/or mar ker should be used t o plot each syst em. For example,

bode(sys1,'r--',sys2,'gx')

bode

11-20

uses r ed dashed lines for t he fir st syst em sys1 and gr een 'x' mar ker s for t he

second syst em sys2.

When invoked wit h left -hand ar gument s

[mag,phase,w] = bode(sys)

[mag,phase] = bode(sys,w)

r et ur n t he magnit ude and phase (in degr ees) of t he fr equency r esponse at t he

fr equencies w (in r ad/sec). The out put s mag and phase ar e 3-D ar r ays wit h t he

fr equency as t he last dimension (see “Ar gument s” below for det ails). You can

conver t t he magnit ude t o decibels by

magdb = 20*log10(mag)

Remark If sys is an FRD model, bode(sys,w), w can only include fr equencies in

sys.frequency.

Arguments The out put ar gument s mag and phase ar e 3-D ar r ays wit h dimensions

For SISO syst ems, mag(1,1,k) and phase(1,1,k) give t he magnit ude and

phase of t he r esponse at t he fr equency = w(k).

MIMO syst ems ar e t r eat ed as ar r ays of SISO syst ems and t he magnit udes and

phases ar e comput ed for each SISO ent r y independent ly ( is t he t r ansfer

funct ion fr om input t o out put ). The values mag(i,j,k) and phase(i,j,k)

t hen char act er ize t he r esponse of at t he fr equency w(k).

Example You can plot t he Bode r esponse of t he cont inuous SISO syst em

number of out put s ( ) number of input s ( ) × lengt h of w ( ) ×

ω

k

mag(1,1,k) h j ω

k

( ) =

phase(1,1,k) h j ω

k

( ) ∠ =

h

i j

h

i j

j i

h

i j

mag(i,j,k) h

i j

j ω

k

( ) =

phase(i,j,k) h

i j

j ω

k

( ) ∠ =

bode

11-21

by t yping

g = tf([1 0.1 7.5],[1 0.12 9 0 0]);

bode(g)

To plot t he r esponse on a wider fr equency r ange, for example, fr om 0.1 t o 100

r ad/sec, t ype

bode(g,{0.1 , 100})

H s ( )

s

2

0.1s 7.5 + +

s

4

0.12s

3

9s

2

+ +

--------------------------------------------- =

Frequency (rad/sec)

P

h

a

s

e

(

d

e

g

)

;

M

a

g

n

i

t

u

d

e

(

d

B

)

Bode Diagrams

−40

−20

0

20

40

10

−1

10

0

10

1

−200

−150

−100

−50

0

bode

11-22

You can also discr et ize t his syst em using zer o-or der hold and t he sample t ime

second, and compar e t he cont inuous and discr et ized r esponses by

t yping

gd = c2d(g,0.5)

bode(g,'r',gd,'b--')

Algorithm For cont inuous-t ime syst ems, bode comput es t he fr equency r esponse by

evaluat ing t he t r ansfer funct ion on t he imaginar y axis . Only

posit ive fr equencies ar e consider ed. For st at e-space models, t he fr equency

r esponse is

When numer ically safe, is diagonalized for maximum speed. Ot her wise,

is r educed t o upper Hessenber g for m and t he linear equat ion

is solved at each fr equency point , t aking advant age of t he Hessenber g

T

s

0.5 =

Frequency (rad/sec)

P

h

a

s

e

(

d

e

g

)

;

M

a

g

n

i

t

u

d

e

(

d

B

)

Bode Diagrams

−100

−50

0

50

10

−1

10

0

10

1

−300

−250

−200

−150

−100

−50

0

H s ( ) s j ω =

ω

D C j ω A – ( )

1 –

B + , ω 0 ≥

A A

j ω A – ( )X B =

bode

11-23

st r uct ur e. The r educt ion t o Hessenber g for m pr ovides a good compr omise

bet ween efficiency and r eliabilit y. See [1] for mor e det ails on t his t echnique.

For discr et e-t ime syst ems, t he fr equency r esponse is obt ained by evaluat ing

t he t r ansfer funct ion on t he unit cir cle. To facilit at e int er pr et at ion, t he

upper -half of t he unit cir cle is par amet r ized as

wher e is t he sample t ime. is called t he Nyquist frequency. The

equivalent “cont inuous-t ime fr equency” is t hen used as t he -axis var iable.

Because

is per iodic wit h per iod , bode plot s t he r esponse only up t o t he Nyquist

fr equency . If t he sample t ime is unspecified, t he default value is

assumed.

Diagnostics If t he syst em has a pole on t he axis (or unit cir cle in t he discr et e case) and

w happens t o cont ain t his fr equency point , t he gain is infinit e, is

singular , and bode pr oduces t he war ning message

Singularity in freq. response due to jw-axis or unit circle pole.

See Also evalfr Response at single complex fr equency

freqresp Fr equency r esponse comput at ion

ltiview LTI syst em viewer

nichols Nichols plot

nyquist Nyquist plot

sigma Singular value plot

References [1] Laub, A.J ., “Efficient Mult ivar iable Fr equency Response Comput at ions,”

IEEE Transactions on Automatic Control, AC-26 (1981), pp. 407–408.

H z ( )

z e

j ωT

s

= , 0 ω ω

N

≤ ≤

π

T

s

------ =

T

s

ω

N

ω x

H e

j ωT

s

( )

2ω

N

ω

N

T

s

1 =

j ω

j ωI A –

c2d

11-24

11c2d

Purpose Discr et ize cont inuous-t ime syst ems

Syntax sysd = c2d(sys,Ts)

sysd = c2d(sys,Ts,method)

Description sysd = c2d(sys,Ts) discr et izes t he cont inuous-t ime LTI model sys using

zer o-or der hold on t he input s and a sample t ime of Ts seconds.

sysd = c2d(sys,Ts,method) gives access t o alt er nat ive discr et izat ion

schemes. The st r ing method select s t he discr et izat ion met hod among t he

following:

Refer t o “Cont inuous/Discr et e Conver sions of LTI Models” in Chapt er 3 for

mor e det ail on t hese discr et izat ion met hods.

c2d suppor t s MIMO syst ems (except for t he 'matched' met hod) as well as LTI

models wit h input delays ('zoh' and 'foh' met hods only).

Example Consider t he syst em

'zoh' Zer o-or der hold. The cont r ol input s ar e assumed piecewise

const ant over t he sampling per iod Ts.

'foh' Tr iangle appr oximat ion (modified fir st -or der hold, see [1], p.

151). The cont r ol input s ar e assumed piecewise linear over

t he sampling per iod Ts.

'tustin' Bilinear (Tust in) appr oximat ion.

'prewarp' Tust in appr oximat ion wit h fr equency pr ewar ping.

'matched' Mat ched pole-zer o met hod. See [1], p. 147.

H s ( )

s 1 –

s

2

4s 5 + +

--------------------------- - =

c2d

11-25

wit h input delay second. To discr et ize t his syst em using t he

t r iangle appr oximat ion wit h sample t ime second, t ype

H = tf([1 –1],[1 4 5],'inputdelay',0.35)

Transfer function:

s - 1

exp(-0.35*s) * -------------

s^2 + 4 s + 5

Hd = c2d(H,0.1,'foh')

Transfer function:

0.0115 z^3 + 0.0456 z^2 – 0.0562 z – 0.009104

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

z^6 – 1.629 z^5 + 0.6703 z^4

Sampling time: 0.1

T

d

0.35 =

T

s

0.1 =

c2d

11-26

The next command compar es t he cont inuous and discr et ized st ep r esponses.

step(H,'-',Hd,'--')

See Also d2c Discr et e t o cont inuous conver sion

d2d Resampling of discr et e syst ems

References [1] Fr anklin, G.F., J .D. Powell, and M.L. Wor kman, Digital Control of Dynamic

S ystems, Second Edit ion, Addison-Wesley, 1990.

canon

11-27

11canon

Purpose Comput e canonical st at e-space r ealizat ions

Syntax csys = canon(sys,'type')

[csys,T] = canon(sys,'type')

Description canon comput es a canonical st at e-space model for t he cont inuous or discr et e

LTI syst em sys. Two t ypes of canonical for ms ar e suppor t ed.

Modal Form

csys = canon(sys,'modal') r et ur ns a r ealizat ion csys in modal for m, t hat is,

wher e t he r eal eigenvalues appear on t he diagonal of t he mat r ix and t he

complex conjugat e eigenvalues appear in 2-by-2 blocks on t he diagonal of .

For a syst em wit h eigenvalues , t he modal mat r ix is of t he

for m

Companion Form

csys = canon(sys,'companion') pr oduces a companion r ealizat ion of sys

wher e t he char act er ist ic polynomial of t he syst em appear s explicit ly in t he

r ight most column of t he mat r ix. For a syst em wit h char act er ist ic polynomial

t he cor r esponding companion mat r ix is

A

A

λ

1

σ j ω λ

2

, t , ( ) A

λ

1

0 0 0

0 σ ω 0

0 ω – σ 0

0 0 0 λ

2

A

p s ( ) s

n

a

1

s

n 1 –

... a

n 1 –

s a

n

+ + + + =

A

A

0 0 .. .. 0 a

n

–

1 0 0 .. 0 a

n 1 –

–

0 1 0 . : :

: 0 . . : :

0 . . 1 0 a

2

–

0 .. .. 0 1 a

1

–

=

canon

11-28

For st at e-space models sys,

[csys,T] = canon(a,b,c,d,'type')

also r et ur ns t he st at e coor dinat e t r ansfor mat ion T r elat ing t he or iginal st at e

vect or and t he canonical st at e vect or .

This synt ax r et ur ns T=[] when sys is not a st at e-space model.

Algorithm Tr ansfer funct ions or zer o-pole-gain models ar e fir st conver t ed t o st at e space

using ss.

The t r ansfor mat ion t o modal for m uses t he mat r ix of eigenvect or s of t he

mat r ix. The modal for m is t hen obt ained as

The st at e t r ansfor mat ion r et ur ned is t he inver se of .

The r educt ion t o companion for m uses a st at e similar it y t r ansfor mat ion based

on t he cont r ollabilit y mat r ix [1].

Limitations The modal t r ansfor mat ion r equir es t hat t he mat r ix be diagonalizable. A

sufficient condit ion for diagonalizabilit y is t hat has no r epeat ed eigenvalues.

The companion t r ansfor mat ion r equir es t hat t he syst em be cont r ollable fr om

t he fir st input . The companion for m is oft en poor ly condit ioned for most

st at e-space comput at ions; avoid using it when possible.

See Also ctrb Cont r ollabilit y mat r ix

ctrbf Cont r ollabilit y canonical for m

ss2ss St at e similar it y t r ansfor mat ion

References [1] Kailat h, T. Linear S ystems, Pr ent ice-Hall, 1980.

x x

c

x

c

T x =

P A

x

c

·

P

1 –

APx

c

P

1 –

B u + =

y CPx

c

Du + =

T P

A

A

care

11-29

11car e

Purpose Solve cont inuous-t ime algebr aic Riccat i equat ions (CARE)

Syntax [X,L,G,rr] = care(A,B,Q)

[X,L,G,rr] = care(A,B,Q,R,S,E)

[X,L,G,report] = care(A,B,Q,...,'report')

[X1,X2,L,report] = care(A,B,Q,...,'implicit')

Description [X,L,G,rr] = care(A,B,Q) comput es t he unique solut ion of t he algebr aic

Riccat i equat ion

such t hat has all it s eigenvalues in t he open left -half plane. The

mat r ix is symmet r ic and called t he stabilizing solut ion of .

[X,L,G,rr] = care(A,B,Q) also r et ur ns:

•The eigenvalues L of

•The gain mat r ix

•The r elat ive r esidual rr defined by

[X,L,G,rr] = care(A,B,Q,R,S,E) solves t he mor e gener al Riccat i equat ion

Her e t he gain mat r ix is and t he “closed-loop”

eigenvalues ar e L = eig(A–B*G,E).

Two addit ional synt axes ar e pr ovided t o help develop applicat ions such as

-opt imal cont r ol design.

[X,L,G,report] = care(A,B,Q,...,'report')t ur ns off t he er r or messages

when t he solut ion fails t o exist and r et ur ns a failur e r epor t inst ead.

The value of report is:

•–1 when t he associat ed Hamilt onian pencil has eigenvalues on or ver y near

t he imaginar y axis (failur e)

•–2 when t her e is no finit e solut ion, i.e., wit h singular

(failur e)

•The r elat ive r esidual defined above when t he solut ion exist s (success)

X

R i c X ( ) A

T

X XA XBB

T

X – Q + + 0 = =

A BB

T

X –

X R i c X ( ) 0 =

A BB

T

X –

G B

T

X =

r r

R i c X ( )

F

X

F

--------------------------- =

R i c X ( ) A

T

XE E

T

XA E

T

XB S + ( )R

1 –

B

T

XE S

T

+ ( ) – Q + + 0 = =

G R

1 –

B

T

XE S

T

+ ( ) =

H

∞

X

X X

2

X

1

1 –

= X

1

r r

care

11-30

Alt er nat ively, [X1,X2,L,report] = care(A,B,Q,...,'implicit') also t ur ns

off er r or messages but now r et ur ns in implicit for m.

Not e t hat t his synt ax r et ur ns report = 0 when successful.

Examples Example 1

Given

you can solve t he Riccat i equat ion

by

a = [–3 2;1 1]

b = [0 ; 1]

c = [1 –1]

r = 3

[x,l,g] = care(a,b,c'*c,r)

This yields t he solut ion

x

x =

0.5895 1.8216

1.8216 8.8188

You can ver ify t hat t his solut ion is indeed st abilizing by compar ing t he

eigenvalues of a and a–b*g.

[eig(a) eig(a–b*g)]

ans =

–3.4495 –3.5026

1.4495 –1.4370

X

X X

2

X

1

1 –

=

A

3 – 2

1 1

= B

0

1

= C

1 1 –

= R 3 =

A

T

X XA XBR

1 –

B

T

X – C

T

C + + 0 =

care

11-31

Finally, not e t hat t he var iable l cont ains t he closed-loop eigenvalues eig(a–

b*g).

l

l =

–3.5026

–1.4370

Example 2

To solve t he -like Riccat i equat ion

r ewr it e it in t he care for mat as

You can now comput e t he st abilizing solut ion by

B = [B1 , B2]

m1 = size(B1,2)

m2 = size(B2,2)

R = [–g^2*eye(m1) zeros(m1,m2) ; zeros(m2,m1) eye(m2)]

X = care(A,B,C'*C,R)

Algorithm care implement s t he algor it hms descr ibed in [1]. It wor ks wit h t he

Hamilt onian mat r ix when is well-condit ioned and ; ot her wise it uses

t he ext ended Hamilt onian pencil and QZ algor it hm.

Limitations The pair must be st abilizable (t hat is, all unst able modes ar e

cont r ollable). In addit ion, t he associat ed Hamilt onian mat r ix or pencil must

have no eigenvalue on t he imaginar y axis. Sufficient condit ions for t his t o hold

ar e det ect able when and , or

H

∞

A

T

X XA X γ

2 –

B

1

B

1

T

B

2

B

2

T

– ( )X + + C

T

C + 0 =

A

T

X XA X B

1

B

2

, [ ]

γ

2 –

I – 0

0 I

1 –

B

1

T

B

2

T

X – C

T

C + + 0 =

B

R

¹ ¹ ' ¹ ¹

¹ ¹ ' ¹ ¹

X

R E I =

A B , ( )

Q A , ( ) S 0 = R 0 >

care

11-32

See Also dare Solve discr et e-t ime Riccat i equat ions

lyap Solve cont inuous-t ime Lyapunov equat ions

References [1] Ar nold, W.F., III and A.J . Laub, “Gener alized Eigenpr oblem Algor it hms

and Soft war e for Algebr aic Riccat i Equat ions,” Proc. IEEE, 72 (1984),

pp. 1746–1754.

Q S

S

T

R

0 >

chgunits

11-33

11chgunit s

Purpose Conver t t he fr equency unit s of an FRD model

Syntax sys = chgunits(sys,units)

Description sys = chgunits(sys,units) conver t s t he unit s of t he fr equency point s st or ed

in an FRD model, sys t o units, wher e units is eit her of t he st r ings 'Hz' or

'rad/s'. This oper at ion changes t he assigned fr equencies by applying t he

appr opr iat e (2*pi) scaling fact or , and t he 'Units' pr oper t y is updat ed.

If t he 'Units' field alr eady mat ches units, no conver sion is made.

Example w = logspace(1,2,2);

sys = rss(3,1,1);

sys = frd(sys,w)

From input 'input 1' to:

Frequency(rad/s) output 1

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

10 0.293773+0.001033i

100 0.294404+0.000109i

Continuous-time frequency response data.

sys = chgunits(sys,'Hz')

sys.freq

ans =

1.5915

15.9155

See Also frd Cr eat e or conver t t o an FRD model

get Get t he pr oper t ies of an LTI model

set Set t he pr oper t ies of an LTI model

connect

11-34

11connect

Purpose Der ive st at e-space model fr om block diagr am descr ipt ion

Syntax sysc = connect(sys,Q,inputs,outputs)

Description Complex dynamical syst ems ar e oft en given in block diagr am for m. For

syst ems of even moder at e complexit y, it can be quit e difficult t o find t he

st at e-space model r equir ed in or der t o br ing cer t ain analysis and design t ools

int o use. St ar t ing wit h a block diagr am descr ipt ion, you can use append and

connect t o const r uct a st at e-space model of t he syst em.

Fir st , use

sys = append(sys1,sys2,...,sysN)

t o specify each block sysj in t he diagr am and for m a block-diagonal,

unconnected LTI model sys of t he diagr am.

Next , use

sysc = connect(sys,Q,inputs,outputs)

t o connect t he blocks t oget her and der ive a st at e-space model sysc for t he

over all int er connect ion. The ar gument s Q, inputs, and outputs have t he

following pur pose:

• The mat r ix Q indicat es how t he blocks on t he diagr am ar e connect ed. It has

a r ow for each input of sys, wher e t he fir st element of each r ow is t he input

number . The subsequent element s of each r ow specify wher e t he block input

get s it s summing input s; negat ive element s indicat e minus input s t o t he

summing junct ion. For example, if input 7 get s it s input s fr om t he out put s 2,

15, and 6, wher e t he input fr om out put 15 is negat ive, t he cor r esponding r ow

of Q is [7 2 –15 6]. Shor t r ows can be padded wit h t r ailing zer os (see

example below).

• Given sys and Q, connect comput es a st at e-space model of t he

int er connect ion wit h t he same input s and out put s as sys (t hat is, t he

concat enat ion of all block input s and out put s). The index vect or s inputs and

outputs t hen indicat e which of t he input s and out put s in t he lar ge

unconnect ed syst em ar e ext er nal input s and out put s of t he block diagr am.

For example, if t he ext er nal input s ar e input s 1, 2, and 15 of sys, and t he

connect

11-35

ext er nal out put s ar e out put s 2 and 7 of sys, t hen inputs and outputs should

be set t o

inputs = [1 2 15];

outputs = [2 7];

The final model sysc has t hese par t icular input s and out put s.

Since it is easy t o make a mist ake ent er ing all t he dat a r equir ed for a lar ge

model, be sur e t o ver ify your model in as many ways as you can. Her e ar e some

suggest ions:

•Make sur e t he poles of t he unconnect ed model sys mat ch t he poles of t he

var ious blocks in t he diagr am.

•Check t hat t he final poles and DC gains ar e r easonable.

•Plot t he step and bode r esponses of sysc and compar e t hem wit h your

expect at ions.

If you need t o wor k ext ensively wit h block diagr ams, Simulink is a much easier

and mor e compr ehensive t ool for model building.

Example Consider t he following block diagr am

x

·

Ax Bu + =

y Cx Du + =

2 s 1 + ( )

s 2 +

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

10

s 5 +

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

y

1

y

2

u

2

u

1

u

c

sys1

sys2

sys3

+

–

connect

11-36

Given t he mat r ices of t he st at e-space model sys2

A = [ –9.0201 17.7791

–1.6943 3.2138 ];

B = [ –.5112 .5362

–.002 –1.8470];

C = [ –3.2897 2.4544

–13.5009 18.0745];

D = [–.5476 –.1410

–.6459 .2958 ];

Define t he t hr ee blocks as individual LTI models.

sys1 = tf(10,[1 5],'inputname','uc')

sys2 = ss(A,B,C,D,'inputname',{'u1' 'u2'},...

'outputname',{'y1' 'y2'})

sys3 = zpk(–1,–2,2)

Next append t hese blocks t o for m t he unconnect ed model sys.

sys = append(sys1,sys2,sys3)

This pr oduces t he block-diagonal model

sys

a =

x1 x2 x3 x4

x1 -5 0 0 0

x2 0 -9.0201 17.779 0

x3 0 -1.6943 3.2138 0

x4 0 0 0 -2

b =

uc u1 u2 ?

x1 4 0 0 0

x2 0 -0.5112 0.5362 0

x3 0 -0.002 -1.847 0

x4 0 0 0 1.4142

connect

11-37

c =

x1 x2 x3 x4

? 2.5 0 0 0

y1 0 -3.2897 2.4544 0

y2 0 -13.501 18.075 0

? 0 0 0 -1.4142

d =

uc u1 u2 ?

? 0 0 0 0

y1 0 -0.5476 -0.141 0

y2 0 -0.6459 0.2958 0

? 0 0 0 2

Continuous-time system.

Not e t hat t he or der ing of t he input s and out put s is t he same as t he block

or der ing you chose. Unnamed input s or out put s ar e denot ed by ?.

To der ive t he over all block diagr am model fr om sys, specify t he

int er connect ions and t he ext er nal input s and out put s. You need t o connect

out put s 1 and 4 int o input 3 (u2), and out put 3 (y2) int o input 4. The

int er connect ion mat r ix Q is t her efor e

Q = [3 1 –4

4 3 0];

Not e t hat t he second r ow of Q has been padded wit h a t r ailing zer o. The block

diagr am has t wo ext er nal input s uc and u1 (input s 1 and 2 of sys), and t wo

ext er nal out put s y1 and y2 (out put s 2 and 3 of sys). Accor dingly, set inputs

and outputs as follows.

inputs = [1 2];

outputs = [2 3];

connect

11-38

You can obt ain a st at e-space model for t he over all int er connect ion by t yping

sysc = connect(sys,Q,inputs,outputs)

a =

x1 x2 x3 x4

x1 -5 0 0 0

x2 0.84223 0.076636 5.6007 0.47644

x3 -2.9012 -33.029 45.164 -1.6411

x4 0.65708 -11.996 16.06 -1.6283

b =

uc u1

x1 4 0

x2 0 -0.076001

x3 0 -1.5011

x4 0 -0.57391

c =

x1 x2 x3 x4

y1 -0.22148 -5.6818 5.6568 -0.12529

y2 0.46463 -8.4826 11.356 0.26283

d =

uc u1

y1 0 -0.66204

y2 0 -0.40582

Continuous-time system.

Not e t hat t he input s and out put s ar e as desir ed.

See Also append Append LTI syst ems

feedback Feedback connect ion

minreal Minimal st at e-space r ealizat ion

parallel Par allel connect ion

series Ser ies connect ion

connect

11-39

References [1] Edwar ds, J .W., “A For t r an Pr ogr am for t he Analysis of Linear Cont inuous

and Sampled-Dat a Syst ems,” NAS A Report TM X56038, Dr yden Resear ch

Cent er , 1976.

covar

11-40

11covar

Purpose Out put and st at e covar iance of a syst em dr iven by whit e noise

Syntax [P,Q] = covar(sys,W)

Description covar calculat es t he st at ionar y covar iance of t he out put of an LTI model sys

dr iven by Gaussian whit e noise input s . This funct ion handles bot h

cont inuous- and discr et e-t ime cases.

P = covar(sys,W) r et ur ns t he st eady-st at e out put r esponse covar iance

given t he noise int ensit y

[P,Q] = covar(sys,W) also r et ur ns t he st eady-st at e st at e covar iance

when sys is a st at e-space model (ot her wise Q is set t o []).

When applied t o an N-dimensional LTI ar r ay sys, covar r et ur ns

mult i-dimensional ar r ays P, Q such t hat

P(:,:,i1,...iN) and Q(:,:,i1,...iN) ar e t he covar iance mat r ices for t he

model sys(:,:,i1,...iN).

Example Comput e t he out put r esponse covar iance of t he discr et e SISO syst em

due t o Gaussian whit e noise of int ensit y W = 5. Type

sys = tf([2 1],[1 0.2 0.5],0.1);

p = covar(sys,5)

y

w

P E yy

T

( ) =

E w t ( )w τ ( )

T

( ) W δ t τ – ( ) = (cont inuous t ime)

E w k [ ]w l [ ]

T

( ) W δ

k l

= (discr et e t ime)

Q E xx

T

( ) =

H z ( )

2z 1 +

z

2

0.2z 0.5 + +

-------------------------------------- , = T

s

0.1 =

covar

11-41

and MATLAB r et ur ns

p =

30.3167

You can compar e t his out put of covar t o simulat ion r esult s.

randn('seed',0)

w = sqrt(5)∗randn(1,1000); % 1000 samples

% Simulate response to w with LSIM:

y = lsim(sys,w);

% Compute covariance of y values

psim = sum(y .∗ y)/length(w);

This yields

psim =

32.6269

The t wo covar iance values p and psim do not agr ee per fect ly due t o t he finit e

simulat ion hor izon.

Algorithm Tr ansfer funct ions and zer o-pole-gain models ar e fir st conver t ed t o st at e space

wit h ss.

For cont inuous-t ime st at e-space models

is obt ained by solving t he Lyapunov equat ion

The out put r esponse covar iance is finit e only when and t hen

.

In discr et e t ime, t he st at e covar iance solves t he discr et e Lyapunov equat ion

x

·

Ax Bw + =

y Cx Dw + =

Q

AQ QA

T

BWB

T

+ + 0 =

P D 0 =

P CQC

T

=

AQA

T

Q – BWB

T

+ 0 =

covar

11-42

and is given by

Not e t hat is well defined for nonzer o in t he discr et e case.

Limitations The st at e and out put covar iances ar e defined for stable syst ems only. For

cont inuous syst ems, t he out put r esponse covar iance is finit e only when t he

mat r ix is zer o (st r ict ly pr oper syst em).

See Also dlyap Solver for discr et e-t ime Lyapunov equat ions

lyap Solver for cont inuous-t ime Lyapunov equat ions

References [1] Br yson, A.E. and Y.C. Ho, Applied Optimal Control, Hemispher e

Publishing, 1975, pp. 458-459.

P P CQC

T

DWD

T

+ =

P D

P

D

ctrb

11-43

11ct r b

Purpose For m t he cont r ollabilit y mat r ix

Syntax Co = ctrb(A,B)

Co = ctrb(sys)

Description ctrb comput es t he cont r ollabilit y mat r ix for st at e-space syst ems. For an

n-by-n mat r ix A and an n-by-m mat r ix B, ctrb(A,B) r et ur ns t he cont r ollabilit y

mat r ix

(11-1)

wher e has n r ows and nm columns.

Co = ctrb(sys) calculat es t he cont r ollabilit y mat r ix of t he st at e-space LTI

object sys. This synt ax is equivalent t o execut ing

Co = ctrb(sys.A,sys.B)

The syst em is cont r ollable if Co has full r ank n.

Example Check if t he syst em wit h t he following dat a

A =

1 1

4 –2

B =

1 –1

1 –1

is cont r ollable. Type

Co=ctrb(A,B);

% Number of uncontrollable states

unco=length(A)–rank(Co)

and MATLAB r et ur ns

unco =

1

Co B AB A

2

B … A

n 1 –

B =

Co

ctrb

11-44

Limitations The calculat ion of Co may be ill-condit ioned wit h r espect t o inver sion. An

indicat ion of t his can be seen fr om t his simple example.

This pair is cont r ollable if but if , wher e eps is t he r elat ive

machine pr ecision. ctrb(A,B) r et ur ns

which is not full r ank. For cases like t hese, it is bet t er t o det er mine t he

cont r ollabilit y of a syst em using ctrbf.

See Also ctrbf Comput e t he cont r ollabilit y st air case for m

obsv Comput e t he obser vabilit y mat r ix

A

1 δ

0 1

, = B

1

δ

=

δ 0 ≠ δ eps <

B AB

1 1

δ δ

=

ctrbf

11-45

11ct r bf

Purpose Comput e t he cont r ollabilit y st air case for m

Syntax [Abar,Bbar,Cbar,T,k] = ctrbf(A,B,C)

[Abar,Bbar,Cbar,T,k] = ctrbf(A,B,C,tol)

Description If t he cont r ollabilit y mat r ix of has r ank , wher e n is t he size of

, t hen t her e exist s a similar it y t r ansfor mat ion such t hat

wher e is unit ar y, and t he t r ansfor med syst em has a staircase for m, in which

t he uncont r ollable modes, if t her e ar e any, ar e in t he upper left cor ner .

wher e is cont r ollable, all eigenvalues of ar e uncont r ollable, and

[Abar,Bbar,Cbar,T,k] = ctrbf(A,B,C) decomposes t he st at e-space syst em

r epr esent ed by A, B, and C int o t he cont r ollabilit y st air case for m, Abar, Bbar,

and Cbar, descr ibed above. T is t he similar it y t r ansfor mat ion mat r ix and k is a

vect or of lengt h n, wher e n is t he or der of t he syst em r epr esent ed by A. Each

ent r y of k r epr esent s t he number of cont r ollable st at es fact or ed out dur ing each

st ep of t he t r ansfor mat ion mat r ix calculat ion. The number of nonzer o element s

in k indicat es how many it er at ions wer e necessar y t o calculat e T, and sum(k) is

t he number of st at es in , t he cont r ollable por t ion of Abar.

ctrbf(A,B,C,tol) uses t he t oler ance tol when calculat ing t he cont r ollable/

uncont r ollable subspaces. When t he t oler ance is not specified, it default s t o

10*n*norm(A,1)*eps.

A B , ( ) r n ≤

A

A T AT

T

, = B T B , = C CT

T

=

T

A

A

u c

0

A

21

A

c

, =

B

0

B

c

, = C C

n c

C

c

=

A

c

B

c

, ( ) A

u c

C

c

s I A

c

– ( )

1 –

B

c

C s I A – ( )

1 –

B. =

A

c

ctrbf

11-46

Example Comput e t he cont r ollabilit y st air case for m for

A =

1 1

4 –2

B =

1 –1

1 –1

C =

1 0

0 1

and locat e t he uncont r ollable mode.

[Abar,Bbar,Cbar,T,k]=ctrbf(A,B,C)

Abar =

–3.0000 0

–3.0000 2.0000

Bbar =

0.0000 0.0000

1.4142 –1.4142

Cbar =

–0.7071 0.7071

0.7071 0.7071

T =

–0.7071 0.7071

0.7071 0.7071

k =

1 0

The decomposed syst em Abar shows an uncont r ollable mode locat ed at –3 and

a cont r ollable mode locat ed at 2.

See also t he funct ion minreal, which uses ctrbf t o find t he minimal r ealizat ion

of a syst em.

ctrbf

11-47

Algorithm ctrbf is an M-file t hat implement s t he St air case Algor it hm of [1].

See Also ctrb For m t he cont r ollabilit y mat r ix

minreal Minimum r ealizat ion and pole-zer o cancellat ion

References [1] Rosenbr ock, M.M., S tate-S pace and Multivariable Theory, J ohn Wiley,

1970.

d2c

11-48

11d2c

Purpose Conver t discr et e-t ime LTI models t o cont inuous t ime

Syntax sysc = d2c(sysd)

sysc = d2c(sysd,method)

Description d2c conver t s LTI models fr om discr et e t o cont inuous t ime using one of t he

following conver sion met hods:

The st r ing method specifies t he conver sion met hod. If method is omit t ed t hen

zer o-or der hold ('zoh') is assumed. See “Cont inuous/Discr et e Conver sions of

LTI Models” in Chapt er 3 of t his manual and r efer ence [1] for mor e det ails on

t he conver sion met hods.

Example Consider t he discr et e-t ime model wit h t r ansfer funct ion

and sample t ime second. You can der ive a cont inuous-t ime

zer o-or der -hold equivalent model by t yping

Hc = d2c(H)

Discr et izing t he r esult ing model Hc wit h t he zer o-or der hold met hod (t his is t he

default met hod) and sampling per iod gives back t he or iginal discr et e

model . To see t his, t ype

c2d(Hc,0.1)

To use t he Tust in appr oximat ion inst ead of zer o-or der hold, t ype

Hc = d2c(H,'tustin')

'zoh' Zer o-or der hold on t he input s. The cont r ol input s ar e

assumed piecewise const ant over t he sampling per iod.

'tustin' Bilinear (Tust in) appr oximat ion t o t he der ivat ive.

'prewarp' Tust in appr oximat ion wit h fr equency pr ewar ping.

'matched' Mat ched pole-zer o met hod of [1] (for SISO syst ems only).

H z ( )

z 1 –

z

2

z 0.3 + +

----------------------------- =

T

s

0.1 =

T

s

0.1 =

H z ( )

d2c

11-49

As wit h zer o-or der hold, t he inver se discr et izat ion oper at ion

c2d(Hc,0.1,'tustin')

gives back t he or iginal .

Algorithm The 'zoh' conver sion is per for med in st at e space and r elies on t he mat r ix

logar it hm (see logm in Using MATLAB).

Limitations The Tust in appr oximat ion is not defined for syst ems wit h poles at and

is ill-condit ioned for syst ems wit h poles near .

The zer o-or der hold met hod cannot handle syst ems wit h poles at . In

addit ion, t he 'zoh' conver sion incr eases t he model or der for syst ems wit h

negat ive r eal poles, [2]. This is necessar y because t he mat r ix logar it hm maps

r eal negat ive poles t o complex poles. As a r esult , a discr et e model wit h a single

pole at would be t r ansfor med t o a cont inuous model wit h a single

complex pole at . Such a model is not meaningful

because of it s complex t ime r esponse.

To ensur e t hat all complex poles of t he cont inuous model come in conjugat e

pair s, d2c r eplaces negat ive r eal poles wit h a pair of complex conjugat e

poles near . The conver sion t hen yields a cont inuous model wit h higher

or der . For example, t he discr et e model wit h t r ansfer funct ion

and sample t ime 0.1 second is conver t ed by t yping

Ts = 0.1

H = zpk(–0.2,–0.5,1,Ts) * tf(1,[1 1 0.4],Ts)

Hc = d2c(H)

MATLAB r esponds wit h

Warning: System order was increased to handle real negative poles.

Zero/pole/gain:

–33.6556 (s–6.273) (s^2 + 28.29s + 1041)

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

(s^2 + 9.163s + 637.3) (s^2 + 13.86s + 1035)

H z ( )

z 1 – =

z 1 – =

z 0 =

z 0.5 – =

0.5 – ( ) log 0.6931 – j π + ≈

z α – =

α –

H z ( )

z 0.2 +

z 0.5 + ( ) z

2

z 0.4 + + ( )

--------------------------------------------------------- =

d2c

11-50

Conver t Hc back t o discr et e t ime by t yping

c2d(Hc,Ts)

yielding

Zero/pole/gain:

(z+0.5) (z+0.2)

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

(z+0.5)^2 (z^2 + z + 0.4)

Sampling time: 0.1

This discr et e model coincides wit h aft er canceling t he pole/zer o pair at

.

See Also c2d Cont inuous- t o discr et e-t ime conver sion

d2d Resampling of discr et e models

logm Mat r ix logar it hm

References [1] Fr anklin, G.F., J .D. Powell, and M.L. Wor kman, Digital Control of Dynamic

S ystems, Second Edit ion, Addison-Wesley, 1990.

[2] Kollár , I., G.F. Fr anklin, and R. Pint elon, “On t he Equivalence of z-domain

and s-domain Models in Syst em Ident ificat ion,” Proceedings of the IEEE

Instrumentation and Measurement Technology Conference, Br ussels, Belgium,

J une, 1996, Vol. 1, pp. 14-19.

H z ( )

z 0.5 – =

d2d

11-51

11d2d

Purpose Resample discr et e-t ime LTI models or add input delays

Syntax sys1 = d2d(sys,Ts)

Description sys1 = d2d(sys,Ts) r esamples t he discr et e-t ime LTI model sys t o pr oduce an

equivalent discr et e-t ime model sys1 wit h t he new sample t ime Ts (in seconds).

The r esampling assumes zer o-or der hold on t he input s and is equivalent t o

consecut ive d2c and c2d conver sions.

sys1 = c2d(d2c(sys),Ts)

Example Consider t he zer o-pole-gain model

wit h sample t ime 0.1 second. You can r esample t his model at 0.05 second by

t yping

H = zpk(0.7,0.5,1,0.1)

H2 = d2d(H,0.05)

Zero/pole/gain:

(z–0.8243)

----------

(z–0.7071)

Sampling time: 0.05

Not e t hat t he inver se r esampling oper at ion, per for med by t yping d2d(H2,0.1),

yields back t he init ial model .

Zero/pole/gain:

(z–0.7)

-------

(z–0.5)

Sampling time: 0.1

See Also c2d Cont inuous- t o discr et e-t ime conver sion

d2c Discr et e- t o cont inuous-t ime conver sion

H z ( )

z 0.7 –

z 0.5 –

----------------- =

H z ( )

damp

11-52

11damp

Purpose Comput e damping fact or s and nat ur al fr equencies

Syntax [Wn,Z] = damp(sys)

[Wn,Z,P] = damp(sys)

Description damp calculat es t he damping fact or and nat ur al fr equencies of t he poles of an

LTI model sys. When invoked wit hout left hand ar gument s, a t able of t he

eigenvalues in incr easing fr equency, along wit h t heir damping fact or s and

nat ur al fr equencies, is displayed on t he scr een.

[Wn,Z] = damp(sys) r et ur ns column vect or s Wn and Z cont aining t he nat ur al

fr equencies and damping fact or s of t he poles of sys. For discr et e-t ime

syst ems wit h poles and sample t ime , damp comput es “equivalent ”

cont inuous-t ime poles by solving

The values Wn and Z ar e t hen r elat ive t o t he cont inuous-t ime poles . Bot h Wn

and Z ar e empt y if t he sample t ime is unspecified.

[Wn,Z,P] = damp(sys) r et ur ns an addit ional vect or P cont aining t he (t r ue)

poles of sys. Not e t hat P r et ur ns t he same values as pole(sys) (up t o

r eor der ing).

Example Comput e and display t he eigenvalues, nat ur al fr equencies, and damping

fact or s of t he cont inuous t r ansfer funct ion

Type

H = tf([2 5 1],[1 2 3])

Transfer function:

2 s^2 + 5 s + 1

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

s^2 + 2 s + 3

ω

n

ζ

z T

s

s

z e

s T

s

=

s

H s ( )

2s

2

5s 1 + +

s

2

2s 3 + +

------------------------------- =

damp

11-53

Type

damp(H)

and MATLAB r et ur ns

Eigenvalue Damping Freq. (rad/s)

–1.00e+000 + 1.41e+000i 5.77e–001 1.73e+000

–1.00e+000 – 1.41e+000i 5.77e–001 1.73e+000

See Also eig Calculat e eigenvalues and eigenvect or s

esort,dsort Sor t syst em poles

pole Comput e syst em poles

pzmap Pole-zer o map

zero Comput e (t r ansmission) zer os

dare

11-54

11dar e

Purpose Solve discr et e-t ime algebr aic Riccat i equat ions (DARE)

Syntax [X,L,G,rr] = dare(A,B,Q,R)

[X,L,G,rr] = dare(A,B,Q,R,S,E)

[X,L,G,report] = dare(A,B,Q,...,'report')

[X1,X2,L,report] = dare(A,B,Q,...,'implicit')

Description [X,L,G,rr] = dare(A,B,Q,R) comput es t he unique solut ion of t he

discr et e-t ime algebr aic Riccat i equat ion

such t hat t he “closed-loop” mat r ix

has all it s eigenvalues inside t he unit disk. The mat r ix is symmet r ic and

called t he stabilizing solut ion of . [X,L,G,rr] = dare(A,B,Q,R)

also r et ur ns:

• The eigenvalues L of

• The gain mat r ix

• The r elat ive r esidual rr defined by

[X,L,G,rr] = dare(A,B,Q,R,S,E) solves t he mor e gener al DARE:

The cor r esponding gain mat r ix and closed-loop eigenvalues ar e

X

R i c X ( ) A

T

XA X – A

T

XB B

T

XB R + ( )

1 –

B

T

XA – Q + 0 = =

A

cl

A B B

T

XB R + ( )

1 –

B

T

XA – =

X

R i c X ( ) 0 =

A

cl

G B

T

XB R + ( )

1 –

B

T

XA =

r r

R i c X ( )

F

X

F

--------------------------- =

A

T

XA E

T

XE – A

T

XB S + ( ) B

T

XB R + ( )

1 –

B

T

XA S

T

+ ( ) – Q + 0 =

G B

T

XB R + ( )

1 –

B

T

XA S

T

+ ( ) =

dare

11-55

and L = eig(A–B*G,E).

Two addit ional synt axes ar e pr ovided t o help develop applicat ions such as

-opt imal cont r ol design.

[X,L,G,report] = dare(A,B,Q,...,'report') t ur ns off t he er r or messages

when t he solut ion fails t o exist and r et ur ns a failur e r epor t inst ead. The

value of report is:

•–1 when t he associat ed symplect ic pencil has eigenvalues on or ver y near t he

unit cir cle (failur e)

•–2 when t her e is no finit e solut ion, t hat is, wit h singular

(failur e)

•The r elat ive r esidual defined above when t he solut ion exist s (success)

Alt er nat ively, [X1,X2,L,report] = dare(A,B,Q,...,'implicit') also t ur ns

off er r or messages but now r et ur ns in implicit for m as

Not e t hat t his synt ax r et ur ns report = 0 when successful.

Algorithm dare implement s t he algor it hms descr ibed in [1]. It uses t he QZ algor it hm t o

deflat e t he ext ended symplect ic pencil and comput e it s st able invar iant

subspace.

Limitations The pair must be st abilizable (t hat is, all eigenvalues of out side t he

unit disk must be cont r ollable). In addit ion, t he associat ed symplect ic pencil

must have no eigenvalue on t he unit cir cle. Sufficient condit ions for t his t o hold

ar e det ect able when and , or

See Also care Solve cont inuous-t ime Riccat i equat ions

dlyap Solve discr et e-t ime Lyapunov equat ions

H

∞

X

X X

2

X

1

1 –

= X

1

r r

X

X X

2

X

1

1 –

=

A B , ( ) A

Q A , ( ) S 0 = R 0 >

Q S

S

T

R

0 >

dare

11-56

References [1] Ar nold, W.F., III and A.J . Laub, “Gener alized Eigenpr oblem Algor it hms

and Soft war e for Algebr aic Riccat i Equat ions,” Proc. IEEE, 72 (1984), pp.

1746–1754.

dcgain

11-57

11dcgain

Purpose Comput e low fr equency (DC) gain of LTI syst em

Syntax k = dcgain(sys)

Description k = dcgain(sys) comput es t he DC gain k of t he LTI model sys.

Continuous Time

The cont inuous-t ime DC gain is t he t r ansfer funct ion value at t he fr equency

. For st at e-space models wit h mat r ices , t his value is

Discrete Time

The discr et e-t ime DC gain is t he t r ansfer funct ion value at . For

st at e-space models wit h mat r ices , t his value is

Remark The DC gain is infinit e for syst ems wit h int egr at or s.

Example To comput e t he DC gain of t he MIMO t r ansfer funct ion

t ype

H = [1 tf([1 –1],[1 1 3]) ; tf(1,[1 1]) tf([1 2],[1 –3])]

dcgain(H)

ans =

1.0000 –0.3333

1.0000 –0.6667

See Also evalfr Evaluat es fr equency r esponse at single fr equency

norm LTI syst em nor ms

s 0 = A B C D , , , ( )

K D CA

1 –

B – =

z 1 =

A B C D , , , ( )

K D C I A – ( )

1 –

B + =

H s ( )

1

s 1 –

s

2

s 3 + +

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

1

s 1 +

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

s 2 +

s 3 –

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

=

delay2z

11-58

11delay2z

Purpose Replace delays of discr et e-t ime TF, SS, or ZPK models by poles at z=0, or

r eplace delays of FRD models by a phase shift

Syntax sys = delay2z(sys)

Description sys = delay2z(sys) maps all t ime delays t o poles at z=0 for discr et e-t ime TF,

ZPK, or SS models sys. Specifically, a delay of k sampling per iods is r eplaced

by (1/z)^k in t he t r ansfer funct ion cor r esponding t o t he model.

For FRD models, delay2z absor bs all t ime delays int o t he fr equency r esponse

dat a, and is applicable t o bot h cont inuous- and discr et e-t ime FRDs.

Example z=tf('z',–1);

sys=(–.4*z –.1)/(z^2 + 1.05*z + .08)

Transfer function:

–0.4 z – 0.1

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

z^2 + 1.05 z + 0.08

Sampling time: unspecified

sys.Inputd = 1;

sys = delay2z(sys)

Transfer function:

-0.4 z - 0.1

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

z^3 + 1.05 z^2 + 0.08 z

Sampling time: unspecified

See Also hasdelay Tr ue for LTI models wit h delays

pade Pade appr oximat ion of t ime delays

totaldelay Combine delays for an LTI model

dlqr

11-59

11dlqr

Purpose Design linear -quadr at ic (LQ) st at e-feedback r egulat or for discr et e-t ime plant

Syntax [K,S,e] = dlqr(a,b,Q,R)

[K,S,e] = dlqr(a,b,Q,R,N)

Description [K,S,e] = dlqr(a,b,Q,R,N) calculat es t he opt imal gain mat r ix K such t hat

t he st at e-feedback law

minimizes t he quadr at ic cost funct ion

for t he discr et e-t ime st at e-space mode

l

The default value N=0 is assumed when N is omit t ed.

In addit ion t o t he st at e-feedback gain K, dlqr r et ur ns t he solut ion S of t he

associat ed discr et e-t ime Riccat i equat ion

and t he closed-loop eigenvalues e = eig(a-b*K). Not e t hat is der ived fr om

by

Limitations The pr oblem dat a must sat isfy:

•The pair is st abilizable.

• and .

• has no unobser vable mode on t he unit cir cle.

See Also dare Solve discr et e Riccat i equat ions

lqgreg LQG r egulat or

u n [ ] Kx n [ ] – =

J u ( ) x n [ ]

T

Qx n [ ] u n [ ]

T

R u n [ ] 2x n [ ]

T

N u n [ ] + + ( )

n 1 =

∞

∑

=

x n 1 + [ ] Ax n [ ] Bu n [ ] + =

A

T

S A S – A

T

S B N + ( ) B

T

XB R + ( )

1 –

B

T

S A N

T

+ ( ) – Q + 0 =

K

S

K B

T

XB R + ( )

1 –

B

T

S A N

T

+ ( ) =

A B , ( )

R 0 > Q N R

1 –

N

T

– 0 ≥

Q N R

1 –

N

T

– A BR

1 –

N

T

– , ( )

dlqr

11-60

lqr St at e-feedback LQ r egulat or for cont inuous plant

lqrd Discr et e LQ r egulat or for cont inuous plant

lqry St at e-feedback LQ r egulat or wit h out put weight ing

dlyap

11-61

11dlyap

Purpose Solve discr et e-t ime Lyapunov equat ions

Syntax X = dlyap(A,Q)

Description dlyap solves t he discr et e-t ime Lyapunov equat ion

wher e and ar e -by- mat r ices.

The solut ion is symmet r ic when is symmet r ic, and posit ive definit e when

is posit ive definit e and has all it s eigenvalues inside t he unit disk.

Diagnostics The discr et e-t ime Lyapunov equat ion has a (unique) solut ion if t he eigenvalues

of sat isfy for all .

If t his condit ion is violat ed, dlyap pr oduces t he er r or message

Solution does not exist or is not unique.

See Also covar Covar iance of syst em r esponse t o whit e noise

lyap Solve cont inuous Lyapunov equat ions

A

T

XA X – Q + 0 =

A Q n n

X Q

Q A

α

1

α

2

... α

n

, , , A α

i

α

j

1 ≠ i j , ( )

drmodel, drss

11-62

11dr model, dr ss

Purpose Gener at e st able r andom discr et e t est models

Syntax sys = drss(n)

sys = drss(n,p)

sys = drss(n,p,m)

sys = drss(n,p,m,s1,...sn)

[num,den] = drmodel(n)

[A,B,C,D] = drmodel(n)

[A,B,C,D] = drmodel(n,p,m)

Description sys = drss(n) pr oduces a r andom n-t h or der st able model wit h one input and

one out put , and r et ur ns t he model in t he st at e-space object sys.

drss(n,p) pr oduces a r andom n-t h or der st able model wit h one input and p

out put s.

drss(n,m,p) gener at es a r andom n-t h or der st able model wit h m input s and p

out put s.

drss(n,p,m,s1,...sn) gener at es a s1–by–sn ar r ay of r andom n-t h or der

st able model wit h m input s and p out put s.

In all cases, t he discr et e-t ime st at e-space model or ar r ay r et ur ned by drss has

an unspecified sampling t ime. To gener at e t r ansfer funct ion or zer o-pole-gain

syst ems, conver t sys using tf or zpk.

drmodel(n) pr oduces a r andom n-t h or der st able model and r et ur ns eit her t he

t r ansfer funct ion numer at or num and denominat or den or t he st at e-space

mat r ices A, B, C, and D, based on t he number of out put ar gument s. The r esult ing

model always has one input and one out put .

[A,B,C,D] = drmodel(n,m,p) pr oduces a r andom n-t h or der st able

st at e-space model wit h m input s and p out put s.

drmodel, drss

11-63

Example Gener at e a r andom discr et e LTI syst em wit h t hr ee st at es, t wo input s, and t wo

out put s.

sys = drss(3,2,2)

a =

x1 x2 x3

x1 0.38630 –0.21458 –0.09914

x2 –0.23390 –0.15220 –0.06572

x3 –0.03412 0.11394 –0.22618

b =

u1 u2

x1 0.98833 0.51551

x2 0 0.33395

x3 0.42350 0.43291

c =

x1 x2 x3

y1 0.22595 0.76037 0

y2 0 0 0

d =

u1 u2

y1 0 0.68085

y2 0.78333 0.46110

Sampling time: unspecified

Discrete-time system.

See Also rmodel, rss Gener at e st able r andom cont inuous t est models

tf Conver t LTI syst ems t o t r ansfer funct ions for m

zpk Conver t LTI syst ems t o zer o-pole-gain for m

dsort

11-64

11dsor t

Purpose Sor t discr et e-t ime poles by magnit ude

Syntax s = dsort(p)

[s,ndx] = dsort(p)

Description dsort sor t s t he discr et e-t ime poles cont ained in t he vect or p in descending

or der by magnit ude. Unst able poles appear fir st .

When called wit h one left hand ar gument , dsort r et ur ns t he sor t ed poles in s.

[s,ndx] = dsort(p) also r et ur ns t he vect or ndx cont aining t he indices used in

t he sor t .

Example Sor t t he following discr et e poles.

p =

–0.2410 + 0.5573i

–0.2410 – 0.5573i

0.1503

–0.0972

–0.2590

s = dsort(p)

s =

–0.2410 + 0.5573i

–0.2410 – 0.5573i

–0.2590

0.1503

–0.0972

Limitations The poles in t he vect or p must appear in complex conjugat e pair s.

See Also eig Calculat e eigenvalues and eigenvect or s

esort, sort Sor t syst em poles

pole Comput e syst em poles

pzmap Pole-zer o map

zero Comput e (t r ansmission) zer os

dss

11-65

11dss

Purpose Specify descr ipt or st at e-space models

Syntax sys = dss(a,b,c,d,e)

sys = dss(a,b,c,d,e,Ts)

sys = dss(a,b,c,d,e,ltisys)

sys = dss(a,b,c,d,e,'Property1',Value1,...,'PropertyN',ValueN)

sys = dss(a,b,c,d,e,Ts,'Property1',Value1,...,'PropertyN',ValueN)

Description sys = dss(a,b,c,d,e) cr eat es t he cont inuous-t ime descr ipt or st at e-space

model

The mat r ix must be nonsingular . The out put sys is an SS model st or ing t he

model dat a (see “LTI Object s” on page 2-3). Not e t hat ss pr oduces t he same

t ype of object . If t he mat r ix , do can simply set d t o t he scalar 0 (zer o).

sys = dss(a,b,c,d,e,Ts) cr eat es t he discr et e-t ime descr ipt or model

wit h sample t ime Ts (in seconds).

sys = dss(a,b,c,d,e,ltisys) cr eat es a descr ipt or model wit h gener ic LTI

pr oper t ies inher it ed fr om t he LTI model ltisys (including t he sample t ime).

See “LTI Pr oper t ies” on page 2-26 for an over view of gener ic LTI pr oper t ies.

Any of t he pr evious synt axes can be followed by pr oper t y name/pr oper t y value

pair s

'Property',Value

Each pair specifies a par t icular LTI pr oper t y of t he model, for example, t he

input names or some not es on t he model hist or y. See set and t he example

below for det ails.

Ex

·

Ax Bu + =

y Cx Du + =

E

D 0 =

Ex n 1 + [ ] Ax n [ ] B u n [ ] + =

y n [ ] Cx n [ ] Du n [ ] + =

dss

11-66

Example The command

sys = dss(1,2,3,4,5,'td',0.1,'inputname','voltage',...

'notes','Just an example')

cr eat es t he model

wit h a 0.1 second input delay. The input is labeled 'voltage', and a not e is

at t ached t o t ell you t hat t his is just an example.

See Also dssdata Ret r ieve mat r ices of descr ipt or model

get Get pr oper t ies of LTI models

set Set pr oper t ies of LTI models

ss Specify (r egular ) st at e-space models

5x

·

x 2u + =

y 3x 4u + =

A B C D E , , , ,

dssdata

11-67

11dssdat a

Purpose Quick access t o descr ipt or st at e-space dat a

Syntax [a,b,c,d,e] = dssdata(sys)

[a,b,c,d,e,Ts] = dssdata(sys)

Description [a,b,c,d,e] = dssdata(sys) ext r act s t he descr ipt or mat r ix dat a

fr om t he st at e-space model sys. If sys is a t r ansfer funct ion or

zer o-pole-gain model, it is fir st conver t ed t o st at e space. Not e t hat dssdata is

t hen equivalent t o ssdata because it always r et ur ns .

[a,b,c,d,e,Ts] = dssdata(sys) also r et ur ns t he sample t ime Ts in addit ion

t o a, b, c, d, and e.

You can access t he r emaining LTI pr oper t ies of sys wit h get or by dir ect

r efer encing, for example,

sys.notes

See Also dss Specify descr ipt or st at e-space models

get Get pr oper t ies of LTI models

ssdata Quick access t o st at e-space dat a

tfdata Quick access t o t r ansfer funct ion dat a

zpkdata Quick access t o zer o-pole-gain dat a

A B C D E , , , , ( )

E I =

esort

11-68

11esor t

Purpose Sor t cont inuous-t ime poles by r eal par t

Syntax s = esort(p)

[s,ndx] = esort(p)

Description esort sor t s t he cont inuous-t ime poles cont ained in t he vect or p by r eal par t .

Unst able eigenvalues appear fir st and t he r emaining poles ar e or der ed by

decr easing r eal par t s.

When called wit h one left -hand ar gument , s = esort(p) r et ur ns t he sor t ed

eigenvalues in s.

[s,ndx] = esort(p) r et ur ns t he addit ional ar gument ndx, a vect or cont aining

t he indices used in t he sor t .

Example Sor t t he following cont inuous eigenvalues.

p

p =

–0.2410+ 0.5573i

–0.2410– 0.5573i

0.1503

–0.0972

–0.2590

esort(p)

ans =

0.1503

–0.0972

–0.2410+ 0.5573i

–0.2410– 0.5573i

–0.2590

Limitations The eigenvalues in t he vect or p must appear in complex conjugat e pair s.

esort

11-69

See Also dsort, sort Sor t syst em poles

eig Calculat e eigenvalues and eigenvect or s

pole Comput e syst em poles

pzmap Pole-zer o map

zero Comput e (t r ansmission) zer os

estim

11-70

11est im

Purpose For m st at e est imat or given est imat or gain

Syntax est = estim(sys,L)

est = estim(sys,L,sensors,known)

Description est = estim(sys,L) pr oduces a st at e/out put est imat or est given t he plant

st at e-space model sys and t he est imat or gain L. All input s of sys ar e

assumed st ochast ic (pr ocess and/or measur ement noise), and all out put s ar e

measur ed. The est imat or est is r et ur ned in st at e-space for m (SS object ). For a

cont inuous-t ime plant sys wit h equat ions

estim gener at es plant out put and st at e est imat es and as given by t he

following model.

The discr et e-t ime est imat or has similar equat ions.

est = estim(sys,L,sensors,known) handles mor e gener al plant s sys wit h

bot h known input s and st ochast ic input s , and bot h measur ed out put s

and nonmeasur ed out put s .

The index vect or s sensors and known specify which out put s ar e measur ed

and which input s ar e known. The r esult ing est imat or est uses bot h and

t o pr oduce t he out put and st at e est imat es.

w

y

x

·

Ax Bw + =

y Cx Dw + =

yˆ xˆ

x

ˆ

·

Axˆ L y Cxˆ – ( ) + =

yˆ

xˆ

C

I

xˆ =

u w y

z

x

·

Ax B

1

w B

2

u + + =

z

y

C

1

C

2

x

D

11

D

21

w

D

12

D

22

u + + =

y

u u

y

estim

11-71

estim handles bot h cont inuous- and discr et e-t ime cases. You can use t he

funct ions place (pole placement ) or kalman (Kalman filt er ing) t o design an

adequat e est imat or gain . Not e t hat t he est imat or poles (eigenvalues of

) should be fast er t han t he plant dynamics (eigenvalues of ) t o ensur e

accur at e est imat ion.

Example Consider a st at e-space model sys wit h seven out put s and four input s. Suppose

you designed a Kalman gain mat r ix using out put s 4, 7, and 1 of t he plant as

sensor measur ement s, and input s 1,4, and 3 of t he plant as known

(det er minist ic) input s. You can t hen for m t he Kalman est imat or by

sensors = [4,7,1];

known = [1,4,3];

est = estim(sys,L,sensors,known)

See t he funct ion kalman for dir ect Kalman est imat or design.

See Also kalman Design Kalman est imat or

place Pole placement

reg For m r egulat or given st at e-feedback and est imat or

gains

x

ˆ

·

Axˆ B

2

u L y C

2

xˆ D

22

u – – ( ) + + =

yˆ

xˆ

C

2

I

xˆ

D

22

0

u + =

est

u (known)

y (sensor s)

yˆ

xˆ

L

A L C – A

L

evalfr

11-72

11evalfr

Purpose Evaluat e fr equency r esponse at a single (complex) fr equency

Syntax frsp = evalfr(sys,f)

Description frsp = evalfr(sys,f) evaluat es t he t r ansfer funct ion of t he TF, SS, or ZPK

model sys at t he complex number f. For st at e-space models wit h dat a

, t he r esult is

evalfr is a simplified ver sion of freqresp meant for quick evaluat ion of t he

r esponse at a single point . Use freqresp t o comput e t he fr equency r esponse

over a set of fr equencies.

Example To evaluat e t he discr et e-t ime t r ansfer funct ion

at , t ype

H = tf([1 –1],[1 1 1],–1)

z = 1+j

evalfr(H,z)

ans =

2.3077e–01 + 1.5385e–01i

Limitations The r esponse is not finit e when f is a pole of sys.

See Also bode Bode fr equency r esponse

freqresp Fr equency r esponse over a set of fr equencies

sigma Singular value r esponse

A B C D , , , ( )

H f ( ) D C f I A – ( )

1 –

B + =

H z ( )

z 1 –

z

2

z 1 + +

------------------------ =

z 1 j + =

feedback

11-73

11feedback

Purpose Feedback connect ion of t wo LTI models

Syntax sys = feedback(sys1,sys2)

sys = feedback(sys1,sys2,sign)

sys = feedback(sys1,sys2,feedin,feedout,sign)

Description sys = feedback(sys1,sys2) r et ur ns an LTI model sys for t he negat ive

feedback int er connect ion.

The closed-loop model sys has as input vect or and as out put vect or . The

LTI models sys1 and sys2 must be bot h cont inuous or bot h discr et e wit h

ident ical sample t imes. Pr ecedence r ules ar e used t o det er mine t he r esult ing

model t ype (see “Pr ecedence Rules” on page 2-5).

To apply posit ive feedback, use t he synt ax

sys = feedback(sys1,sys2,+1)

By default , feedback(sys1,sys2) assumes negat ive feedback and is

equivalent t o feedback(sys1,sys2,–1).

Finally,

sys = feedback(sys1,sys2,feedin,feedout)

sys1

sys2

–

+

u y

u y

feedback

11-74

comput es a closed-loop model sys for t he mor e gener al feedback loop.

The vect or feedin cont ains indices int o t he input vect or of sys1 and specifies

which input s ar e involved in t he feedback loop. Similar ly, feedout specifies

which out put s of sys1 ar e used for feedback. The r esult ing LTI model sys has

t he same input s and out put s as sys1 (wit h t heir or der pr eser ved). As befor e,

negat ive feedback is applied by default and you must use

sys = feedback(sys1,sys2,feedin,feedout,+1)

t o apply posit ive feedback.

For mor e complicat ed feedback st r uct ur es, use append and connect.

Remark You can specify st at ic gains as r egular mat r ices, for example,

sys = feedback(sys1,2)

However , at least one of t he t wo ar gument s sys1 and sys2 should be an LTI

object . For feedback loops involving t wo st at ic gains k1 and k2, use t he synt ax

sys = feedback(tf(k1),k2)

sys1

sys2

–

+

u y

v z

sys

u

y

feedback

11-75

Examples Example 1

To connect t he plant

wit h t he cont r oller

using negat ive feedback, t ype

G = tf([2 5 1],[1 2 3],'inputname','torque',...

'outputname','velocity');

H = zpk(–2,–10,5)

Cloop = feedback(G,H)

and MATLAB r et ur ns

Zero/pole/gain from input "torque" to output "velocity":

0.18182 (s+10) (s+2.281) (s+0.2192)

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

(s+3.419) (s^2 + 1.763s + 1.064)

The r esult is a zer o-pole-gain model as expect ed fr om t he pr ecedence r ules.

Not e t hat Cloop inher it ed t he input and out put names fr om G.

–

+

G

H

velocity torque

G s ( )

2s

2

5s 1 + +

s

2

2s 3 + +

------------------------------- =

H s ( )

5 s 2 + ( )

s 10 +

-------------------- =

feedback

11-76

Example 2

Consider a st at e-space plant P wit h five input s and four out put s and a

st at e-space feedback cont r oller K wit h t hr ee input s and t wo out put s. To connect

out put s 1, 3, and 4 of t he plant t o t he cont r oller input s, and t he cont r oller

out put s t o input s 4 and 2 of t he plant , use

feedin = [4 2];

feedout = [1 3 4];

Cloop = feedback(P,K,feedin,feedout)

Example 3

You can for m t he following negat ive-feedback loops

by

Cloop = feedback(G,1) % left diagram

Cloop = feedback(1,G) % right diagram

Limitations The feedback connect ion should be fr ee of algebr aic loop. If and ar e t he

feedt hr ough mat r ices of sys1 and sys2, t his condit ion is equivalent t o:

• nonsingular when using negat ive feedback

• nonsingular when using posit ive feedback.

See Also star St ar pr oduct of LTI syst ems (LFT connect ion)

series Ser ies connect ion

parallel Par allel connect ion

connect Der ive st at e-space model for block diagr am

int er connect ion

G

G

D

1

D

2

I D

1

D

2

+

I D

1

D

2

–

filt

11-77

11filt

Purpose Specify discr et e t r ansfer funct ions in DSP for mat

Syntax sys = filt(num,den)

sys = filt(num,den,Ts)

sys = filt(M)

sys = filt(num,den,'Property1',Value1,...,'PropertyN',ValueN)

sys = filt(num,den,Ts,'Property1',Value1,...,'PropertyN',ValueN)

Description In digit al signal pr ocessing (DSP), it is cust omar y t o wr it e t r ansfer funct ions

as r at ional expr essions in and t o or der t he numer at or and denominat or

t er ms in ascending power s of , for example,

The funct ion filt is pr ovided t o facilit at e t he specificat ion of t r ansfer funct ions

in DSP for mat .

sys = filt(num,den) cr eat es a discr et e-t ime t r ansfer funct ion sys wit h

numer at or (s) num and denominat or (s) den. The sample t ime is left unspecified

(sys.Ts = –1) and t he out put sys is a TF object .

sys = filt(num,den,Ts) fur t her specifies t he sample t ime Ts (in seconds).

sys = filt(M) specifies a st at ic filt er wit h gain mat r ix M.

Any of t he pr evious synt axes can be followed by pr oper t y name/pr oper t y value

pair s of t he for m

'Property',Value

Each pair specifies a par t icular LTI pr oper t y of t he model, for example, t he

input names or t he t r ansfer funct ion var iable. See “LTI Pr oper t ies” on page

2-26 and t he set ent r y for addit ional infor mat ion on LTI pr oper t ies and

admissible pr oper t y values.

Arguments For SISO t r ansfer funct ions, num and den ar e r ow vect or s cont aining t he

numer at or and denominat or coefficient s or der ed in ascending power s of .

For example, den = [1 0.4 2] r epr esent s t he polynomial .

z

1 –

z

1 –

H z

1 –

( )

2 z

1 –

+

1 0.4z

1 –

2z

2 –

+ +

-------------------------------------------- - =

z

1 –

1 0.4z

1 –

2z

2 –

+ +

filt

11-78

MIMO t r ansfer funct ions ar e r egar ded as ar r ays of SISO t r ansfer funct ions

(one per I/O channel), each of which is char act er ized by it s numer at or and

denominat or . The input ar gument s num and den ar e t hen cell ar r ays of r ow

vect or s such t hat :

•num and den have as many r ows as out put s and as many columns as input s.

• Their ent r ies num{i,j} and den{i,j} specify t he numer at or and

denominat or of t he t r ansfer funct ion fr om input j t o out put i.

If all SISO ent r ies have t he same denominat or , you can also set den t o t he r ow

vect or r epr esent at ion of t his common denominat or . See also “MIMO Tr ansfer

Funct ion Models” on page 2-10 for alt er nat ive ways t o specify MIMO t r ansfer

funct ions.

Remark filt behaves as tf wit h t he Variable pr oper t y set t o 'z^–1' or 'q'. See tf

ent r y below for det ails.

Example Typing t he commands

num = {1 , [1 0.3]}

den = {[1 1 2] ,[5 2]}

H = filt(num,den,'inputname',{'channel1' 'channel2'})

cr eat es t he t wo-input digit al filt er

wit h unspecified sample t ime and input names 'channel1' and 'channel2'.

See Also tf Cr eat e t r ansfer funct ions

zpk Cr eat e zer o-pole-gain models

ss Cr eat e st at e-space models

i j , ( )

H z

1 –

( )

1

1 z

1 –

2z

2 –

+ +

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

1 0.3z

1 –

+

5 2z

1 –

+

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

=

frd

11-79

11fr d

Purpose Cr eat e a fr equency r esponse dat a (FRD) object or conver t anot her model t ype

t o an FRD model

Syntax sys = frd(response,frequency)

sys = frd(response,frequency,Ts)

sys = frd

sys = frd(response,frequency,ltisys)

sysfrd = frd(sys,frequency)

sysfrd = frd(sys,frequency,'Units',units)

Description sys = frd(response,frequency) cr eat es an FRD model sys fr om t he

fr equency r esponse dat a st or ed in t he mult idimensional ar r ay response. The

vect or frequency r epr esent s t he under lying fr equencies for t he fr equency

r esponse dat a. See Table 11-14, “Dat a For mat for t he Ar gument r esponse in

FRD Models,” on page 80.

sys = frd(response,frequency,Ts) cr eat es a discr et e-t ime FRD model sys

wit h scalar sample t ime Ts. Set Ts = –1 t o cr eat e a discr et e-t ime FRD model

wit hout specifying t he sample t ime.

sys = frd cr eat es an empt y FRD model.

The input ar gument list for any of t hese synt axes can be followed by pr oper t y

name/pr oper t y value pair s of t he for m

'PropertyName',PropertyValue

You can use t hese ext r a ar gument s t o set t he var ious pr oper t ies of FRD models

(see t he set command, or “LTI Pr oper t ies” on page 2-26 and “Model-Specific

Pr oper t ies” on page 2-28). These pr oper t ies include 'Units'. The default unit s

for FRD models ar e in 'rad/s'.

To for ce an FRD model sys t o inher it all of it s gener ic LTI pr oper t ies fr om any

exist ing LTI model refsys, use t he synt ax sys =

frd(response,frequency,ltisys).

sysfrd = frd(sys,frequency) conver t s a TF, SS, or ZPK model t o an FRD

model. The fr equency r esponse is comput ed at t he fr equencies pr ovided by t he

vect or frequency.

frd

11-80

sysfrd = frd(sys,frequency,'Units',units)conver t s an FRD model fr om a

TF, SS, or ZPK model while specifying t he unit s for frequency t o be units

('rad/s' or 'Hz').

Arguments When you specify a SISO or MIMO FRD model, or an ar r ay of FRD models, t he

input ar gument frequency is always a vect or of lengt h Nf, wher e Nf is t he

number of fr equency dat a point s in t he FRD. The specificat ion of t he input

ar gument response is summar ized in t he following t able.

Remarks See “Fr equency Response Dat a (FRD) Models” on page 2-17 for mor e

infor mat ion on single FRD models, and “Building LTI Ar r ays Using t f, zpk, ss,

and fr d” on page 4-17 for infor mat ion on ar r ays of FRD models.

Example Type t he commands

freq = logspace(1,2);

resp = .05*(freq).*exp(i*2*freq);

sys = frd(resp,freq)

t o cr eat e a SISO FRD model.

See Also chgunits Change unit s for an FRD model

frdata Quick access t o dat a for an FRD model

set Set t he pr oper t ies for an LTI model

ss Cr eat e st at e-space models

Table 11-14: Data Format for the Argument response in FRD Models

Model Form Response Data Format

SISO model Vect or of lengt h Nf for which response(i) is t he

fr equency r esponse at t he fr equency frequency(i)

MIMO model

wit h Ny out put s

and Nu input s

Ny-by-Nu-by-Nf mult idimensional ar r ay for which

response(i,j,k) specifies t he fr equency r esponse

fr om input j t o out put i at fr equency frequency(k)

S1-by-...-by-Sn

ar r ay of models

wit h Ny out put s

and Nu input s

Mult idimensional ar r ay of size [Ny Nu S1 ... Sn] for

which response(i,j,k,:) specifies t he ar r ay of

fr equency r esponse dat a fr om input j t o out put i at

fr equency frequency(k)

frd

11-81

tf Cr eat e t r ansfer funct ions

zpk Cr eat e zer o-pole-gain models

frdata

11-82

11fr dat a

Purpose Quick access t o dat a for a fr equency r esponse dat a object

Syntax [response,freq] = frdata(sys)

[response,freq,Ts] = frdata(sys)

[response,freq] = frdata(sys,'v')

Description [response,freq] = frdata(sys) r et ur ns t he r esponse dat a and fr equency

samples of t he FRD model sys. For an FRD model wit h Ny out put s and Nu

input s at Nf fr equencies:

•response is an Ny-by-Nu-by-Nf mult idimensional ar r ay wher e t he (i,j)

ent r y specifies t he r esponse fr om input j t o out put i.

•freq is a column vect or of lengt h Nf t hat cont ains t he fr equency samples of

t he FRD model.

See Table 11-14, “Dat a For mat for t he Ar gument r esponse in FRD Models,” on

page 80 for mor e infor mat ion on t he dat a for mat for FRD r esponse dat a.

For SISO FRD models, t he synt ax

[response,freq] = frdata(sys,'v')

for ces frdata t o r et ur n t he r esponse dat a and fr equencies dir ect ly as column

vect or s r at her t han as cell ar r ays (see example below).

[response,freq,Ts] = frdata(sys) also r et ur ns t he sample t ime Ts.

Ot her pr oper t ies of sys can be accessed wit h get or by dir ect st r uct ur e-like

r efer encing (e.g., sys.Units).

Arguments The input ar gument sys t o frdata must be an FRD model.

Example Typing t he commands

freq = logspace(1,2,2);

resp = .05*(freq).*exp(i*2*freq);

sys = frd(resp,freq);

[resp,freq] = frdata(sys,'v')

frdata

11-83

r et ur ns t he FRD model dat a

resp =

0.2040 + 0.4565i

2.4359 - 4.3665i

freq =

10

100

See Also frd Cr eat e or conver t t o FRD models

get Get t he pr oper t ies for an LTI model

set Set model pr oper t ies

freqresp

11-84

11fr eqr esp

Purpose Comput e fr equency r esponse over gr id of fr equencies

Syntax H = freqresp(sys,w)

Description H = freqresp(sys,w) comput es t he fr equency r esponse of t he LTI model sys

at t he r eal fr equency point s specified by t he vect or w. The fr equencies must be

in r adians/sec. For single LTI Models, freqresp(sys,w) r et ur ns a 3-D ar r ay H

wit h t he fr equency as t he last dimension (see “Ar gument s” below). For LTI

ar r ays of size [Ny Nu S1 ... Sn], freqresp(sys,w) r et ur ns a [Ny–by–Nu–by–

S1–by–...–by–Sn] lengt h (w) ar r ay.

In cont inuous t ime, t he r esponse at a fr equency ω is t he t r ansfer funct ion value

at . For st at e-space models, t his value is given by

In discr et e t ime, t he r eal fr equencies w(1),..., w(N) ar e mapped t o point s on t he

unit cir cle using t he t r ansfor mat ion

wher e is t he sample t ime. The t r ansfer funct ion is t hen evaluat ed at t he

r esult ing values. The default is used for models wit h unspecified

sample t ime.

Remark If sys is an FRD model, freqresp(sys,w), w can only include fr equencies in

sys.frequency.

Arguments The out put ar gument H is a 3-D ar r ay wit h dimensions

For SISO syst ems, H(1,1,k) gives t he scalar r esponse at t he fr equency w(k).

For MIMO syst ems, t he fr equency r esponse at w(k) is H(:,:,k), a mat r ix wit h

as many r ows as out put s and as many columns as input s.

Example Comput e t he fr equency r esponse of

s j ω =

H j ω ( ) D C j ωI A – ( )

1 –

B + =

z e

j ωT

s

=

T

s

z T

s

1 =

number of out put s ( ) number of input s ( ) × lengt h of w ( ) ×

freqresp

11-85

at t he fr equencies . Type

w = [1 10 100]

H = freqresp(P,w)

H(:,:,1) =

0 0.5000– 0.5000i

–0.2000+ 0.6000i 1.0000

H(:,:,2) =

0 0.0099– 0.0990i

0.9423+ 0.2885i 1.0000

H(:,:,3) =

0 0.0001– 0.0100i

0.9994+ 0.0300i 1.0000

The t hr ee displayed mat r ices ar e t he values of for

The t hir d index in t he 3-D ar r ay H is r elat ive t o t he fr equency vect or w, so you

can ext r act t he fr equency r esponse at r ad/sec by

H(:,:,w==10)

ans =

0 0.0099– 0.0990i

0.9423+ 0.2885i 1.0000

P s ( )

0

1

s 1 +

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

s 1 –

s 2 +

------------ 1

=

ω 1 10 100 , , =

P j ω ( )

ω 1, = ω 10, = ω 100 =

ω 10 =

freqresp

11-86

Algorithm For t r ansfer funct ions or zer o-pole-gain models, freqresp evaluat es t he

numer at or (s) and denominat or (s) at t he specified fr equency point s. For

cont inuous-t ime st at e-space models , t he fr equency r esponse is

When numer ically safe, is diagonalized for fast evaluat ion of t his expr ession

at t he fr equencies . Ot her wise, is r educed t o upper Hessenber g

for m and t he linear equat ion is solved at each fr equency point ,

t aking advant age of t he Hessenber g st r uct ur e. The r educt ion t o Hessenber g

for m pr ovides a good compr omise bet ween efficiency and r eliabilit y. See [1] for

mor e det ails on t his t echnique.

Diagnostics If t he syst em has a pole on t he axis (or unit cir cle in t he discr et e-t ime case)

and w happens t o cont ain t his fr equency point , t he gain is infinit e, is

singular , and freqresp pr oduces t he following war ning message.

Singularity in freq. response due to jw-axis or unit circle pole.

See Also evalfr Response at single complex fr equency

bode Bode plot

nyquist Nyquist plot

nichols Nichols plot

sigma Singular value plot

ltiview LTI syst em viewer

References [1] Laub, A.J ., “Efficient Mult ivar iable Fr equency Response Comput at ions,”

IEEE Transactions on Automatic Control, AC-26 (1981), pp. 407–408.

A B C D , , , ( )

D C j ω A – ( )

1 –

B , + ω ω

1

... ω

N

, , =

A

ω

1

... ω

N

, , A

j ω A – ( )X B =

j ω

j ωI A –

gensig

11-87

11gensig

Purpose Gener at e t est input signals for lsim

Syntax [u,t] = gensig(type,tau)

[u,t] = gensig(type,tau,Tf,Ts)

Description [u,t] = gensig(type,tau) gener at es a scalar signal u of class type and wit h

per iod tau (in seconds). The following t ypes of signals ar e available.

gensig r et ur ns a vect or t of t ime samples and t he vect or u of signal values at

t hese samples. All gener at ed signals have unit amplit ude.

[u,t] = gensig(type,tau,Tf,Ts) also specifies t he t ime dur at ion Tf of t he

signal and t he spacing Ts bet ween t he t ime samples t.

You can feed t he out put s u and t dir ect ly t o lsim and simulat e t he r esponse of

a single-input linear syst em t o t he specified signal. Since t is uniquely

det er mined by Tf and Ts, you can also gener at e input s for mult i-input syst ems

by r epeat ed calls t o gensig.

Example Gener at e a squar e wave wit h per iod 5 seconds, dur at ion 30 seconds, and

sampling ever y 0.1 seconds.

[u,t] = gensig('square',5,30,0.1)

type = 'sin' Sine wave.

type = 'square' Squar e wave.

type = 'pulse' Per iodic pulse.

gensig

11-88

Plot t he r esult ing signal.

plot(t,u)

axis([0 30 –1 2])

See Also lsim Simulat e r esponse t o ar bit r ar y input s

0 5 10 15 20 25 30

−1

−0.5

0

0.5

1

1.5

2

get

11-89

11get

Purpose Access/quer y LTI pr oper t y values

Syntax Value = get(sys,'PropertyName')

get(sys)

Description Value = get(sys,'PropertyName') r et ur ns t he cur r ent value of t he pr oper t y

PropertyName of t he LTI model sys. The st r ing 'PropertyName' can be t he full

pr oper t y name (for example, 'UserData') or any unambiguous case-insensit ive

abbr eviat ion (for example, 'user'). You can specify any gener ic LTI pr oper t y,

or any pr oper t y specific t o t he model sys (see “LTI Pr oper t ies” on page 2-26 for

det ails on gener ic and model-specific LTI pr oper t ies).

Wit hout left -hand ar gument ,

get(sys)

displays all pr oper t ies of sys and t heir values.

Example Consider t he discr et e-t ime SISO t r ansfer funct ion defined by

h = tf(1,[1 2],0.1,'inputname','voltage','user','hello');

You can display all LTI pr oper t ies of h wit h

get(h)

num: {[0 1]}

den: {[1 2]}

Variable: 'z'

Ts: 0.1

InputDelay: 0

OutputDelay: 0

ioDelayMatrix: 0

InputName: {'voltage'}

OutputName: {''}

InputGroup: {0x2 cell}

OutputGroup: {0x2 cell}

Notes: {}

UserData: 'hello'

get

11-90

or quer y only about t he numer at or and sample t ime values by

get(h,'num')

ans =

[1x2 double]

and

get(h,'ts')

ans =

0.1000

Because t he numer at or dat a (num pr oper t y) is always st or ed as a cell ar r ay, t he

fir st command evaluat es t o a cell ar r ay cont aining t he r ow vect or [0 1].

Remark An alt er nat ive t o t he synt ax

Value = get(sys,'PropertyName')

is t he st r uct ur e-like r efer encing

Value = sys.PropertyName

For example,

sys.Ts

sys.a

sys.user

r et ur n t he values of t he sample t ime, mat r ix, and UserData pr oper t y of t he

(st at e-space) model sys.

See Also frdata Quick access t o fr equency r esponse dat a

set Set /modify LTI pr oper t ies

ssdata Quick access t o st at e-space dat a

tfdata Quick access t o t r ansfer funct ion dat a

zpkdata Quick access t o zer o-pole-gain dat a

A

gram

11-91

11gr am

Purpose Comput e cont r ollabilit y and obser vabilit y gr amians

Syntax Wc = gram(sys,'c')

Wo = gram(sys,'o')

Description gram calculat es cont r ollabilit y and obser vabilit y gr amians. You can use

gr amians t o st udy t he cont r ollabilit y and obser vabilit y pr oper t ies of

st at e-space models and for model r educt ion [1,2]. They have bet t er numer ical

pr oper t ies t han t he cont r ollabilit y and obser vabilit y mat r ices for med by ctrb

and obsv.

Given t he cont inuous-t ime st at e-space model

t he cont r ollabilit y gr amian is defined by

and t he obser vabilit y gr amian by

The discr et e-t ime count er par t s ar e

The cont r ollabilit y gr amian is posit ive definit e if and only if is

cont r ollable. Similar ly, t he obser vabilit y gr amian is posit ive definit e if and

only if is obser vable.

Use t he commands

Wc = gram(sys,'c') % controllability gramian

Wo = gram(sys,'o') % observability gramian

x

·

Ax Bu + =

y Cx Du + =

W

c

e

Aτ

BB

T

e

A

T

τ

τ d

0

∞

∫

=

W

o

e

A

T

τ

C

T

Ce

Aτ

τ d

0

∞

∫

=

W

c

A

k

BB

T

A

T

( )

k

,

k 0 =

∞

∑

= W

o

A

T

( )

k

C

T

CA

k

k 0 =

∞

∑

=

A B , ( )

C A , ( )

gram

11-92

t o comput e t he gr amians of a cont inuous or discr et e syst em. The LTI model sys

must be in st at e-space for m.

Algorithm The cont r ollabilit y gr amian is obt ained by solving t he cont inuous-t ime

Lyapunov equat ion

or it s discr et e-t ime count er par t

Similar ly, t he obser vabilit y gr amian solves t he Lyapunov equat ion

in cont inuous t ime, and t he Lyapunov equat ion

in discr et e t ime.

Limitations The mat r ix must be st able (all eigenvalues have negat ive r eal par t in

cont inuous t ime, and magnit ude st r ict ly less t han one in discr et e t ime).

See Also balreal Gr amian-based balancing of st at e-space r ealizat ions

ctrb Cont r ollabilit y mat r ix

lyap, dlyap Lyapunov equat ion solver s

obsv Obser vabilit y mat r ix

References [1] Kailat h, T., Linear S ystems, Pr ent ice-Hall, 1980.

W

c

AW

c

W

c

A

T

BB

T

+ + 0 =

AW

c

A

T

W

c

– BB

T

+ 0 =

W

o

A

T

W

o

W

o

A C

T

C + + 0 =

A

T

W

o

A W

o

– C

T

C + 0 =

A

hasdelay

11-93

11hasdelay

Purpose Test if an LTI model has t ime delays

Syntax hasdelay(sys)

Description hasdelay(sys) r et ur ns 1 (t r ue) if t he LTI model sys has input delays, out put

delays, or I/O delays, and 0 (false) ot her wise.

See Also delay2z Changes t r ansfer funct ions of discr et e-t ime LTI models

wit h delays t o r at ional funct ions or absor bs FRD delays

int o t he fr equency r esponse phase infor mat ion

totaldelay Combines delays for an LTI model

impulse

11-94

11impulse

Purpose Comput e t he impulse r esponse of LTI models

Syntax impulse(sys)

impulse(sys,t)

impulse(sys1,sys2,...,sysN)

impulse(sys1,sys2,...,sysN,t)

impulse(sys1,'PlotStyle1',...,sysN,'PlotStyleN')

[y,t,x] = impulse(sys)

Description impulse calculat es t he unit impulse r esponse of a linear syst em. The impulse

r esponse is t he r esponse t o a Dir ac input for cont inuous-t ime syst ems and

t o a unit pulse at for discr et e-t ime syst ems. Zer o init ial st at e is assumed

in t he st at e-space case. When invoked wit hout left -hand ar gument s, t his

funct ion plot s t he impulse r esponse on t he scr een.

impulse(sys) plot s t he impulse r esponse of an ar bit r ar y LTI model sys. This

model can be cont inuous or discr et e, and SISO or MIMO. The impulse r esponse

of mult i-input syst ems is t he collect ion of impulse r esponses for each input

channel. The dur at ion of simulat ion is det er mined aut omat ically t o display t he

t r ansient behavior of t he r esponse.

impulse(sys,t) set s t he simulat ion hor izon explicit ly. You can specify eit her

a final t ime t = Tfinal (in seconds), or a vect or of evenly spaced t ime samples

of t he for m

t = 0:dt:Tfinal

For discr et e syst ems, t he spacing dt should mat ch t he sample per iod. For

cont inuous syst ems, dt becomes t he sample t ime of t he discr et ized simulat ion

model (see “Algor it hm”), so make sur e t o choose dt small enough t o capt ur e

t r ansient phenomena.

To plot t he impulse r esponses of sever al LTI models sys1,..., sysN on a single

figur e, use

impulse(sys1,sys2,...,sysN)

impulse(sys1,sys2,...,sysN,t)

δ t ( )

t 0 =

impulse

11-95

As wit h bode or plot, you can specify a par t icular color , linest yle, and/or

mar ker for each syst em, for example,

impulse(sys1,'y:',sys2,'g--')

See “Plot t ing and Compar ing Mult iple Syst ems” on page 5-13 and t he bode

ent r y in t his chapt er for mor e det ails.

When invoked wit h left hand ar gument s,

[y,t] = impulse(sys)

[y,t,x] = impulse(sys) % for state-space models only

y = impulse(sys,t)

r et ur n t he out put r esponse y, t he t ime vect or t used for simulat ion, and t he

st at e t r aject or ies x (for st at e-space models only). No plot is dr awn on t he

scr een. For single-input syst ems, y has as many r ows as t ime samples (lengt h

of t), and as many columns as out put s. In t he mult i-input case, t he impulse

r esponses of each input channel ar e st acked up along t he t hir d dimension of y.

The dimensions of y ar e t hen

and y(:,:,j) gives t he r esponse t o an impulse dist ur bance ent er ing t he jt h

input channel. Similar ly, t he dimensions of x ar e

Example To plot t he impulse r esponse of t he second-or der st at e-space model

lengt h of t ( ) number of out put s ( ) number of input s ( ) × ×

lengt h of t ( ) number of st at es ( ) number of input s ( ) × ×

x

·

1

x

·

2

0.5572 – 0.7814 –

0.7814 0

x

1

x

2

1 1 –

0 2

u

1

u

2

+ =

y

1.9691 6.4493

x

1

x

2

=

impulse

11-96

use t he following commands.

a = [–0.5572 –0.7814;0.7814 0];

b = [1 –1;0 2];

c = [1.9691 6.4493];

sys = ss(a,b,c,0);

impulse(sys)

The left plot shows t he impulse r esponse of t he fir st input channel, and t he

r ight plot shows t he impulse r esponse of t he second input channel.

You can st or e t he impulse r esponse dat a in MATLAB ar r ays by

[y,t] = impulse(sys)

Time (sec.)

A

m

p

l

i

t

u

d

e

Impulse Response

0 5 10 15 20

−6

−4

−2

0

2

4

6

8

10

12

From: U1

0 5 10 15 20

From: U2

impulse

11-97

Because t his syst em has t wo input s, y is a 3-D ar r ay wit h dimensions

size(y)

ans =

101 1 2

(t he fir st dimension is t he lengt h of t). The impulse r esponse of t he fir st input

channel is t hen accessed by

y(:,:,1)

Algorithm Cont inuous-t ime models ar e fir st conver t ed t o st at e space. The impulse

r esponse of a single-input st at e-space model

is equivalent t o t he following unfor ced r esponse wit h init ial st at e .

To simulat e t his r esponse, t he syst em is discr et ized using zer o-or der hold on

t he input s. The sampling per iod is chosen aut omat ically based on t he syst em

dynamics, except when a t ime vect or t = 0:dt:Tf is supplied (dt is t hen used

as sampling per iod).

Limitations The impulse r esponse of a cont inuous syst em wit h nonzer o mat r ix is infinit e

at . impulse ignor es t his discont inuit y and r et ur ns t he lower cont inuit y

value at .

See Also ltiview LTI syst em viewer

step St ep r esponse

initial Fr ee r esponse t o init ial condit ion

lsim Simulat e r esponse t o ar bit r ar y input s

x

·

Ax bu + =

y Cx =

b

x

·

Ax , = x 0 ( ) b =

y Cx =

D

t 0 =

Cb t 0 =

initial

11-98

11init ial

Purpose Comput e t he init ial condit ion r esponse of st at e-space models

Syntax initial(sys,x0)

initial(sys,x0,t)

initial(sys1,sys2,...,sysN,x0)

initial(sys1,sys2,...,sysN,x0,t)

initial(sys1,'PlotStyle1',...,sysN,'PlotStyleN',x0)

[y,t,x] = initial(sys,x0)

Description initial calculat es t he unfor ced r esponse of a st at e-space model wit h an init ial

condit ion on t he st at es.

This funct ion is applicable t o eit her cont inuous- or discr et e-t ime models. When

invoked wit hout left hand ar gument s, initial plot s t he init ial condit ion

r esponse on t he scr een.

initial(sys,x0) plot s t he r esponse of sys t o an init ial condit ion x0 on t he

st at es. sys can be any state-space model (cont inuous or discr et e, SISO or

MIMO, wit h or wit hout input s). The dur at ion of simulat ion is det er mined

aut omat ically t o r eflect adequat ely t he r esponse t r ansient s.

initial(sys,x0,t) explicit ly set s t he simulat ion hor izon. You can specify

eit her a final t ime t = Tfinal (in seconds), or a vect or of evenly spaced t ime

samples of t he for m

t = 0:dt:Tfinal

For discr et e syst ems, t he spacing dt should mat ch t he sample per iod. For

cont inuous syst ems, dt becomes t he sample t ime of t he discr et ized simulat ion

model (see impulse), so make sur e t o choose dt small enough t o capt ur e

t r ansient phenomena.

x

·

Ax , = x 0 ( ) x

0

=

y Cx =

initial

11-99

To plot t he init ial condit ion r esponses of sever al LTI models on a single figur e,

use

initial(sys1,sys2,...,sysN,x0)

initial(sys1,sys2,...,sysN,x0,t)

(see impulse for det ails).

When invoked wit h left hand ar gument s,

[y,t,x] = initial(sys,x0)

[y,t,x] = initial(sys,x0,t)

r et ur n t he out put r esponse y, t he t ime vect or t used for simulat ion, and t he

st at e t r aject or ies x. No plot is dr awn on t he scr een. The ar r ay y has as many

r ows as t ime samples (lengt h of t) and as many columns as out put s. Similar ly,

x has length(t) r ows and as many columns as st at es.

Example Plot t he r esponse of t he st at e-space model

x

·

1

x

·

2

0.5572 – 0.7814 –

0.7814 0

x

1

x

2

=

y

1.9691 6.4493

x

1

x

2

=

initial

11-100

t o t he init ial condit ion

a = [–0.5572 –0.7814;0.7814 0];

c = [1.9691 6.4493];

x0 = [1 ; 0]

sys = ss(a,[],c,[]);

initial(sys,x0)

See Also impulse Impulse r esponse

lsim Simulat e r esponse t o ar bit r ar y input s

ltiview LTI syst em viewer

step St ep r esponse

x 0 ( )

1

0

=

Time (sec.)

A

m

p

l

i

t

u

d

e

Initial Condition Results

0 2 4 6 8 10 12 14 16 18 20

−2

−1

0

1

2

3

4

5

inv

11-101

11inv

Purpose Inver t LTI syst ems

Syntax isys = inv(sys)

Description inv inver t s t he input /out put r elat ion

t o pr oduce t he LTI syst em wit h t he t r ansfer mat r ix .

This oper at ion is defined only for squar e syst ems (same number of input s and

out put s) wit h an inver t ible feedt hr ough mat r ix . inv handles bot h

cont inuous- and discr et e-t ime syst ems.

Example Consider

At t he MATLAB pr ompt , t ype

H = [1 tf(1,[1 1]);0 1]

Hi = inv(H)

t o inver t it . MATLAB r et ur ns

Transfer function from input 1 to output...

#1: 1

#2: 0

Transfer function from input 2 to output...

–1

#1: -----

s + 1

#2: 1

y G s ( )u =

H s ( ) G s ( )

1 –

=

u H s ( )y =

D

H s ( )

1

1

s 1 +

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

0 1

=

inv

11-102

You can ver ify t hat

H * Hi

is t he ident it y t r ansfer funct ion (st at ic gain I).

Limitations Do not use inv t o model feedback connect ions such as

While it seems r easonable t o evaluat e t he cor r esponding closed-loop t r ansfer

funct ion as

inv(1+g*h) * g

t his t ypically leads t o nonminimal closed-loop models. For example,

g = zpk([],1,1)

h = tf([2 1],[1 0])

cloop = inv(1+g*h) * g

yields a t hir d-or der closed-loop model wit h an unst able pole-zer o cancellat ion

at s = 1.

cloop

Zero/pole/gain:

s (s–1)

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

(s–1) (s^2 + s + 1)

–

+

G

H

I GH + ( )

1 –

G

inv

11-103

Use feedback or star t o avoid such pit falls.

cloop = feedback(g,h)

Zero/pole/gain:

s

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

(s^2 + s + 1)

isct, isdt

11-104

11isct , isdt

Purpose Det er mine whet her an LTI model is cont inuous or discr et e

Syntax boo = isct(sys)

boo = isdt(sys)

Description boo = isct(sys) r et ur ns 1 (t r ue) if t he LTI model sys is cont inuous and 0

(false) ot her wise. sys is cont inuous if it s sample t ime is zer o, t hat is, sys.Ts=0.

boo = isdt(sys) r et ur ns 1 (t r ue) if sys is discr et e and 0 (false) ot her wise.

Discr et e-t ime LTI models have a nonzer o sample t ime, except for empt y models

and st at ic gains, which ar e r egar ded as eit her cont inuous or discr et e as long as

t heir sample t ime is not explicit ly set t o a nonzer o value. Thus bot h

isct(tf(10))

isdt(tf(10))

ar e t r ue. However , if you explicit ly label a gain as discr et e, for example, by

t yping

g = tf(10,'ts',0.01)

isct(g) now r et ur ns false and only isdt(g) is t r ue.

See Also isa Det er mine LTI model t ype

isempty Tr ue for empt y LTI models

isproper Tr ue for pr oper LTI models

isempty

11-105

11isempt y

Purpose Test if an LTI model is empt y

Syntax boo = isempty(sys)

Description isempty(sys) r et ur ns 1 (t r ue) if t he LTI model sys has no input or no out put ,

and 0 (false) ot her wise.

Example Bot h commands

isempty(tf) % tf by itself returns an empty transfer function

isempty(ss(1,2,[],[]))

r et ur n 1 (t r ue) while

isempty(ss(1,2,3,4))

r et ur ns 0 (false).

See Also issiso Tr ue for SISO syst ems

size I/O dimensions and ar r ay dimensions of LTI models

isproper

11-106

11ispr oper

Purpose Test if an LTI model is pr oper

Syntax boo = isproper(sys)

Description isproper(sys) r et ur ns 1 (t r ue) if t he LTI model sys is pr oper and 0 (false)

ot her wise.

St at e-space models ar e always pr oper . SISO t r ansfer funct ions or

zer o-pole-gain models ar e pr oper if t he degr ee of t heir numer at or is less t han

or equal t o t he degr ee of t heir denominat or . MIMO t r ansfer funct ions ar e

pr oper if all t heir SISO ent r ies ar e pr oper .

Example The following commands

isproper(tf([1 0],1)) % transfer function s

isproper(tf([1 0],[1 1])) % transfer function s/(s+1)

r et ur n false and t r ue, r espect ively.

issiso

11-107

11issiso

Purpose Test if an LTI model is single-input /single-out put (SISO)

Syntax boo = issiso(sys)

Description issiso(sys) r et ur ns 1 (t r ue) if t he LTI model sys is SISO and 0 (false)

ot her wise.

See Also isempty Tr ue for empt y LTI models

size I/O dimensions and ar r ay dimensions of LTI models

kalman

11-108

11kalman

Purpose Design cont inuous- or discr et e-t ime Kalman est imat or

Syntax [kest,L,P] = kalman(sys,Qn,Rn,Nn)

[kest,L,P,M,Z] = kalman(sys,Qn,Rn,Nn) % discrete time only

[kest,L,P] = kalman(sys,Qn,Rn,Nn,sensors,known)

Description kalman designs a Kalman st at e est imat or given a st at e-space model of t he

plant and t he pr ocess and measur ement noise covar iance dat a. The Kalman

est imat or is t he opt imal solut ion t o t he following cont inuous or discr et e

est imat ion pr oblems.

Continuous-Time Estimation

Given t he cont inuous plant

wit h known input s and pr ocess and measur ement whit e noise

sat isfying

const r uct a st at e est imat e t hat minimizes t he st eady-st at e er r or

covar iance

The opt imal solut ion is t he Kalman filt er wit h equat ions

wher e t he filt er gain is det er mined by solving an algebr aic Riccat i equat ion.

This est imat or uses t he known input s and t he measur ement s t o gener at e

x

·

Ax Bu Gw + + = (st at e equat ion)

y

v

Cx Du Hw v + + + = (measur ement equat ion)

u w v ,

E w ( ) E v ( ) 0 , E ww

T

( ) Q , = E v v

T

( ) R = , E wv

T

( ) N = = =

xˆ t ( )

P E x xˆ – { } x xˆ – { }

T

( )

t ∞ →

lim =

x

ˆ

·

Axˆ Bu L y

v

Cxˆ – Du – ( ) + + =

yˆ

xˆ

C

I

xˆ

D

0

u + =

L

u y

v

kalman

11-109

t he out put and st at e est imat es and . Not e t hat est imat es t he t r ue plant

out put

Discrete-Time Estimation

Given t he discr et e plant

and t he noise covar iance dat a

t he Kalman est imat or has equat ions

yˆ xˆ yˆ

y Cx Du Hw + + =

w

u

v

+

y

v

xˆ

Plant

y

Kalman

filt er

u

yˆ

(Measur ement noise)

Kalman estimator

x n 1 + [ ] Ax n [ ] Bu n [ ] Gw n [ ] + + =

y

v

n [ ] Cx n [ ] Du n [ ] Hw n [ ] v n [ ] + + + =

E w n [ ]w n [ ]

T

( ) Q , = E v n [ ]v n [ ]

T

( ) R = , E w n [ ]v n [ ]

T

( ) N =

xˆ n 1 n + [ ] Axˆ n n 1 – [ ] Bu n [ ] L y

v

n [ ] Cxˆ n n 1 – [ ] Du n [ ] – – ( ) + + =

yˆ n n [ ]

xˆ n n [ ]

C I MC – ( )

I MC –

xˆ n n 1 – [ ]

I CM – ( )D CM

MD – M

u n [ ]

y

v

n [ ]

+ =

kalman

11-110

and gener at es opt imal “cur r ent ” out put and st at e est imat es and

using all available measur ement s including . The gain mat r ices and

ar e der ived by solving a discr et e Riccat i equat ion. The innovation gain

is used t o updat e t he pr edict ion using t he new measur ement .

Usage [kest,L,P] = kalman(sys,Qn,Rn,Nn) r et ur ns a st at e-space model kest of t he

Kalman est imat or given t he plant model sys and t he noise covar iance dat a Qn,

Rn, Nn (mat r ices above). sys must be a st at e-space model wit h mat r ices

The r esult ing est imat or kest has as input s and (or t heir

discr et e-t ime count er par t s) as out put s. You can omit t he last input ar gument

Nn when .

The funct ion kalman handles bot h cont inuous and discr et e pr oblems and

pr oduces a cont inuous est imat or when sys is cont inuous, and a discr et e

est imat or ot her wise. In cont inuous t ime, kalman also r et ur ns t he Kalman gain

L and t he st eady-st at e er r or covar iance mat r ix P. Not e t hat P is t he solut ion of

t he associat ed Riccat i equat ion. In discr et e t ime, t he synt ax

[kest,L,P,M,Z] = kalman(sys,Qn,Rn,Nn)

r et ur ns t he filt er gain and innovat ions gain , as well as t he st eady-st at e

er r or covar iances

Finally, use t he synt axes

[kest,L,P] = kalman(sys,Qn,Rn,Nn,sensors,known)

[kest,L,P,M,Z] = kalman(sys,Qn,Rn,Nn,sensors,known)

yˆ n n [ ] xˆ n n [ ]

y

v

n [ ] L

M M

xˆ n n 1 – [ ] y

v

n [ ]

xˆ n n [ ] xˆ n n 1 – [ ] M y

v

n [ ] Cxˆ n n 1 – [ ] – Du n [ ] –

¸ ,

¸ _

+ =

innovat ion

¹ ¹ ¹ ¹ ¹ ¹ ' ¹ ¹ ¹ ¹ ¹ ¹

Q R N , ,

A

B G

C

D H

, , ,

u y

v

; [ ] yˆ ; xˆ [ ]

N 0 =

L M

P E e n n 1 – [ ]e n n 1 – [ ]

T

( ) ,

n ∞ →

lim = e n n 1 – [ ] x n [ ] x n n 1 – [ ] – =

Z E e n n [ ]e n n [ ]

T

( ) ,

n ∞ →

lim = e n n [ ] x n [ ] x n n [ ] – =

kalman

11-111

for mor e gener al plant s sys wher e t he known input s and st ochast ic input s

ar e mixed t oget her , and not all out put s ar e measur ed. The index vect or s

sensors and known t hen specify which out put s of sys ar e measur ed and

which input s ar e known. All ot her input s ar e assumed st ochast ic.

Example See examples on “Cont r ol Design Tools” on page 1-20, “LQG Design for t he

x-Axis” on page 9-34, and “Kalman Filt er ing” on page 9-50.

Limitations The plant and noise dat a must sat isfy:

• det ect able

• and

• has no uncont r ollable mode on t he imaginar y

axis (or unit cir cle in discr et e t ime)

wit h t he not at ion

See Also care Solve cont inuous-t ime Riccat i equat ions

dare Solve discr et e-t ime Riccat i equat ions

estim For m est imat or given est imat or gain

kalmd Discr et e Kalman est imat or for cont inuous plant

lqgreg Assemble LQG r egulat or

lqr Design st at e-feedback LQ r egulat or

References [1] Fr anklin, G.F., J .D. Powell, and M.L. Wor kman, Digital Control of Dynamic

S ystems, Second Edit ion, Addison-Wesley, 1990.

u

w

y

u

C A , ( )

R 0 > Q N R

1 –

N

T

– 0 ≥

A N R

1 –

C – Q N R

1 –

N

T

– , ( )

Q GQG

T

=

R R HN N

T

H

T

HQH

T

+ + + =

N G QH

T

N + ( ) =

kalmd

11-112

11kalmd

Purpose Design discr et e Kalman est imat or for cont inuous plant

Syntax [kest,L,P,M,Z] = kalmd(sys,Qn,Rn,Ts)

Description kalmd designs a discr et e-t ime Kalman est imat or t hat has r esponse

char act er ist ics similar t o a cont inuous-t ime est imat or designed wit h kalman.

This command is useful t o der ive a discr et e est imat or for digit al

implement at ion aft er a sat isfact or y cont inuous est imat or has been designed.

[kest,L,P,M,Z] = kalmd(sys,Qn,Rn,Ts) pr oduces a discr et e Kalman

est imat or kest wit h sample t ime Ts for t he cont inuous-t ime plant

wit h pr ocess noise and measur ement noise sat isfying

The est imat or kest is der ived as follows. The cont inuous plant sys is fir st

discr et ized using zer o-or der hold wit h sample t ime Ts (see c2d ent r y), and t he

cont inuous noise covar iance mat r ices and ar e r eplaced by t heir discr et e

equivalent s

The int egr al is comput ed using t he mat r ix exponent ial for mulas in [2]. A

discr et e-t ime est imat or is t hen designed for t he discr et ized plant and noise. See

kalman for det ails on discr et e-t ime Kalman est imat ion.

kalmd also r et ur ns t he est imat or gains L and M, and t he discr et e er r or

covar iance mat r ices P and Z (see kalman for det ails).

Limitations The discr et ized pr oblem dat a should sat isfy t he r equir ement s for kalman.

See Also kalman Design Kalman est imat or

x

·

Ax Bu Gw + + = (st at e equat ion)

y

v

Cx Du v + + = (measur ement equat ion)

w v

E w ( ) E v ( ) 0 , E ww

T

( ) Q

n

, = E v v

T

( ) R

n

= , E wv

T

( ) 0 = = =

Q

n

R

n

Q

d

e

Aτ

GQG

T

e

A

T

τ

τ d

0

T

s

∫

=

R

d

R T

s

⁄ =

kalmd

11-113

lqgreg Assemble LQG r egulat or

lqrd Discr et e LQ-opt imal gain for cont inuous plant

References [1] Fr anklin, G.F., J .D. Powell, and M.L. Wor kman, Digital Control of Dynamic

S ystems, Second Edit ion, Addison-Wesley, 1990.

[2] Van Loan, C.F., “Comput ing Int egr als Involving t he Mat r ix Exponent ial,”

IEEE Trans. Automatic Control, AC-15, Oct ober 1970.

kalmd

11-114

lft

11-115

11lft

Purpose Redheffer st ar pr oduct (linear fr act ional t r ansfor mat ion) of t wo LTI models

Syntax sys = lft(sys1,sys2)

sys = lft(sys1,sys2,nu,ny)

Description lft for ms t he st ar pr oduct or linear fr act ional t r ansfor mat ion (LFT) of t wo LTI

models or LTI ar r ays. Such int er connect ions ar e widely used in r obust cont r ol

t echniques.

sys = lft(sys1,sys2,nu,ny) for ms t he st ar pr oduct sys of t he t wo LTI

models (or LTI ar r ays) sys1 and sys2. The st ar pr oduct amount s t o t he

following feedback connect ion for single LTI models (or for each model in an

LTI ar r ay).

This feedback loop connect s t he fir st nu out put s of sys2 t o t he last nu input s of

sys1 (signals ), and t he last ny out put s of sys1 t o t he fir st ny input s of sys2

(signals ). The r esult ing syst em sys maps t he input vect or t o t he

out put vect or .

sys1

sys2

sys

z

1

z

2

w

2

w

1

u

u

y

y

u

y w

1

; w

2

[ ]

z

1

; z

2

[ ]

lft

11-116

The abbr eviat ed synt ax

sys = lft(sys1,sys2)

pr oduces:

• The lower LFT of sys1 and sys2 if sys2 has fewer input s and out put s t han

sys1. This amount s t o delet ing and in t he above diagr am.

• The upper LFT of sys1 and sys2 if sys1 has fewer input s and out put s t han

sys2. This amount s t o delet ing and in t he above diagr am.

Algorithm The closed-loop model is der ived by element ar y st at e-space manipulat ions.

Limitations Ther e should be no algebr aic loop in t he feedback connect ion.

See Also connect Der ive st at e-space model for block diagr am

int er connect ion

feedback Feedback connect ion

w

2

z

2

w

1

z

1

sys1

sys2

u

y

u

y

z

1

z

2

w

2

w

1

sys1

sys2

Lower LFT connection Upper LFT connection

lqgreg

11-117

11lqgr eg

Purpose For m LQG r egulat or given st at e-feedback gain and Kalman est imat or

Syntax rlqg = lqgreg(kest,k)

rlqg = lqgreg(kest,k,'current') % discrete-time only

rlqg = lqgreg(kest,k,controls)

Description lqgreg for ms t he LQG r egulat or by connect ing t he Kalman est imat or designed

wit h kalman and t he opt imal st at e-feedback gain designed wit h lqr, dlqr, or

lqry. The LQG r egulat or minimizes some quadr at ic cost funct ion t hat t r ades

off r egulat ion per for mance and cont r ol effor t . This r egulat or is dynamic and

r elies on noisy out put measur ement s t o gener at e t he r egulat ing commands (see

“LQG Regulat or ” on page 7-10 for det ails).

In cont inuous t ime, t he LQG r egulat or gener at es t he commands

wher e is t he Kalman st at e est imat e. The r egulat or st at e-space equat ions ar e

wher e is t he vect or of plant out put measur ement s (see kalman for

backgr ound and not at ion). The diagr am below shows t his dynamic r egulat or in

r elat ion t o t he plant .

u Kxˆ – =

xˆ

x

ˆ

·

A L C – B L D – ( )K –

xˆ L y

v

+ =

u Kxˆ – =

y

v

lqgreg

11-118

In discr et e t ime, you can for m t he LQG r egulat or using eit her t he pr edict ion

of based on measur ement s up t o , or t he cur r ent st at e

est imat e based on all available measur ement s including . While

t he r egulat or

is always well-defined, t he current regulator

is causal only when is inver t ible (see kalman for t he not at ion). In

addit ion, pr act ical implement at ions of t he cur r ent r egulat or should allow for

t he pr ocessing t ime r equir ed t o comput e once t he measur ement s

become available (t his amount s t o a t ime delay in t he feedback loop).

Usage rlqg = lqgreg(kest,k) r et ur ns t he LQG r egulat or rlqg (a st at e-space model)

given t he Kalman est imat or kest and t he st at e-feedback gain mat r ix k. The

same funct ion handles bot h cont inuous- and discr et e-t ime cases. Use

consist ent t ools t o design kest and k:

u

y

+

+

xˆ

K –

LQG regulator

u

Plant

Measur ement

noise

Kalman

filt er

Pr ocess

noise

y

v

xˆ n n 1 – [ ] x n [ ] y

v

n 1 – [ ]

xˆ n n [ ] y

v

n [ ]

u n [ ] Kxˆ n n 1 – [ ] – =

u n [ ] Kxˆ n n [ ] – =

I KMD –

u n [ ] y

v

n [ ]

lqgreg

11-119

•Cont inuous r egulat or for cont inuous plant : use lqr or lqry and kalman.

•Discr et e r egulat or for discr et e plant : use dlqr or lqry and kalman.

•Discr et e r egulat or for cont inuous plant : use lqrd and kalmd.

In discr et e t ime, lqgreg pr oduces t he r egulat or

by default (see “Descr ipt ion”). To for m t he “cur r ent ” LQG r egulat or inst ead, use

t he synt ax

rlqg = lqgreg(kest,k,'current')

This synt ax is meaningful only for discr et e-t ime pr oblems.

rlqg = lqgreg(kest,k,controls) handles est imat or s t hat have access t o

addit ional known plant input s . The index vect or controls t hen specifies

which est imat or input s ar e t he cont r ols , and t he r esult ing LQG r egulat or

rlqg has and as input s (see figur e below).

Note: Always use positive feedback t o connect t he LQG r egulat or t o t he

plant .

u n [ ] Kxˆ n n 1 – [ ] – =

u n [ ] Kxˆ n n [ ] – =

u

d

u

u

d

y

v

lqgreg

11-120

Example See t he examples “Cont r ol Design Tools” on page 1-20 and “LQG Regulat ion”

on page 9-31.

See Also kalman Kalman est imat or design

kalmd Discr et e Kalman est imat or for cont inuous plant

lqr, dlqr St at e-feedback LQ r egulat or

lqrd Discr et e LQ r egulat or for cont inuous plant

lqry LQ r egulat or wit h out put weight ing

reg For m r egulat or given st at e-feedback and est imat or

gains

xˆ

u

y

v

Kalman

est imat or

u

d K – u

LQG regulator

lqr

11-121

11lqr

Purpose Design linear -quadr at ic (LQ) st at e-feedback r egulat or for cont inuous plant

Syntax [K,S,e] = lqr(A,B,Q,R)

[K,S,e] = lqr(A,B,Q,R,N)

Description [K,S,e] = lqr(A,B,Q,R,N) calculat es t he opt imal gain mat r ix K such t hat t he

st at e-feedback law

minimizes t he quadr at ic cost funct ion

for t he cont inuous-t ime st at e-space model

The default value N=0 is assumed when N is omit t ed.

In addit ion t o t he st at e-feedback gain K, lqr r et ur ns t he solut ion S of t he

associat ed Riccat i equat ion

and t he closed-loop eigenvalues e = eig(A–B*K). Not e t hat is der ived fr om

by

Limitations The pr oblem dat a must sat isfy:

•The pair is st abilizable.

• and .

• has no unobser vable mode on t he imaginar y

axis.

u Kx – =

J u ( ) x

T

Qx u

T

R u 2x

T

N u + + ( ) t d

0

∞

∫

=

x

·

Ax Bu + =

A

T

S S A S B N + ( )R

1 –

B

T

S N

T

+ ( ) – Q + + 0 =

K

S

K R

1 –

B

T

S N

T

+ ( ) =

A B , ( )

R 0 > Q N R

1 –

N

T

– 0 ≥

Q N R

1 –

N

T

– A BR

1 –

N

T

– , ( )

lqr

11-122

See Also care Solve cont inuous Riccat i equat ions

dlqr St at e-feedback LQ r egulat or for discr et e plant

lqgreg For m LQG r egulat or

lqrd Discr et e LQ r egulat or for cont inuous plant

lqry St at e-feedback LQ r egulat or wit h out put weight ing

lqrd

11-123

11lqr d

Purpose Design discr et e LQ r egulat or for cont inuous plant

Syntax [Kd,S,e] = lqrd(A,B,Q,R,Ts)

[Kd,S,e] = lqrd(A,B,Q,R,N,Ts)

Description lqrd designs a discr et e full-st at e-feedback r egulat or t hat has r esponse

char act er ist ics similar t o a cont inuous st at e-feedback r egulat or designed using

lqr. This command is useful t o design a gain mat r ix for digit al implement at ion

aft er a sat isfact or y cont inuous st at e-feedback gain has been designed.

[Kd,S,e] = lqrd(A,B,Q,R,Ts) calculat es t he discr et e st at e-feedback law

t hat minimizes a discr et e cost funct ion equivalent t o t he cont inuous cost

funct ion

The mat r ices A and B specify t he cont inuous plant dynamics

and Ts specifies t he sample t ime of t he discr et e r egulat or . Also r et ur ned ar e t he

solut ion S of t he discr et e Riccat i equat ion for t he discr et ized pr oblem and t he

discr et e closed-loop eigenvalues e = eig(Ad–Bd*Kd).

[Kd,S,e] = lqrd(A,B,Q,R,N,Ts) solves t he mor e gener al pr oblem wit h a

cr oss-coupling t er m in t he cost funct ion.

Algorithm The equivalent discr et e gain mat r ix Kd is det er mined by discr et izing t he

cont inuous plant and weight ing mat r ices using t he sample t ime Ts and t he

zer o-or der hold appr oximat ion.

u n [ ] K

d

x n [ ] – =

J x

T

Qx u

T

R u + ( ) t d

0

∞

∫

=

x

·

Ax Bu + =

J x

T

Qx u

T

R u 2x

T

N u + + ( ) t d

0

∞

∫

=

lqrd

11-124

Wit h t he not at ion

t he discr et ized plant has equat ions

and t he weight ing mat r ices for t he equivalent discr et e cost funct ion ar e

The int egr als ar e comput ed using mat r ix exponent ial for mulas due t o Van

Loan (see [2]). The plant is discr et ized using c2d and t he gain mat r ix is

comput ed fr om t he discr et ized dat a using dlqr.

Limitations The discr et ized pr oblem dat a should meet t he r equir ement s for dlqr.

See Also c2d Discr et izat ion of LTI model

dlqr St at e-feedback LQ r egulat or for discr et e plant

kalmd Discr et e Kalman est imat or for cont inuous plant

lqr St at e-feedback LQ r egulat or for cont inuous plant

References [1] Fr anklin, G.F., J .D. Powell, and M.L. Wor kman, Digital Control of Dynamic

S ystems, Second Edit ion, Addison-Wesley, 1980, pp. 439–440

[2] Van Loan, C.F., “Comput ing Int egr als Involving t he Mat r ix Exponent ial,”

IEEE Trans. Automatic Control, AC-15, Oct ober 1970.

Φ τ ( ) e

Aτ

, = A

d

Φ T

s

( ) =

Γ τ ( ) e

Aη

B η , d

0

τ

∫

= B

d

Γ T

s

( ) =

x n 1 + [ ] A

d

x n [ ] B

d

u n [ ] + =

Q

d

N

d

N

d

T

R

d

Φ

T

τ ( ) 0

Γ

T

τ ( ) I

Q N

N

T

R

Φ τ ( ) Γ τ ( )

0 I

τ d

0

T

s

∫

=

lqry

11-125

11lqr y

Purpose Linear -quadr at ic (LQ) st at e-feedback r egulat or wit h out put weight ing

Syntax [K,S,e] = lqry(sys,Q,R)

[K,S,e] = lqry(sys,Q,R,N)

Description Given t he plant

or it s discr et e-t ime count er par t , lqry designs a st at e-feedback cont r ol

t hat minimizes t he quadr at ic cost funct ion wit h out put weight ing

(or it s discr et e-t ime count er par t ). The funct ion lqry is equivalent t o lqr or

dlqr wit h weight ing mat r ices:

[K,S,e] = lqry(sys,Q,R,N) r et ur ns t he opt imal gain mat r ix K, t he Riccat i

solut ion S, and t he closed-loop eigenvalues e = eig(A-B*K). The st at e-space

model sys specifies t he cont inuous- or discr et e-t ime plant dat a .

The default value N=0 is assumed when N is omit t ed.

Example See “LQG Design for t he x-Axis” on page 9-34 for an example.

Limitations The dat a must sat isfy t he r equir ement s for lqr or dlqr.

See Also lqr St at e-feedback LQ r egulat or for cont inuous plant

dlqr St at e-feedback LQ r egulat or for discr et e plant

kalman Kalman est imat or design

lqgreg For m LQG r egulat or

x

·

Ax Bu + =

y Cx Du + =

u Kx – =

J u ( ) y

T

Qy u

T

R u 2y

T

N u + + ( ) t d

0

∞

∫

=

Q N

N

T

R

C

T

0

D

T

I

Q N

N

T

R

C D

0 I

=

A B C D , , , ( )

A B Q R N , , , ,

lsim

11-126

11lsim

Purpose Simulat e LTI model r esponse t o ar bit r ar y input s

Syntax lsim(sys,u,t)

lsim(sys,u,t,x0)

lsim(sys1,sys2,...,sysN,u,t)

lsim(sys1,sys2,...,sysN,u,t,x0)

lsim(sys1,'PlotStyle1',...,sysN,'PlotStyleN',u,t)

[y,t,x] = lsim(sys,u,t,x0)

Description lsim simulat es t he (t ime) r esponse of cont inuous or discr et e linear syst ems t o

ar bit r ar y input s. When invoked wit hout left -hand ar gument s, lsim plot s t he

r esponse on t he scr een.

lsim(sys,u,t) pr oduces a plot of t he zer o-init ial condit ion t ime r esponse of t he

LTI model sys t o t he input t ime hist or y t,u. The vect or t specifies t he t ime

samples for t he simulat ion and consist s of r egular ly spaced t ime samples

t = T0:dt:Tfinal

The mat r ix u must have as many r ows as t ime samples (length(t)) and as

many columns as syst em input s. Each r ow u(i,:) specifies t he input value(s)

at t he t ime sample t(i).

The LTI model sys can be cont inuous or discr et e, SISO or MIMO. In discr et e

t ime, u must be sampled at t he same r at e as t he syst em (t is t hen r edundant

and can be omit t ed or set t o t he empt y mat r ix). In cont inuous t ime, t he t ime

sampling dt=t(2)–t(1) is used t o discr et ize t he cont inuous model. Aut omat ic

r esampling is per for med if dt is t oo lar ge (under sampling) and may give r ise t o

hidden oscillat ions (see “Algor it hm”).

lsim(sys,u,t,x0) specifies a nonzer o init ial condit ion x0 for t he syst em

st at es. This init ial condit ion is applied at t(1). This synt ax applies only t o

st at e-space models.

Finally,

lsim(sys1,sys2,...,sysN,u,t)

lsim

11-127

simulat es t he r esponses of sever al LTI models t o t he same input hist or y t,u and

plot s t hese r esponses on a single figur e. As wit h bode or plot, you can specify

a par t icular color , linest yle, and/or mar ker for each syst em, for example,

lsim(sys1,'y:',sys2,'g--',u,t,x0)

The mult isyst em behavior is similar t o t hat of bode or step.

When invoked wit h left -hand ar gument s,

[y,t] = lsim(sys,u,t)

[y,t,x] = lsim(sys,u,t) % for state-space models only

[y,t,x] = lsim(sys,u,t,x0) % with initial state

r et ur n t he out put r esponse y, t he t ime vect or t used for simulat ion, and t he

st at e t r aject or ies x (for st at e-space models only). No plot is dr awn on t he

scr een. The mat r ix y has as many r ows as t ime samples (length(t)) and as

many columns as syst em out put s. The same holds for x wit h “out put s” r eplaced

by st at es. Not e t hat t he out put t may differ fr om t he specified t ime vect or when

t he input dat a is under sampled (see “Algor it hm”).

Example Simulat e and plot t he r esponse of t he syst em

t o a squar e wave wit h per iod of four seconds. Fir st gener at e t he squar e wave

wit h gensig. Sample ever y 0.1 second dur ing 10 seconds:

[u,t] = gensig('square',4,10,0.1);

H s ( )

2s

2

5s 1 + +

s

2

2s 3 + +

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

s 1 –

s

2

s 5 + +

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

=

lsim

11-128

Then simulat e wit h lsim.

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

lsim(H,u,t)

lsim

11-129

Not e t hat if you begin t he simulat ion wit h a nonzer o value for t (1), t hen t he

zer o-init ial condit ion r esponse is shift ed in t ime, as shown below.

lsim(H,u,t+4)

Algorithm Discr et e-t ime syst ems ar e simulat ed wit h ltitr (st at e space) or filter

(t r ansfer funct ion and zer o-pole-gain).

Cont inuous-t ime syst ems ar e discr et ized wit h c2d using eit her t he 'zoh' or

'foh' met hod ('foh' is used for smoot h input signals and 'zoh' for

discont inuous signals such as pulses or squar e waves). By default , t he

sampling per iod is set t o t he spacing dt bet ween t he user -supplied t ime

samples t. However , if dt is not small enough t o capt ur e int er sample behavior ,

lsim select s a smaller sampling per iod and r esamples t he input dat a using

linear int er polat ion for smoot h signals and zer o-or der hold for squar e signals.

The t ime vect or r et ur ned by lsim is t hen differ ent fr om t he specified t vect or .

lsim

11-130

To illust r at e why r esampling is somet imes necessar y, consider t he

second-or der model

To simulat e it s r esponse t o a squar e wave wit h per iod 1 second, you can pr oceed

as follows:

w2 = 62.83^2

h = tf(w2,[1 2 w2]);

t = 0:0.1:5; % vector of time samples

u = (rem(t,1)>=0.5); % square wave values

lsim(h,u,t)

H s ( )

ω

2

s

2

2s ω

2

+ +

------------------------------- , = ω 62.83 =

lsim

11-131

The r esponse exhibit s st r ong oscillat ions. Less obvious fr om t his plot is t he fact

t hat lsim has r esampled t he input t o r eveal t he oscillat or y behavior . To see

t his, discr et ize using t he sampling per iod 0.1 second (spacing in your t

vect or ) and simulat e t he r esponse of t he discr et ized model:

hd = c2d(h,0.1);

lsim(hd,u,t)

H s ( )

lsim

11-132

The t wo r esponses look quit e differ ent . To clar ify t his discr epancy,

super impose t he t wo plot s by

lsim(h,'b--',hd,'r-',u,t)

The cause is now obvious: hd is under sampled and it s r esponse (solid line)

masks t he int er sample oscillat ions of t he cont inuous model .

By compar ing t he suggest ed sampling dt=t(2)–t(1) against t he syst em

dynamics, lsim det ect s such under sampling and r esamples t he input t o

pr oduce accur at e cont inuous-t ime simulat ions.

See Also gensig Gener at e t est input signals for lsim

impulse Impulse r esponse

initial Fr ee r esponse t o init ial condit ion

ltiview LTI syst em viewer

step St ep r esponse

H s ( )

ltiview

11-133

11lt iview

Purpose Init ialize an LTI Viewer for LTI syst em r esponse analysis

Syntax ltiview

ltiview(plottype,sys)

ltiview(plottype,sys,extras)

ltiview(plottype,sys1,sys2,...sysN)

ltiview(plottype,sys1,sys2,...sysN,extras)

ltiview(plottype,sys1,PlotStyle1,sys2,PlotStyle2,...)

Description ltiview when invoked wit hout input ar gument s, init ializes a new LTI Viewer

for LTI syst em r esponse analysis.

Only fr equency-domain analysis funct ions can be applied t o FRDs.

ltiview(plottype,sys) init ializes an LTI Viewer cont aining t he LTI

r esponse t ype indicat ed by plottype for t he LTI model sys. The st r ing

plottype can be any one of t he following:

'step'

'impulse'

'initial'

'lsim'

'pzmap'

'bode'

'nyquist'

'nichols'

'sigma'

or , plottype can be a cell vect or cont aining up t o six of t hese plot t ypes.

For example,

ltiview({'step';'nyquist'},sys)

displays t he plot s of bot h of t hese r esponse t ypes for a given syst em sys.

ltiview(plottype,sys,extras) allows t he addit ional input ar gument s

suppor t ed by t he var ious LTI model r esponse funct ions t o be passed t o t he

lt iview command.

ltiview

11-134

extras is one or mor e input ar gument s as specified by t he funct ion named in

plottype. These ar gument s may be r equir ed or opt ional, depending on t he t ype

of LTI r esponse. For example, if plottype is 'step' t hen extras may be t he

desir ed final t ime, Tfinal, as shown below.

ltiview('step',sys,Tfinal)

However , if plottype is 'initial', t he extras ar gument s must cont ain t he

init ial condit ions x0 and may cont ain ot her ar gument s, such as Tfinal.

ltiview('initial',sys,x0,Tfinal)

See t he individual r efer ences pages of each possible plottype commands for a

list of appr opr iat e ar gument s for extras.

Finally,

ltiview(plottype,sys1,sys2,...sysN)

ltiview(plottype,sys1,sys2,...sysN,extras)

ltiview(plottype,sys1,PlotStyle1,sys2,PlotStyle2,...)

init ializes an LTI Viewer cont aining t he r esponses of mult iple LTI models,

using t he plot st yles in PlotStyle, when applicable. See t he individual

r efer ence pages of t he LTI r esponse funct ions for mor e infor mat ion on

specifying plot st yles.

Example See Chapt er 6, “The LTI Viewer .”

See Also bode Bode r esponse

impulse Impulse r esponse

initial Response t o init ial condit ion

lsim Simulat e LTI model r esponse t o ar bit r ar y input s

nichols Nichols r esponse

nyquist Nyquist r esponse

pzmap Pole/zer o map

sigma Singular value r esponse

step St ep r esponse

lyap

11-135

11lyap

Purpose Solve cont inuous-t ime Lyapunov equat ions

Syntax X = lyap(A,Q)

X = lyap(A,B,C)

Description lyap solves t he special and gener al for ms of t he Lyapunov mat r ix equat ion.

Lyapunov equat ions ar ise in sever al ar eas of cont r ol, including st abilit y t heor y

and t he st udy of t he RMS behavior of syst ems.

X = lyap(A,Q) solves t he Lyapunov equat ion

wher e and ar e squar e mat r ices of ident ical sizes. The solut ion X is a

symmet r ic mat r ix if is.

X = lyap(A,B,C) solves t he gener alized Lyapunov equat ion (also called

Sylvest er equat ion).

The mat r ices must have compat ible dimensions but need not be

squar e.

Algorithm lyap t r ansfor ms t he and mat r ices t o complex Schur for m, comput es t he

solut ion of t he r esult ing t r iangular syst em, and t r ansfor ms t his solut ion back

[1].

Limitations The cont inuous Lyapunov equat ion has a (unique) solut ion if t he eigenvalues

of and of sat isfy

If t his condit ion is violat ed, lyap pr oduces t he er r or message

Solution does not exist or is not unique.

See Also covar Covar iance of syst em r esponse t o whit e noise

dlyap Solve discr et e Lyapunov equat ions

AX XA

T

Q + + 0 =

A Q

Q

AX XB C + + 0 =

A B C , ,

A B

α

1

α

2

... α

n

, , , A β

1

β

2

... β

n

, , , B

α

i

β

j

0 ≠ + for all pair s i j , ( )

lyap

11-136

References [1] Bar t els, R.H. and G.W. St ewar t , “Solut ion of t he Mat r ix Equat ion AX + XB

= C,” Comm. of the ACM, Vol. 15, No. 9, 1972.

[2] Br yson, A.E. and Y.C. Ho, Applied Optimal Control, Hemispher e

Publishing, 1975. pp. 328–338.

margin

11-137

11mar gin

Purpose Comput e gain and phase mar gins and associat ed cr ossover fr equencies

Syntax [Gm,Pm,Wcg,Wcp] = margin(sys)

[Gm,Pm,Wcg,Wcp] = margin(mag,phase,w)

margin(sys)

Description margin calculat es t he gain mar gin, phase mar gin, and associat ed cr ossover

fr equencies of SISO open-loop models. The gain and phase mar gins indicat e

t he r elat ive st abilit y of t he cont r ol syst em when t he loop is closed. When

invoked wit hout left -hand ar gument s, margin pr oduces a Bode plot and

displays t he mar gins on t his plot .

The gain mar gin is t he amount of gain incr ease r equir ed t o make t he loop gain

unit y at t he fr equency wher e t he phase angle is –180°. In ot her wor ds, t he gain

mar gin is if is t he gain at t he –180° phase fr equency. Similar ly, t he

phase mar gin is t he differ ence bet ween t he phase of t he r esponse and –180°

when t he loop gain is 1.0. The fr equency at which t he magnit ude is 1.0 is called

t he unit y-gain fr equency or cr ossover fr equency. It is gener ally found t hat gain

mar gins of t hr ee or mor e combined wit h phase mar gins bet ween 30 and 60

degr ees r esult in r easonable t r ade-offs bet ween bandwidt h and st abilit y.

[Gm,Pm,Wcg,Wcp] = margin(sys) comput es t he gain mar gin Gm, t he phase

mar gin Pm, and t he cor r esponding cr ossover fr equencies Wcg and Wcp, given t he

SISO open-loop model sys. This funct ion handles bot h cont inuous- and

discr et e-t ime cases. When faced wit h sever al cr ossover fr equencies, margin

r et ur ns t he smallest gain and phase mar gins.

[Gm,Pm,Wcg,Wcp] = margin(mag,phase,w) der ives t he gain and phase

mar gins fr om t he Bode fr equency r esponse dat a (magnit ude, phase, and

fr equency vect or ). Int er polat ion is per for med bet ween t he fr equency point s t o

est imat e t he mar gin values. This appr oach is gener ally less accur at e.

When invoked wit hout left -hand ar gument ,

margin(sys)

plot s t he open-loop Bode r esponse wit h t he gain and phase mar gins mar ked by

ver t ical lines.

1 g ⁄ g

margin

11-138

Example You can comput e t he gain and phase mar gins of t he open-loop discr et e-t ime

t r ansfer funct ion. Type

hd = tf([0.04798 0.0464],[1 –1.81 0.9048],0.1)

MATLAB r esponds wit h

Transfer function:

0.04798 z + 0.0464

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

z^2 – 1.81 z + 0.9048

Sampling time: 0.1

Type

[Gm,Pm,Wcg,Wcp] = margin(hd);

[Gm,Pm,Wcg,Wcp]

and MATLAB r et ur ns

ans =

2.0517 13.5712 5.4374 4.3544

margin

11-139

You can also display t hese mar gins gr aphically.

margin(hd)

Algorithm The phase mar gin is comput ed using t heor y, and t he gain mar gin by

solving for t he fr equency .

See Also bode Bode fr equency r esponse

ltiview LTI syst em viewer

Frequency (rad/sec)

P

h

a

s

e

(

d

e

g

)

;

M

a

g

n

i

t

u

d

e

(

d

B

)

Bode Diagrams

−100

−50

0

50

Gm=6.3 dB (Wcg=5.4); Pm=13.6 deg. (Wcp=4.4)

10

0

10

1

10

2

−300

−250

−200

−150

−100

−50

0

H

∞

H j ω ( ) H j ω ( ) = ω

minreal

11-140

11minreal

Purpose Minimal r ealizat ion or pole-zer o cancellat ion

Syntax sysr = minreal(sys)

sysr = minreal(sys,tol)

Description sysr = minreal(sys) eliminat es uncont r ollable or unobser vable st at e in

st at e-space models, or cancels pole-zer o pair s in t r ansfer funct ions or

zer o-pole-gain models. The out put sysr has minimal or der and t he same

r esponse char act er ist ics as t he or iginal model sys.

sysr = minreal(sys,tol) specifies t he t oler ance used for st at e eliminat ion or

pole-zer o cancellat ion. The default value is tol = sqrt(eps) and incr easing

t his t oler ance for ces addit ional cancellat ions.

Example The commands

g = zpk([],1,1)

h = tf([2 1],[1 0])

cloop = inv(1+g*h) * g

pr oduce t he nonminimal zer o-pole-gain model by t yping cloop.

Zero/pole/gain:

s (s–1)

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

(s–1) (s^2 + s + 1)

To cancel t he pole-zer o pair at , t ype

cloop = minreal(cloop)

and MATLAB r et ur ns

Zero/pole/gain:

s

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

(s^2 + s + 1)

Algorithm Pole-zer o cancellat ion is a st r aight for war d sear ch t hr ough t he poles and zer os

looking for mat ches t hat ar e wit hin t oler ance. Tr ansfer funct ions ar e fir st

conver t ed t o zer o-pole-gain for m.

s 1 =

minreal

11-141

See Also balreal Gr amian-based input /out put balancing

modred Model or der r educt ion

sminreal St r uct ur ed model r educt ion

modred

11-142

11modred

Purpose Model or der r educt ion

Syntax rsys = modred(sys,elim)

rsys = modred(sys,elim,'mdc')

rsys = modred(sys,elim,'del')

Description modred r educes t he or der of a cont inuous or discr et e st at e-space model sys.

This funct ion is usually used in conjunct ion wit h balreal. Two or der r educt ion

t echniques ar e available:

•rsys = modred(sys,elim) or rsys = modred(sys,elim,'mdc') pr oduces a

r educed-or der model rsys wit h mat ching DC gain (or equivalent ly, mat ching

st eady st at e in t he st ep r esponse). The index vect or elim specifies t he st at es

t o be eliminat ed. The r esult ing model rsys has length(elim) fewer st at es.

This t echnique consist s of set t ing t he der ivat ive of t he eliminat ed st at es t o

zer o and solving for t he r emaining st at es.

•rsys = modred(sys,elim,'del')simply delet es t he st at es specified by elim.

While t his met hod does not guar ant ee mat ching DC gains, it t ends t o

pr oduce bet t er appr oximat ions in t he fr equency domain (see example below).

If t he st at e-space model sys has been balanced wit h balreal and t he gr amians

have small diagonal ent r ies, you can r educe t he model or der by eliminat ing

t he last st at es wit h modred.

Example Consider t he cont inuous four t h-or der model

To r educe it s or der , fir st comput e a balanced st at e-space r ealizat ion wit h

balreal by t yping

h = tf([1 11 36 26],[1 14.6 74.96 153.7 99.65])

[hb,g] = balreal(h)

g'

MATLAB r et ur ns

ans =

1.3938e–01 9.5482e–03 6.2712e–04 7.3245e–06

m

m

h s ( )

s

3

11s

2

36s 26 + + +

s

4

14.6 + s

3

74.96s

2

153.7s 99.65 + + +

------------------------------------------------------------------------------------------------------ =

modred

11-143

The last t hr ee diagonal ent r ies of t he balanced gr amians ar e small, so

eliminat e t he last t hr ee st at es wit h modred using bot h mat ched DC gain and

dir ect delet ion met hods.

hmdc = modred(hb,2:4,'mdc')

hdel = modred(hb,2:4,'del')

Bot h hmdc and hdel ar e fir st -or der models. Compar e t heir Bode r esponses

against t hat of t he or iginal model .

bode(h,'-',hmdc,'x',hdel,'*')

h s ( )

Frequency (rad/sec)

P

h

a

s

e

(

d

e

g

)

;

M

a

g

n

i

t

u

d

e

(

d

B

)

Bode Diagrams

−80

−60

−40

−20

0

10

−1

10

0

10

1

10

2

10

3

−200

−150

−100

−50

0

modred

11-144

The r educed-or der model hdel is clear ly a bet t er fr equency-domain

appr oximat ion of . Now compar e t he st ep r esponses.

step(h,'-',hmdc,'-.',hdel,'--')

While hdel accur at ely r eflect s t he t r ansient behavior , only hmdc gives t he t r ue

st eady-st at e r esponse.

Algorithm The algor it hm for t he mat ched DC gain met hod is as follows. For

cont inuous-t ime models

t he st at e vect or is par t it ioned int o , t o be kept , and , t o be eliminat ed.

h s ( )

Time (sec.)

A

m

p

l

i

t

u

d

e

Step Response

0 0.5 1 1.5 2 2.5 3

−0.05

0

0.05

0.1

0.15

0.2

0.25

0.3

x

·

Ax Bu + =

y Cx Du + =

x

1

x

2

modred

11-145

Next , t he der ivat ive of is set t o zer o and t he r esult ing equat ion is solved for

. The r educed-or der model is given by

The discr et e-t ime case is t r eat ed similar ly by set t ing

Limitations Wit h t he mat ched DC gain met hod, must be inver t ible in cont inuous t ime,

and must be inver t ible in discr et e t ime.

See Also balreal Input /out put balancing of st at e-space models

minreal Minimal st at e-space r ealizat ions

x

·

1

x

·

2

A

11

A

12

A

21

A

22

x

1

x

2

B

1

B

2

u + =

y C

1

C

2

x Du + =

x

2

x

1

x

·

1

A

11

A

12

A

22

1 –

A

21

– [ ]x

1

B

1

A

12

A

22

1 –

B

2

– [ ]u + =

y C

1

C

2

A

22

1 –

A

21

– [ ]x D C

2

A

22

1 –

B

2

– [ ]u + =

x

2

n 1 + [ ] x

2

n [ ] =

A

22

I A

22

–

ndims

11-146

11ndims

Purpose Pr ovide t he number of t he dimensions of an LTI model or LTI ar r ay

Syntax n = ndims(sys)

Description n = ndims(sys) is t he number of dimensions of an LTI model or an ar r ay of

LTI models sys. A single LTI model has t wo dimensions (one for out put s, and

one for input s). An LTI ar r ay has 2+p dimensions, wher e is t he number

of ar r ay dimensions. For example, a 2-by-3-by-4 ar r ay of models has 2+3=5

dimensions.

ndims(sys) = length(size(sys))

Example sys = rss(3,1,1,3);

ndims(sys)

ans =

4

ndims r et ur ns 4 for t his 3-by-1 ar r ay of SISO models.

See Also size Ret ur ns a vect or cont aining t he lengt hs of t he

dimensions of an LTI ar r ay or model

p 2 ≥

ngrid

11-147

11ngr id

Purpose Super impose a Nichols char t on a Nichols plot

Syntax ngrid

Description ngrid super imposes Nichols char t gr id lines over t he Nichols fr equency

r esponse of a SISO LTI syst em. The r ange of t he Nichols gr id lines is set t o

encompass t he ent ir e Nichols fr equency r esponse.

The char t r elat es t he complex number t o , wher e is any

complex number . For SISO syst ems, when is a point on t he open-loop

fr equency r esponse, t hen

is t he cor r esponding value of t he closed-loop fr equency r esponse assuming unit

negat ive feedback.

If t he cur r ent axis is empt y, ngrid gener at es a new Nichols char t gr id in t he

r egion –40 dB t o 40 dB in magnit ude and –360 degr ees t o 0 degr ees in phase.

If t he cur r ent axis does not cont ain a SISO Nichols fr equency r esponse, ngrid

r et ur ns a war ning.

Example Plot t he Nichols r esponse wit h Nichols gr id lines for t he syst em.

Type

H = tf([–4 48 –18 250 600],[1 30 282 525 60])

MATLAB r et ur ns

Transfer function:

– 4 s^4 + 48 s^3 – 18 s^2 + 250 s + 600

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

s^4 + 30 s^3 + 282 s^2 + 525 s + 60

H 1 H + ( ) ⁄ H H

H

H

1 H +

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

H s ( )

4s

4

– 48s

3

18s

2

– 250s 600 + + +

s

4

30s

3

282s

2

525s 60 + + + +

--------------------------------------------------------------------------------------- =

ngrid

11-148

Type

nichols(H)

ngrid

See Also nichols Nichols plot s

Open−Loop Phase (deg)

O

p

e

n

−

L

o

o

p

G

a

i

n

(

d

B

)

Nichols Charts

−500 −450 −400 −350 −300 −250 −200 −150 −100 −50

−40

−30

−20

−10

0

10

20

30

40

6 dB

3 dB

1 dB

0.5 dB

0.25 dB

0 dB

−1 dB

−3 dB

−6 dB

−12 dB

−20 dB

−40 dB

nichols

11-149

11nichols

Purpose Comput e Nichols fr equency r esponse of LTI models

Syntax nichols(sys)

nichols(sys,w)

nichols(sys1,sys2,...,sysN)

nichols(sys1,sys2,...,sysN,w)

nichols(sys1,'PlotStyle1',...,sysN,'PlotStyleN')

[mag,phase,w] = nichols(sys)

[mag,phase] = nichols(sys,w)

Description nichols comput es t he fr equency r esponse of an LTI model and plot s it in t he

Nichols coor dinat es. Nichols plot s ar e useful t o analyze open- and closed-loop

pr oper t ies of SISO syst ems, but offer lit t le insight int o MIMO cont r ol loops.

Use ngrid t o super impose a Nichols char t on an exist ing SISO Nichols plot .

nichols(sys) pr oduces a Nichols plot of t he LTI model sys. This model can be

cont inuous or discr et e, SISO or MIMO. In t he MIMO case, nichols pr oduces

an ar r ay of Nichols plot s, each plot showing t he r esponse of one par t icular I/O

channel. The fr equency r ange and gr idding ar e det er mined aut omat ically

based on t he syst em poles and zer os.

nichols(sys,w) explicit ly specifies t he fr equency r ange or fr equency point s t o

be used for t he plot . To focus on a par t icular fr equency int er val [wmin,wmax],

set w = {wmin,wmax}. To use par t icular fr equency point s, set w t o t he vect or of

desir ed fr equencies. Use logspace t o gener at e logar it hmically spaced

fr equency vect or s. Fr equencies should be specified in r adians/sec.

nichols(sys1,sys2,...,sysN) or nichols(sys1,sys2,...,sysN,w)

super imposes t he Nichols plot s of sever al LTI models on a single figur e. All

syst ems must have t he same number of input s and out put s, but may ot her wise

be a mix of cont inuous- and discr et e-t ime syst ems. You can also specify a

dist inct ive color , linest yle, and/or mar ker for each syst em plot wit h t he synt ax

nichols(sys1,'PlotStyle1',...,sysN,'PlotStyleN')

See bode for an example.

nichols

11-150

When invoked wit h left -hand ar gument s,

[mag,phase,w] = nichols(sys)

[mag,phase] = nichols(sys,w)

r et ur n t he magnit ude and phase (in degr ees) of t he fr equency r esponse at t he

fr equencies w (in r ad/sec). The out put s mag and phase ar e 3-D ar r ays similar t o

t hose pr oduced by bode (see bode on page 11-19). They have dimensions

Remark If sys is an FRD model, nichols(sys,w), w can only include fr equencies in

sys.frequency.

Example Plot t he Nichols r esponse of t he syst em

num = [–4 48 –18 250 600];

den = [1 30 282 525 60];

H = tf(num,den)

nichols(H); ngrid

number of out put s ( ) number of input s ( ) × lengt h of w ( ) ×

H s ( )

4s

4

– 48s

3

18s

2

– 250s 600 + + +

s

4

30s

3

282s

2

525s 60 + + + +

--------------------------------------------------------------------------------------- =

nichols

11-151

Algorithm See bode.

See Also bode Bode plot

evalfr Response at single complex fr equency

freqresp Fr equency r esponse comput at ion

ltiview LTI syst em viewer

ngrid Gr id on Nichols plot

nyquist Nyquist plot

sigma Singular value plot

Open−Loop Phase (deg)

O

p

e

n

−

L

o

o

p

G

a

i

n

(

d

B

)

Nichols Charts

−500 −450 −400 −350 −300 −250 −200 −150 −100 −50

−40

−30

−20

−10

0

10

20

30

40

6 dB

3 dB

1 dB

0.5 dB

0.25 dB

0 dB

−1 dB

−3 dB

−6 dB

−12 dB

−20 dB

−40 dB

norm

11-152

11nor m

Purpose Comput e LTI model nor ms

Syntax norm(sys)

norm(sys,2)

norm(sys,inf)

norm(sys,inf,tol)

[ninf,fpeak] = norm(sys)

Description norm comput es t he or nor m of a cont inuous- or discr et e-t ime LTI model.

H

2

Norm

The nor m of a st able cont inuous syst em wit h t r ansfer funct ion , is t he

r oot -mean-squar e of it s impulse r esponse, or equivalent ly

This nor m measur es t he st eady-st at e covar iance (or power ) of t he out put

r esponse t o unit whit e noise input s .

Infinity Norm

The infinit y nor m is t he peak gain of t he fr equency r esponse, t hat is,

wher e denot es t he lar gest singular value of a mat r ix.

H

2

L

∞

H

2

H s ( )

H

2

1

2π

------ Tr ace H j ω ( )

H

H j ω ( ) ( ) ω d

∞ –

∞

∫

=

y Hw = w

H

2

2

E y t ( )

T

y t ( ) { } ,

t ∞ →

lim = E w t ( )w τ ( )

T

( ) δ t τ – ( )I =

H s ( )

∞

max H j ω ( ) =

ω

(SISO case)

H s ( )

∞

max σ

max

H j ω ( ) ( ) =

ω

(MIMO case)

σ

max

. ( )

norm

11-153

The discr et e-t ime count er par t is

Usage norm(sys) or norm(sys,2) bot h r et ur n t he nor m of t he TF, SS, or ZPK

model sys. This nor m is infinit e in t he following cases:

•sys is unst able.

•sys is cont inuous and has a nonzer o feedt hr ough (t hat is, nonzer o gain at t he

fr equency ).

Not e t hat norm(sys) pr oduces t he same r esult as

sqrt(trace(covar(sys,1)))

norm(sys,inf) comput es t he infinit y nor m of any t ype of LTI model sys. This

nor m is infinit e if sys has poles on t he imaginar y axis in cont inuous t ime, or on

t he unit cir cle in discr et e t ime.

norm(sys,inf,tol) set s t he desir ed r elat ive accur acy on t he comput ed

infinit y nor m (t he default value is tol=1e–2).

[ninf,fpeak] = norm(sys,inf) also r et ur ns t he fr equency fpeak wher e t he

gain achieves it s peak value.

Example Consider t he discr et e-t ime t r ansfer funct ion

wit h sample t ime 0.1 second. Comput e it s nor m by t yping

H = tf([1 –2.841 2.875 –1.004],[1 –2.417 2.003 –0.5488],0.1)

norm(H)

ans =

1.2438

H z ( )

∞

max σ

max

H e

j θ

( ) ( ) =

θ 0 π , [ ] ∈

H

2

ω ∞ =

H z ( )

z

3

2.841z

2

– 2.875z 1.004 – +

z

3

2.417z

2

– 2.003z 0.5488 – +

--------------------------------------------------------------------------------- =

H

2

norm

11-154

Comput e it s infinit y nor m by t yping

[ninf,fpeak] = norm(H,inf)

ninf =

2.5488

fpeak =

3.0844

These values ar e confir med by t he Bode plot of .

bode(H)

The gain indeed peaks at appr oximat ely 3 r ad/sec and it s peak value in dB is

found by t yping

20*log10(ninf)

H z ( )

Frequency (rad/sec)

P

h

a

s

e

(

d

e

g

)

;

M

a

g

n

i

t

u

d

e

(

d

B

)

Bode Diagrams

−5

0

5

10

10

−1

10

0

10

1

10

2

−400

−300

−200

−100

0

100

200

norm

11-155

MATLAB r et ur ns

ans =

8.1268

Algorithm norm uses t he same algor it hm as covar for t he nor m, and t he algor it hm of

[1] for t he infinit y nor m. sys is fir st conver t ed t o st at e space.

See Also bode Bode plot

freqresp Fr equency r esponse comput at ion

sigma Singular value plot

References [1] Br uisma, N.A. and M. St einbuch, “A Fast Algor it hm t o Comput e t he

-Nor m of a Tr ansfer Funct ion Mat r ix,” S ystem Control Letters, 14 (1990),

pp. 287–293.

H

2

H

∞

nyquist

11-156

11nyquist

Purpose Comput e Nyquist fr equency r esponse of LTI models

Syntax nyquist(sys)

nyquist(sys,w)

nyquist(sys1,sys2,...,sysN)

nyquist(sys1,sys2,...,sysN,w)

nyquist(sys1,'PlotStyle1',...,sysN,'PlotStyleN')

[re,im,w] = nyquist(sys)

[re,im] = nyquist(sys,w)

Description nyquist calculat es t he Nyquist fr equency r esponse of LTI models. When

invoked wit hout left -hand ar gument s, nyquist pr oduces a Nyquist plot on t he

scr een. Nyquist plot s ar e used t o analyze syst em pr oper t ies including gain

mar gin, phase mar gin, and st abilit y.

nyquist(sys) plot s t he Nyquist r esponse of an ar bit r ar y LTI model sys. This

model can be cont inuous or discr et e, and SISO or MIMO. In t he MIMO case,

nyquist pr oduces an ar r ay of Nyquist plot s, each plot showing t he r esponse of

one par t icular I/O channel. The fr equency point s ar e chosen aut omat ically

based on t he syst em poles and zer os.

nyquist(sys,w) explicit ly specifies t he fr equency r ange or fr equency point s t o

be used for t he plot . To focus on a par t icular fr equency int er val [wmin,wmax],

set w = {wmin,wmax}. To use par t icular fr equency point s, set w t o t he vect or of

desir ed fr equencies. Use logspace t o gener at e logar it hmically spaced

fr equency vect or s. Fr equencies should be specified in r ad/sec.

nyquist(sys1,sys2,...,sysN) or nyquist(sys1,sys2,...,sysN,w)

super imposes t he Nyquist plot s of sever al LTI models on a single figur e. All

syst ems must have t he same number of input s and out put s, but may ot her wise

be a mix of cont inuous- and discr et e-t ime syst ems. You can also specify a

dist inct ive color , linest yle, and/or mar ker for each syst em plot wit h t he synt ax

nyquist(sys1,'PlotStyle1',...,sysN,'PlotStyleN')

See bode for an example.

nyquist

11-157

When invoked wit h left -hand ar gument s

[re,im,w] = nyquist(sys)

[re,im] = nyquist(sys,w)

r et ur n t he r eal and imaginar y par t s of t he fr equency r esponse at t he

fr equencies w (in r ad/sec). re and im ar e 3-D ar r ays wit h t he fr equency as last

dimension (see “Ar gument s” below for det ails).

Remark If sys is an FRD model, nyquist(sys,w), w can only include fr equencies in

sys.frequency.

Arguments The out put ar gument s re and im ar e 3-D ar r ays wit h dimensions

For SISO syst ems, t he scalar s re(1,1,k) and im(1,1,k) ar e t he r eal and

imaginar y par t s of t he r esponse at t he fr equency .

For MIMO syst ems wit h t r ansfer funct ion , re(:,:,k) and im(:,:,k)

give t he r eal and imaginar y par t s of (bot h ar r ays wit h as many r ows

as out put s and as many columns as input s). Thus,

wher e is t he t r ansfer funct ion fr om input t o out put .

Example Plot t he Nyquist r esponse of t he syst em

number of out put s ( ) number of input s ( ) × lengt h of w ( ) ×

ω

k

w(k) =

re(1,1,k) Re h j ω

k

( ) ( ) =

im(1,1,k) Im h j ω

k

( ) ( ) =

H s ( )

H j ω

k

( )

re(i,j,k) Re h

i j

j ω

k

( ) ( ) =

im(i,j,k) Im h

i j

j ω

k

( ) ( ) =

h

i j

j i

nyquist

11-158

H = tf([2 5 1],[1 2 3])

nyquist(H)

See Also bode Bode plot

evalfr Response at single complex fr equency

freqresp Fr equency r esponse comput at ion

ltiview LTI syst em viewer

nichols Nichols plot

sigma Singular value plot

H s ( )

2s

2

5s 1 + +

s

2

2s 3 + +

------------------------------- =

Real Axis

I

m

a

g

i

n

a

r

y

A

x

i

s

Nyquist Diagrams

−1 −0.5 0 0.5 1 1.5 2 2.5 3

−2

−1.5

−1

−0.5

0

0.5

1

1.5

2

obsv

11-159

11obsv

Purpose For m t he obser vabilit y mat r ix

Syntax Ob = obsv(A,B)

Ob = obsv(sys)

Description obsv comput es t he obser vabilit y mat r ix for st at e-space syst ems. For an n-by-n

mat r ix A and a p-by-n mat r ix C, obsv(A,C) r et ur ns t he obser vabilit y mat r ix

wit h n columns and np r ows.

Ob = obsv(sys) calculat es t he obser vabilit y mat r ix of t he st at e-space model

sys. This synt ax is equivalent t o execut ing

Ob = obsv(sys.A,sys.C)

The model is obser vable if Ob has full r ank n.

Example Det er mine if t he pair

A =

1 1

4 –2

C =

1 0

0 1

is obser vable. Type

Ob = obsv(A,C);

% Number of unobservable states

unob = length(A)–rank(Ob)

Ob

C

CA

CA

2

:

CA

n 1 –

=

obsv

11-160

MATLAB r esponds wit h

unob =

0

See Also obsvf Comput e t he obser vabilit y st air case for m

obsvf

11-161

11obsvf

Purpose Comput e t he obser vabilit y st air case for m

Syntax [Abar,Bbar,Cbar,T,k] = obsvf(A,B,C)

[Abar,Bbar,Cbar,T,k] = obsvf(A,B,C,tol)

Description If t he obser vabilit y mat r ix of (A,C) has r ank , wher e n is t he size of A, t hen

t her e exist s a similar it y t r ansfor mat ion such t hat

wher e is unit ar y and t he t r ansfor med syst em has a staircase for m wit h t he

unobser vable modes, if any, in t he upper left cor ner .

wher e is obser vable, and t he eigenvalues of ar e t he unobser vable

modes.

[Abar,Bbar,Cbar,T,k] = obsvf(A,B,C) decomposes t he st at e-space syst em

wit h mat r ices A, B, and C int o t he obser vabilit y st air case for m Abar, Bbar, and

Cbar, as descr ibed above. T is t he similar it y t r ansfor mat ion mat r ix and k is a

vect or of lengt h n, wher e n is t he number of st at es in A. Each ent r y of k

r epr esent s t he number of obser vable st at es fact or ed out dur ing each st ep of t he

t r ansfor mat ion mat r ix calculat ion [1]. The number of nonzer o element s in k

indicat es how many it er at ions wer e necessar y t o calculat e T, and sum(k) is t he

number of st at es in , t he obser vable por t ion of Abar.

obsvf(A,B,C,tol) uses t he t oler ance tol when calculat ing t he obser vable/

unobser vable subspaces. When t he t oler ance is not specified, it default s t o

10*n*norm(a,1)*eps.

r n ≤

A T AT

T

, = B T B , = C CT

T

=

T

A

A

n o

A

12

0 A

o

, =

B

B

n o

B

o

, = C 0 C

o

=

C

o

A

o

, ( ) A

n o

A

o

obsvf

11-162

Example For m t he obser vabilit y st air case for m of

A =

1 1

4 –2

B =

1 –1

1 –1

C =

1 0

0 1

by t yping

[Abar,Bbar,Cbar,T,k] = obsvf(A,B,C)

Abar =

1 1

4 –2

Bbar =

1 1

1 –1

Cbar =

1 0

0 1

T =

1 0

0 1

k =

2 0

Algorithm obsvf is an M-file t hat implement s t he St air case Algor it hm of [1] by calling

ctrbf and using dualit y.

See Also ctrbf Comput e t he cont r ollabilit y st air case for m

obsv Calculat e t he obser vabilit y mat r ix

References [1] Rosenbr ock, M.M., S tate-S pace and Multivariable Theory, J ohn Wiley,

1970.

ord2

11-163

11or d2

Purpose Gener at e cont inuous second-or der syst ems

Syntax [A,B,C,D] = ord2(wn,z)

[num,den] = ord2(wn,z)

Description [A,B,C,D] = ord2(wn,z) gener at es t he st at e-space descr ipt ion (A,B,C,D) of

t he second-or der syst em

given t he nat ur al fr equency wn ( ) and damping fact or z ( ). Use ss t o t ur n

t his descr ipt ion int o a st at e-space object .

[num,den] = ord2(wn,z) r et ur ns t he numer at or and denominat or of t he

second-or der t r ansfer funct ion. Use tf t o for m t he cor r esponding t r ansfer

funct ion object .

Example To gener at e an LTI model of t he second-or der t r ansfer funct ion wit h damping

fact or and nat ur al fr equency , t ype

[num,den] = ord2(2.4,0.4)

num =

1

den =

1.0000 1.9200 5.7600

sys = tf(num,den)

Transfer function:

1

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

s^2 + 1.92 s + 5.76

See Also rmodel, rss Gener at e r andom st able cont inuous models

ss Cr eat e a st at e-space LTI model

tf Cr eat e a t r ansfer funct ion LTI model

h s ( )

1

s

2

2ζω

n

s ω

n

2

+ +

--------------------------------------------- =

ω

n

ζ

ζ 0.4 = ω

n

2.4 r ad/sec. =

pade

11-164

11pade

Purpose Comput e t he Padé appr oximat ion of models wit h t ime delays

Syntax [num,den] = pade(T,N)

pade(T,N)

sysx = pade(sys,N)

sysx = pade(sys,NI,NO,Nio)

Description pade appr oximat es t ime delays by r at ional LTI models. Such appr oximat ions

ar e useful t o model t ime delay effect s such as t r anspor t and comput at ion

delays wit hin t he cont ext of cont inuous-t ime syst ems. The Laplace t r ansfor m

of an t ime delay of seconds is . This exponent ial t r ansfer funct ion

is appr oximat ed by a r at ional t r ansfer funct ion using t he Padé appr oximat ion

for mulas [1].

[num,den] = pade(T,N) r et ur ns t he Nt h-or der (diagonal) Padé appr oximat ion

of t he cont inuous-t ime I/O delay in t r ansfer funct ion for m. The r ow

vect or s num and den cont ain t he numer at or and denominat or coefficient s in

descending power s of . Bot h ar e Nt h-or der polynomials.

When invoked wit hout out put ar gument s,

pade(T,N)

plot s t he st ep and phase r esponses of t he Nt h-or der Padé appr oximat ion and

compar es t hem wit h t he exact r esponses of t he model wit h I/O delay T. Not e

t hat t he Padé appr oximat ion has unit gain at all fr equencies.

sysx = pade(sys,N) pr oduces a delay-fr ee appr oximat ion sysx of t he

cont inuous delay syst em sys. All delays ar e r eplaced by t heir Nt h-or der Padé

appr oximat ion. See “Time Delays” on page 2-45 for det ails on LTI models wit h

delays.

T s T – ( ) exp

sT – ( ) exp

s

pade

11-165

sysx = pade(sys,NI,NO,Nio) specifies independent appr oximat ion or der s for

each input , out put , and I/O delay. These appr oximat ion or der s ar e given by t he

ar r ays of int eger s NI, NO, and Nio, such t hat :

•NI(j) is t he appr oximat ion or der for t he j-t h input channel.

•NO(i) is t he appr oximat ion or der for t he i-t h out put channel.

•Nio(i,j) is t he appr oximat ion or der for t he I/O delay fr om input j t o out put

i.

You can use scalar values t o specify unifor m appr oximat ion or der s, and [] if

t her e ar e no input , out put , or I/O delays.

pade

11-166

Example Comput e a t hir d-or der Padé appr oximat ion of a 0.1 second I/O delay and

compar e t he t ime and fr equency r esponses of t he t r ue delay and it s

appr oximat ion. To do t his, t ype

pade(0.1,3)

Limitations High-or der Padé appr oximat ions pr oduce t r ansfer funct ions wit h clust er ed

poles. Because such pole configur at ions t end t o be ver y sensit ive t o

per t ur bat ions, Padé appr oximat ions wit h or der N>10 should be avoided.

See Also c2d Discr et izat ion of cont inuous syst em

delay2z Changes t r ansfer funct ions of discr et e-t ime LTI models

wit h delays t o r at ional funct ions or absor bs FRD delays

int o t he fr equency r esponse phase infor mat ion

0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2

−1

−0.5

0

0.5

1

1.5

Time (secs)

A

m

p

l

i

t

u

d

e

Step response of 3rd−order Pade approximation

10

1

10

2

10

3

−1000

−800

−600

−400

−200

0

Frequency (rad/s)

P

h

a

s

e

(

d

e

g

.

)

Phase response

pade

11-167

References [1] Golub, G. H. and C. F. Van Loan, Matrix Computations, J ohns Hopkins

Univer sit y Pr ess, Balt imor e, 1989, pp. 557–558.

parallel

11-168

11par allel

Purpose Par allel connect ion of t wo LTI models

Syntax sys = parallel(sys1,sys2)

sys = parallel(sys1,sys2,inp1,inp2,out1,out2)

Description parallel connect s t wo LTI models in par allel. This funct ion accept s any t ype

of LTI model. The t wo syst ems must be eit her bot h cont inuous or bot h discr et e

wit h ident ical sample t ime. St at ic gains ar e neut r al and can be specified as

r egular mat r ices.

sys = parallel(sys1,sys2) for ms t he basic par allel connect ion shown below.

This command is equivalent t o t he dir ect addit ion

sys = sys1 + sys2

(See “Addit ion and Subt r act ion” on page 3-11 for det ails on LTI syst em

addit ion.)

sys1

sys2

u y

+

+

sys

parallel

11-169

sys = parallel(sys1,sys2,inp1,inp2,out1,out2) for ms t he mor e gener al

par allel connect ion.

The index vect or s inp1 and inp2 specify which input s of sys1 and which

input s of sys2 ar e connect ed. Similar ly, t he index vect or s out1 and out2

specify which out put s of sys1 and which out put s of sys2 ar e summed.

The r esult ing model sys has as input s and as

out put s.

Example See “St eady-St at e Design” on page 9-51 for an example.

See Also append Append LTI syst ems

feedback Feedback connect ion

series Ser ies connect ion

sys1

sys2

+

+

sys

u

u

2

u

1

y

2

y

1

y

z

1

v

1

z

2

v

2

u

1

u

2

y

1

y

2

v

1

u v

2

; ; [ ] z

1

y z

2

; ; [ ]

place

11-170

11place

Purpose Pole placement design

Syntax K = place(A,B,p)

[K,prec,message] = place(A,B,p)

Description Given t he single- or mult i-input syst em

and a vect or p of desir ed self-conjugat e closed-loop pole locat ions, place

comput es a gain mat r ix K such t hat t he st at e feedback places t he

closed-loop poles at t he locat ions p. In ot her wor ds, t he eigenvalues of

mat ch t he ent r ies of p (up t o t he or der ing).

K = place(A,B,p) comput es a feedback gain mat r ix K t hat achieves t he

desir ed closed-loop pole locat ions p, assuming all t he input s of t he plant ar e

cont r ol input s. The lengt h of p must mat ch t he r ow size of A. place wor ks for

mult i-input syst ems and is based on t he algor it hm fr om [1]. This algor it hm

uses t he ext r a degr ees of fr eedom t o find a solut ion t hat minimizes t he

sensit ivit y of t he closed-loop poles t o per t ur bat ions in or .

[K,prec,message] = place(A,B,p) also r et ur ns prec, an est imat e of how

closely t he eigenvalues of mat ch t he specified locat ions p (prec

measur es t he number of accur at e decimal digit s in t he act ual closed-loop

poles). If some nonzer o closed-loop pole is mor e t han 10% off fr om t he desir ed

locat ion, message cont ains a war ning message.

You can also use place for est imat or gain select ion by t r ansposing t he A mat r ix

and subst it ut ing C' for B.

l = place(A',C',p).'

Example Consider a st at e-space syst em (a,b,c,d) wit h t wo input s, t hr ee out put s, and

t hr ee st at es. You can comput e t he feedback gain mat r ix needed t o place t he

closed-loop poles at p = [1.1 23 5.0] by

p = [1 1.23 5.0];

K = place(a,b,p)

x

·

Ax Bu + =

u Kx – =

A B K –

A B

A BK –

place

11-171

Algorithm place uses t he algor it hm of [1] which, for mult i-input syst ems, opt imizes t he

choice of eigenvect or s for a r obust solut ion. We r ecommend place r at her t han

acker even for single-input syst ems.

In high-or der pr oblems, some choices of pole locat ions r esult in ver y lar ge

gains. The sensit ivit y pr oblems at t ached wit h lar ge gains suggest caut ion in

t he use of pole placement t echniques. See [2] for r esult s fr om numer ical t est ing.

See Also acker Pole placement using Acker mann’s for mula

lqr St at e-feedback LQ r egulat or design

rlocus, rlocfind Root locus design

References [1] Kaut sky, J . and N.K. Nichols, “Robust Pole Assignment in Linear St at e

Feedback,” Int. J . Control, 41 (1985), pp. 1129–1155.

[2] Laub, A.J . and M. Wet t e, Algorithms and S oftware for Pole Assignment and

Observers, UCRL-15646 Rev. 1, EE Dept ., Univ. of Calif., Sant a Bar bar a, CA,

Sept . 1984.

pole

11-172

11pole

Purpose Comput e t he poles of an LTI syst em

Syntax p = pole(sys)

Description pole comput es t he poles p of t he SISO or MIMO LTI model sys.

Algorithm For st at e-space models, t he poles ar e t he eigenvalues of t he mat r ix, or t he

gener alized eigenvalues of in t he descr ipt or case.

For SISO t r ansfer funct ions or zer o-pole-gain models, t he poles ar e simply t he

denominat or r oot s (see roots).

For MIMO t r ansfer funct ions (or zer o-pole-gain models), t he poles ar e

comput ed as t he union of t he poles for each SISO ent r y. If some columns or

r ows have a common denominat or , t he r oot s of t his denominat or ar e count ed

only once.

Limitations Mult iple poles ar e numer ically sensit ive and cannot be comput ed t o high

accur acy. A pole wit h mult iplicit y t ypically gives r ise t o a clust er of

comput ed poles dist r ibut ed on a cir cle wit h cent er and r adius of or der

See Also damp Damping and nat ur al fr equency of syst em poles

esort, dsort Sor t syst em poles

pzmap Pole-zer o map

zero Comput e (t r ansmission) zer os

A

A λE –

λ m

λ

ρ eps

1 m ⁄

≈

pzmap

11-173

11pzmap

Purpose Comput e t he pole-zer o map of an LTI model

Syntax pzmap(sys)

[p,z] = pzmap(sys)

Description pzmap(sys) plot s t he pole-zer o map of t he cont inuous- or discr et e-t ime LTI

model sys. For SISO syst ems, pzmap plot s t he t r ansfer funct ion poles and zer os.

For MIMO syst ems, it plot s t he syst em poles and t r ansmission zer os. The poles

ar e plot t ed as x’s and t he zer os ar e plot t ed as o’s.

When invoked wit hout left -hand ar gument s,

[p,z] = pzmap(sys)

r et ur ns t he syst em poles and (t r ansmission) zer os in t he column vect or s p and

z. No plot is dr awn on t he scr een.

You can use t he funct ions sgrid or zgrid t o plot lines of const ant damping r at io

and nat ur al fr equency in t he - or -plane. s z

pzmap

11-174

Example Plot t he poles and zer os of t he cont inuous-t ime syst em.

H = tf([2 5 1],[1 2 3])

pzmap(H)

Algorithm pzmap uses a combinat ion of pole and zero.

See Also damp Damping and nat ur al fr equency of syst em poles

esort, dsort Sor t syst em poles

pole Comput e syst em poles

rlocus Root locus

H s ( )

2s

2

5s 1 + +

s

2

2s 3 + +

------------------------------- =

−2.5 −2 −1.5 −1 −0.5 0

−1.5

−1

−0.5

0

0.5

1

1.5

Real Axis

I

m

a

g

A

x

i

s

Pole−zero map

pzmap

11-175

sgrid, zgrid Plot lines of const ant damping and nat ur al fr equency

zero Comput e syst em (t r ansmission) zer os

reg

11-176

11r eg

Purpose For m r egulat or given st at e-feedback and est imat or gains

Syntax rsys = reg(sys,K,L)

rsys = reg(sys,K,L,sensors,known,controls)

Description rsys = reg(sys,K,L) for ms a dynamic r egulat or or compensat or rsys given a

st at e-space model sys of t he plant , a st at e-feedback gain mat r ix K, and an

est imat or gain mat r ix L. The gains K and L ar e t ypically designed using pole

placement or LQG t echniques. The funct ion reg handles bot h cont inuous- and

discr et e-t ime cases.

This synt ax assumes t hat all input s of sys ar e cont r ols, and all out put s ar e

measur ed. The r egulat or rsys is obt ained by connect ing t he st at e-feedback law

and t he st at e est imat or wit h gain mat r ix L (see estim). For a plant

wit h equat ions

t his yields t he r egulat or

u K – x =

x

·

Ax Bu + =

y Cx Du + =

x

ˆ

·

A L C – B L D – ( )K –

xˆ L y + =

u Kxˆ – =

reg

11-177

This r egulat or should be connect ed t o t he plant using positive feedback.

rsys = reg(sys,K,L,sensors,known,controls) handles mor e gener al

r egulat ion pr oblems wher e:

•The plant input s consist of cont r ols , known input s , and st ochast ic

input s .

•Only a subset of t he plant out put s is measur ed.

The index vect or s sensors, known, and controls specify , , and as

subset s of t he out put s and input s of sys. The r esult ing r egulat or uses

as input s t o gener at e t he commands (see figur e below).

u

y

xˆ

K –

Regulator

u

Plant

y

St at e

Est imat or

u u

d

w

y

y u

d

u

u

d

; y [ ]

u

xˆ

u

y

u

d K – u

Regulator rsys

Est imat or

(gain L)

(known)

(sensor s)

reg

11-178

Example Given a cont inuous-t ime st at e-space model

sys = ss(A,B,C,D)

wit h seven out put s and four input s, suppose you have designed:

• A st at e-feedback cont r oller gain K using input s 1, 2, and 4 of t he plant as

cont r ol input s

• A st at e est imat or wit h gain L using out put s 4, 7, and 1 of t he plant as

sensor s, and input 3 of t he plant as an addit ional known input

You can t hen connect t he cont r oller and est imat or and for m t he complet e

r egulat ion syst em by

controls = [1,2,4];

sensors = [4,7,1];

known = [3];

regulator = reg(sys,K,L,sensors,known,controls)

See Also estim For m st at e est imat or given est imat or gain

kalman Kalman est imat or design

lqgreg For m LQG r egulat or

lqr, dlqr St at e-feedback LQ r egulat or

place Pole placement

reshape

11-179

11r eshape

Purpose Change t he shape of an LTI ar r ay

Syntax sys = reshape(sys,s1,s2,...,sk)

sys = reshape(sys,[s1 s2 ... sk])

Description sys = reshape(sys,s1,s2,...,sk) (or , equivalent ly, sys = reshape(sys,[s1

s2 ... sk])) r eshapes t he LTI ar r ay sys int o an s1-by-s2-by...-sk ar r ay of LTI

models. Equivalent ly, sys = reshape(sys,[s1 s2 ... sk]) r eshapes t he LTI

ar r ay sys int o an s1-by-s2-by...-sk ar r ay of LTI models. Wit h eit her synt ax,

t her e must be s1*s2*...*sk models in sys t o begin wit h.

Example sys = rss(4,1,1,2,3);

size(sys)

2x3 array of state-space models

Each model has 1 output, 1 input, and 4 states.

sys1 = reshape(sys,6);

size(sys1)

6x1 array of state-space models

Each model has 1 output, 1 input, and 4 states.

See Also ndims Pr ovide t he number of dimensions of an LTI ar r ay

size Pr ovide t he lengt hs of each dimension of an LTI ar r ay

rlocfind

11-180

11r locfind

Purpose Select feedback gain fr om r oot locus plot

Syntax [k,poles] = rlocfind(sys)

[k,poles] = rlocfind(sys,p)

Description rlocfind r et ur ns t he feedback gain associat ed wit h a par t icular set of poles on

t he r oot locus. rlocfind wor ks wit h bot h cont inuous- and discr et e-t ime SISO

syst ems.

[k,poles] = rlocfind(sys) is used for int er act ive gain select ion fr om t he

r oot locus plot of t he SISO syst em sys gener at ed by rlocus. The funct ion

rlocfind put s up a cr osshair cur sor on t he r oot locus plot t hat you use t o select

a par t icular pole locat ion. The r oot locus gain associat ed wit h t his point is

r et ur ned in k and t he column vect or poles cont ains t he closed-loop poles for

t his gain. To use t his command, t he r oot locus of t he SISO open-loop model sys

must be pr esent in t he cur r ent figur e window.

[k,poles] = rlocfind(sys,p) t akes a vect or p of desir ed r oot locat ions and

comput es a r oot locus gain for each of t hese locat ions (t hat is, a gain for which

one of t he closed-loop r oot s is near t he desir ed locat ion). The jt h ent r y of t he

vect or k gives t he comput ed gain for t he pole locat ion p(j), and t he jt h column

of t he mat r ix poles list s t he r esult ing closed-loop poles.

Example Det er mine a feedback gain such t hat t he closed-loop poles of t he syst em

have damping r at io ζ = 0.707.

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

rlocus(h) % Plot the root locus

k = rlocfind(h) % Select pole with ζ=.707 graphically

Algorithm [k,poles] = rlocfind(sys,p) calculat es t he gain k fr om t he following

for mula.

k = abs(d(p)/n(p))

h s ( )

2s

2

5s 1 + +

s

2

2s 3 + +

------------------------------- =

rlocfind

11-181

wher e p is t he complex point you supply as an input ar gument t o rlocfind (or

wher e you point t o wit h t he mouse), and n and d ar e r espect ively t he numer at or

and denominat or polynomials of t he t r ansfer funct ion associat ed wit h sys. The

poles associat ed wit h t he gain k ar e t hen comput ed as

poles = roots(k*n(s) + d(s))

Limitations rlocfind assumes t hat a r oot locus is in t he cur r ent figur e window when t his

funct ion is called wit hout second input ar gument .

See Also rlocus Plot r oot locus

rltool Root Locus Design GUI

References [1] Ogot a, K., Modern Control Engineering, Pr ent ice Hall, 1970.

rlocus

11-182

11r locus

Purpose Evans r oot locus

Syntax rlocus(sys)

rlocus(sys,k)

[r,k] = rlocus(sys)

r = rlocus(sys,k)

Description rlocus comput es t he Evans r oot locus of a SISO open-loop model. The r oot

locus gives t he closed-loop pole t r aject or ies as a funct ion of t he feedback gain

(assuming negat ive feedback). Root loci ar e used t o st udy t he effect s of

var ying feedback gains on closed-loop pole locat ions. In t ur n, t hese locat ions

pr ovide indir ect infor mat ion on t he t ime and fr equency r esponses.

rlocus(sys) calculat es and plot s t he r oot locus of t he open-loop SISO model

sys. This funct ion can be applied t o any of t he following negative feedback loops

by set t ing sys appr opr iat ely.

If sys has t r ansfer funct ion

k

G

k

G

F k

sys = G sys = F * G

C

k

G

sys = G * C

–

–

–

+

+

+

h s ( )

n s ( )

d s ( )

----------- =

rlocus

11-183

t he closed-loop poles ar e t he r oot s of

rlocus adapt ively select s a set of posit ive gains t o pr oduce a smoot h plot .

Alt er nat ively,

rlocus(sys,k)

uses t he user -specified vect or k of gains t o plot t he r oot locus.

When invoked wit h out put ar gument s,

[r,k] = rlocus(sys)

r = rlocus(sys,k)

r et ur n t he vect or k of select ed gains and t he complex r oot locat ions r for t hese

gains. The mat r ix r has length(k) columns and it s jt h column list s t he

closed-loop r oot s for t he gain k(j).

Example Find and plot t he r oot -locus of t he following syst em.

d s ( ) k n s ( ) + 0 =

k

rlocus

11-184

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

rlocus(h)

For examples, see “Root Locus Design” on page 9-9 and “Har d-Disk Read/Wr it e

Head Cont r oller ” on page 9-20.

See Also rlocfind Select gain fr om r oot locus plot

rltool Root Locus Design GUI

pole Syst em poles

pzmap Pole-zer o map

h s ( )

2s

2

5s 1 + +

s

2

2s 3 + +

------------------------------- =

−3 −2.5 −2 −1.5 −1 −0.5 0 0.5 1

−1.5

−1

−0.5

0

0.5

1

1.5

Real Axis

I

m

a

g

A

x

i

s

rltool

11-185

11r lt ool

Purpose Init ialize t he Root Locus Design GUI

Syntax rltool

rltool(sys)

rltool(sys,comp)

rltool(sys,comp,LocationFlag,FeedbackSign)

Description When invoked wit hout input ar gument s, rltool init ializes a new Root Locus

Design GUI for int er act ive compensat or design. This GUI allows you t o design

a single-input /single-out put (SISO) compensat or using r oot locus t echniques.

rltool

11-186

The Root Locus Design GUI looks like t his.

Edit the gain set

point to change the

closed-loop pole

locations.

Compensator descrip-

tion: The default

compensator is K=1.

Root locus toolbar buttons to

drag, add, or erase compensa-

tor poles and zeros, or to drag

the closed-loop poles

Plot region to display

the root locus

Toggle between

positive/negative

feedback.

Save/retrieve root locus axes

limits and aspect ratios.

Status bar for providing

information

These are the main menus for importing/exporting of

models, and editing them. You can also perform discrete/

continuous conversion.

The feedback structure: Click on K to

view/change the compensator, and on P,

F, or H to view the design model

characteristics.

Zoom into or out of

the root locus plot.

Click on these boxes to open system

response analysis tools.

rltool

11-187

This t ool can be applied t o SISO LTI syst ems whose feedback st r uct ur e is in

one of t he following t wo configur at ions.

In eit her configur at ion, F is a pr e-filt er , P is t he plant model, H is t he sensor

dynamics, and K is t he compensat or t o be designed. In t er ms of t he GUI design

pr ocedur e, once you specify t hem, F, P, and H ar e fixed in t he feedback

st r uct ur e. This t r iple, along wit h t he feedback st r uct ur e, is called t he design

model.

A design model can be const r uct ed for t he GUI by select ing t he Import Model

menu it em fr om t he Fi le menu of t he Root Locus Design GUI. Once you select

t he it em, t he Import De si gn Model window opens. You can t hen impor t SISO

LTI models t hat have been cr eat ed wit h ss, tf, or zpk in your wor kspace or on

your disk (or SISO LTI blocks cont ained in open or saved Simulink models) int o

F, P, and H. Ot her wise, you can specify your design model by defining F, P, and

H manually wit h LTI models cr eat ed using ss, tf, or zpk in t he t ext boxes

pr ovided on t he Import De si gn Mode l window.

If sys is any SISO LTI object (cr eat ed wit h ss, tf, or zpk) t hat exist s in t he

MATLAB wor kspace, rltool(sys) init ializes a Root Locus Design GUI, by

set t ing t he plant model P t o sys.

rltool(sys,comp) also init ializes a Root Locus Design GUI for t he plant model

sys. In addit ion, t he r oot locus compensat or is init ialized t o comp, wher e comp

is any SISO LTI object t hat exist s in t he MATLAB wor kspace.

When eit her t he plant , or bot h t he plant and t he compensat or ar e pr ovided as

ar gument s t o rltool, t he r oot locus of t he closed-loop poles and t heir locat ions

for t he cur r ent compensat or gain ar e dr awn on t he Root Locus Design GUI. The

closed-loop model is gener at ed by placing t he compensat or (comp) and plant

rltool

11-188

model (sys) in t he for war d loop of a negat ive unit y feedback syst em, as shown

in t he diagr am below.

In t his case, F and H ar e t aken t o be 1, while P is sys. If you want t o include F

and H in t he design model aft er loading rltool(sys) or rltool(sys,comp),

select t he Import Mode l menu it em fr om t he Fi le menu of t he Root Locus

Design GUI t o load F and H.

rltool(sys,comp,LocationFlag,FeedbackSign) allows you t o over r ide t he

default compensat or locat ion and feedback sign. LocationFlag can be eit her 1

or 2:

•LocationFlag = 1: Places t he compensat or in t he for war d pat h (t his is t he

default )

•LocationFlag = 2: Places t he compensat or in t he feedback pat h

•FeedbackSign can be eit her 1 or -1:

- FeedbackSign = —1 for negat ive feedback (t his is t he default )

- FeedbackSign = 1 for posit ive feedback

See Also rlocus Plot r oot locus

rlocfind Select gain fr om t he r oot locus plot

sys

comp

+_

y

u

rmodel, rss

11-189

11r model, r ss

Purpose Gener at e st able r andom cont inuous t est models

Syntax sys = rss(n)

sys = rss(n,p)

sys = rss(n,p,m)

sys = r ss(n,p,m,s1,...,sn)

[num,den] = rmodel(n)

[A,B,C,D] = rmodel(n)

[A,B,C,D] = rmodel(n,p,m)

Description rss(n) pr oduces a st able r andom n-t h or der model wit h one input and one

out put and r et ur ns t he model in t he st at e-space object sys.

rss(n,p) pr oduces a r andom nt h or der st able model wit h one input and p

out put s, and rss(n,m,p) pr oduces a r andom n-t h or der st able model wit h m

input s and p out put s. The out put sys is always a st at e-space model.

rss(n,p,m,s1,...,sn)pr oduces an s1-by-...-by-sn ar r ay of r andom n-t h

or der st able st at e-space models wit h m input s and p out put s.

Use tf, frd, or zpk t o conver t t he st at e-space object sys t o t r ansfer funct ion,

fr equency r esponse, or zer o-pole-gain for m.

rmodel(n) pr oduces a r andom n-t h or der st able model and r et ur ns eit her t he

t r ansfer funct ion numer at or num and denominat or den or t he st at e-space

mat r ices A, B, C, and D, depending on t he number of out put ar gument s. The

r esult ing model always has one input and one out put .

[A,B,C,D] = rmodel(n,m,p) pr oduces a st able r andom nt h or der st at e-space

model wit h m input s and p out put s.

rmodel, rss

11-190

Example Obt ain a st able r andom cont inuous LTI model wit h t hr ee st at es, t wo input s,

and t wo out put s by t yping

sys = rss(3,2,2)

a =

x1 x2 x3

x1 –0.54175 0.09729 0.08304

x2 0.09729 –0.89491 0.58707

x3 0.08304 0.58707 –1.95271

b =

u1 u2

x1 –0.88844 –2.41459

x2 0 –0.69435

x3 –0.07162 –1.39139

c =

x1 x2 x3

y1 0.32965 0.14718 0

y2 0.59854 –0.10144 0.02805

d =

u1 u2

y1 –0.87631 –0.32758

y2 0 0

Continuous-time system.

See Also drmodel, drss Gener at e st able r andom discr et e t est models

frd Conver t LTI syst ems t o fr equency r esponse for m

tf Conver t LTI syst ems t o t r ansfer funct ion for m

zpk Conver t LTI syst ems t o zer o-pole-gain for m

series

11-191

11ser ies

Purpose Ser ies connect ion of t wo LTI models

Syntax sys = series(sys1,sys2)

sys = series(sys1,sys2,outputs1,inputs2)

Description series connect s t wo LTI models in ser ies. This funct ion accept s any t ype of

LTI model. The t wo syst ems must be eit her bot h cont inuous or bot h discr et e

wit h ident ical sample t ime. St at ic gains ar e neut r al and can be specified as

r egular mat r ices.

sys = series(sys1,sys2) for ms t he basic ser ies connect ion shown below.

This command is equivalent t o t he dir ect mult iplicat ion

sys = sys2 * sys1

See “Mult iplicat ion” on page 3-13 for det ails on mult iplicat ion of LTI models.

sys = series(sys1,sys2,outputs1,inputs2) for ms t he mor e gener al ser ies

connect ion.

sys1

sys2

u

y

sys

sys1

sys2

y

1

u

2

v

2

z

1

sys

u

y

series

11-192

The index vect or s outputs1 and inputs2 indicat e which out put s of sys1 and

which input s of sys2 should be connect ed. The r esult ing model sys has

as input and as out put .

Example Consider a st at e-space syst em sys1 wit h five input s and four out put s and

anot her syst em sys2 wit h t wo input s and t hr ee out put s. Connect t he t wo

syst ems in ser ies by connect ing out put s 2 and 4 of sys1 wit h input s 1 and 2 of

sys2.

outputs1 = [2 4];

inputs2 = [1 2];

sys = series(sys1,sys2,outputs2,inputs1)

See Also append Append LTI syst ems

feedback Feedback connect ion

parallel Par allel connect ion

y

1

u

2

u

y

set

11-193

11set

Purpose Set or modify LTI model pr oper t ies

Syntax set(sys,'Property',Value)

set(sys,'Property1',Value1,'Property2',Value2,...)

set(sys,'Property')

set(sys)

Description set is used t o set or modify t he pr oper t ies of an LTI model (see “LTI Pr oper t ies”

on page 2-26 for backgr ound on LTI pr oper t ies). Like it s Handle Gr aphics

count er par t , set uses pr oper t y name/pr oper t y value pair s t o updat e pr oper t y

values.

set(sys,'Property',Value) assigns t he value Value t o t he pr oper t y of t he

LTI model sys specified by t he st r ing 'Property'. This st r ing can be t he full

pr oper t y name (for example, 'UserData') or any unambiguous case-insensit ive

abbr eviat ion (for example, 'user'). The specified pr oper t y must be compat ible

wit h t he model t ype. For example, if sys is a t r ansfer funct ion, Variable is a

valid pr oper t y but StateName is not (see “Model-Specific Pr oper t ies” on page

2-28 for det ails).

set(sys,'Property1',Value1,'Property2',Value2,...) set s mult iple

pr oper t y values wit h a single st at ement . Each pr oper t y name/pr oper t y value

pair updat es one par t icular pr oper t y.

set(sys,'Property') displays admissible values for t he pr oper t y specified by

'Property'. See “Pr oper t y Values” below for an over view of legit imat e LTI

pr oper t y values.

set(sys) displays all assignable pr oper t ies of sys and t heir admissible values.

Example Consider t he SISO st at e-space model cr eat ed by

sys = ss(1,2,3,4);

You can add an input delay of 0.1 second, label t he input as torque, r eset t he

mat r ix t o zer o, and st or e it s DC gain in t he 'Userdata' pr oper t y by

set(sys,'inputd',0.1,'inputn','torque','d',0,'user',dcgain(sys))

D

set

11-194

Not e t hat set does not r equir e any out put ar gument . Check t he r esult wit h get

by t yping

get(sys)

a: 1

b: 2

c: 3

d: 0

e: []

StateName: {''}

Ts: 0

InputDelay: 0.1

OutputDelay: 0

ioDelayMatrix: 0

InputName: {'torque'}

OutputName: {''}

InputGroup: {0x2 cell}

OutputGroup: {0x2 cell}

Notes: {}

UserData: -2

Property

Values

The following t able list s t he admissible values for each LTI pr oper t y. and

denot es t he number of input s and out put s of t he under lying LTI model. For

K-dimensional LTI ar r ays, let denot e t he ar r ay dimensions.

N

u

N

y

S

1

S

2

… S

K

, , ,

set

11-195

Table 11-15: LTI Properties

Property Name Admissible Property Values

Ts •0 (zer o) for cont inuous-t ime syst ems

•Sample t ime in seconds for discr et e-t ime syst ems

•–1 or [] for discr et e syst ems wit h unspecified sample t ime

Note : Reset t ing t he sample t ime pr oper t y does not alt er t he model dat a. Use

c2d, d2c, or d2d for discr et e/cont inuous and discr et e/discr et e conver sions.

ioDelayMatrix Input /Out put delays specified wit h

•Nonnegat ive r eal number s for cont inuous-t ime models (seconds)

•Int eger s for discr et e-t ime models (number of sample per iods)

•Scalar when all I/O pair s have t he same delay

• -by- mat r ix t o specify independent delay t imes for each I/O pair

•Ar r ay of size -by- -by- -by-. . .-by- t o specify differ ent I/O delays

for each model in an LTI ar r ay.

InputDelay Input delays specified wit h

•Nonnegat ive r eal number s for cont inuous-t ime models (seconds)

•Int eger s for discr et e-t ime models (number of sample per iods)

•Scalar when or syst em has unifor m input delay

•Vect or of lengt h t o specify independent delay t imes for each input

channel

•Ar r ay of size -by- -by- -by-. . .-by- t o specify differ ent input

delays for each model in an LTI ar r ay.

N

y

N

u

N

y

N

u

S

1

S

n

N

u

1 =

N

u

N

y

N

u

S

1

S

n

set

11-196

OutputDelay Out put delays specified wit h

•Nonnegat ive r eal number s for cont inuous-t ime models (seconds)

•Int eger s for discr et e-t ime models (number of sample per iods)

•Scalar when or syst em has unifor m out put delay

•Vect or of lengt h t o specify independent delay t imes for each out put

channel

•Ar r ay of size -by- -by- -by-. . .-by- t o specify differ ent out put

delays for each model in an LTI ar r ay.

Notes St r ing, ar r ay of st r ings, or cell ar r ay of st r ings

UserData Ar bit r ar y MATLAB var iable

InputName •St r ing for single-input syst ems, for example, 'thrust'

•Cell vect or of st r ings for mult i-input syst ems (wit h as many cells as input s),

for example, {'u';'w'} for a t wo-input syst em

•Padded ar r ay of st r ings wit h as many r ows as input s, for example,

['rudder ' ; 'aileron']

OutputName Same as InputName (wit h “input ” r eplaced by “out put ”)

InputGroup Cell ar r ay. See “Input Gr oups and Out put Gr oups” on page 2-37.

OutputGroup Same as InputGroup

Table 11-15: LTI Properties (Continued)

Property Name Admissible Property Values

N

y

1 =

N

y

N

y

N

u

S

1

S

n

Table 11-16: State-Space Model Properties

Property Name Admissible Property Values

StateName Same as InputName (wit h Input r eplaced by State)

a, b, c, d, e Real-valued st at e-space mat r ices (mult idimensional ar r ays, in t he case of

LTI ar r ays) wit h compat ible dimensions for t he number of st at es, input s,

and out put s. See “The Size of LTI Ar r ay Dat a for SS Models” on page 4-18.

set

11-197

Table 11-17: TF Model Properties

Property Name Admissible Property Values

num, den • Real-valued r ow vect or s for t he coefficient s of t he numer at or or

denominat or polynomials in t he SISO case. List t he coefficient s in

descending power s of t he var iable or by default , and in ascending

power s of when t he Variable pr oper t y is set t o 'q' or 'z^–1' (see

not e below).

• -by- cell ar r ays of r eal-valued r ow vect or s in t he MIMO case, for

example,

{[1 2];[1 0 3]} for a t wo-out put /one-input t r ansfer funct ion

• -by- -by- -by- -by- -dimensional r eal-valued cell ar r ays for

MIMO LTI ar r ays

Variable • St r ing 's' (default ) or 'p' for cont inuous-t ime syst ems

• St r ing 'z' (default ), 'q', or 'z^–1' for discr et e-t ime syst ems

s z

q z

1 –

=

N

y

N

u

N

y

N

u

S

1

… S

K

Table 11-18: ZPK Model Properties

Property Name Admissible Property Values

z, p • Vect or s of zer os and poles (eit her r eal-valued or complex conjugat e pair s of

t hem) in SISO case

• -by- cell ar r ays of vect or s (ent r ies ar e r eal-valued or in complex

conjugat e pair s) in MIMO case, for example, z = {[],[–1 0]} for a model

wit h t wo input s and one out put

• -by- -by- -by- -by- -dimensional cell ar r ays for MIMO LTI

ar r ays

Variable • St r ing 's' (default ) or 'p' for cont inuous-t ime syst ems

• St r ing 'z' (default ), 'q', or 'z^–1' for discr et e-t ime syst ems

N

y

N

u

N

y

N

u

S

1

… S

K

set

11-198

Remark For discr et e-t ime t r ansfer funct ions, t he convent ion used t o r epr esent t he

numer at or and denominat or depends on t he choice of var iable (see t he tf ent r y

for det ails). Like tf, t he synt ax for set changes t o r emain consist ent wit h t he

choice of var iable. For example, if t he Variable pr oper t y is set t o 'z' (t he

default ),

set(h,'num',[1 2],'den',[1 3 4])

pr oduces t he t r ansfer funct ion

However , if you change t he Variable t o 'z^–1' (or 'q') by

set(h,'Variable','z^–1'),

t he same command

set(h,'num',[1 2],'den',[1 3 4])

now int er pr et s t he r ow vect or s [1 2] and [1 3 4] as t he polynomials

and and pr oduces:

Table 11-19: FRD Model Properties

Property Name Admissible Property Values

Frequency Real-valued vect or of lengt h -by-1, wher e is t he number of

fr equencies

Response • -by- -by- -dimensional ar r ay of complex dat a for single LTI models

• -by- -by- -by- -by- -by- -dimensional ar r ay for LTI ar r ays

Units St r ing 'rad/s' (default ), or 'Hz'

N

f

N

f

N

y

N

u

N

f

N

y

N

u

N

f

S

1

… S

K

h z ( )

z 2 +

z

2

3z 4 + +

---------------------------- =

1 2z

1 –

+

1 3z

1 –

4z

2 –

+ +

set

11-199

Because t he r esult ing t r ansfer funct ions ar e differ ent , make sur e t o use t he

convent ion consist ent wit h your choice of var iable.

See Also get Access/quer y LTI model pr oper t ies

frd Specify a fr equency r esponse dat a model

ss Specify a st at e-space model

tf Specify a t r ansfer funct ion

zpk Specify a zer o-pole-gain model

h z

1 –

( )

1 2z

1 –

+

1 3z

1 –

4z

2 –

+ +

--------------------------------------- - z h z ( ) = =

sgrid

11-200

11sgrid

Purpose Gener at e an s-plane gr id of const ant damping fact or s and nat ur al fr equencies

Syntax sgrid

sgrid(z,wn)

Description sgrid gener at es a gr id of const ant damping fact or s fr om zer o t o one in st eps of

0.1 and nat ur al fr equencies fr om zer o t o 10 r ad/sec in st eps of one r ad/sec, and

plot s t he gr id over t he cur r ent axis. If t he cur r ent axis cont ains a cont inuous

s-plane r oot locus diagr am or pole-zer o map, sgrid dr aws t he gr id over t he plot .

sgrid(z,wn) plot s a gr id of const ant damping fact or and nat ur al fr equency

lines for t he damping fact or s and nat ur al fr equencies in t he vect or s z and wn,

r espect ively. If t he cur r ent axis cont ains a cont inuous s-plane r oot locus

diagr am or pole-zer o map, sgrid(z,wn) dr aws t he gr id over t he plot .

Example Plot s-plane gr id lines on t he r oot locus for t he following syst em.

You can do t his by t yping

H = tf([2 5 1],[1 2 3])

Transfer function:

2 s^2 + 5 s + 1

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

s^2 + 2 s + 3

rlocus(H)

sgrid

H s ( )

2s

2

5s 1 + +

s

2

2s 3 + +

------------------------------- =

sgrid

11-201

Limitations sgrid plot s t he gr id over t he cur r ent axis r egar dless of whet her t he axis

cont ains a r oot locus diagr am or pole-zer o map. Ther efor e, if t he cur r ent axes

cont ains, for example, a st ep r esponse, you may super impose a meaningless

s-plane gr id over t he plot . In addit ion, sgrid does not r escale t he axis limit s of

t he cur r ent axis. Ther efor e, t he s-plane gr id may not appear in t he plot if t he

left half of t he s-plane is not encompassed by t he axis limit s.

See Also pzmap Plot pole-zer o map

rlocus Plot r oot locus

zgrid Gener at e z-plane gr id lines

−3 −2.5 −2 −1.5 −1 −0.5 0 0.5 1

−1.5

−1

−0.5

0

0.5

1

1.5

Real Axis

I

m

a

g

A

x

i

s

sigma

11-202

11sigma

Purpose Singular values of t he fr equency r esponse of LTI models

Syntax sigma(sys)

sigma(sys,w)

sigma(sys,w,type)

sigma(sys1,sys2,...,sysN)

sigma(sys1,sys2,...,sysN,w)

sigma(sys1,sys2,...,sysN,w,type)

sigma(sys1,'PlotStyle1',...,sysN,'PlotStyleN')

[sv,w] = sigma(sys)

sv = sigma(sys,w)

Description sigma calculat es t he singular values of t he fr equency r esponse of an LTI model.

For an FRD model, sys, sigma comput es t he singular values of sys.Response

at t he fr equencies, sys.frequency. For cont inuous-t ime TF, SS, or ZPK models

wit h t r ansfer funct ion , sigma comput es t he singular values of as

a funct ion of t he fr equency . For discr et e-t ime TF, SS, or ZPK models wit h

t r ansfer funct ion and sample t ime , sigma comput es t he singular

values of

for fr equencies bet ween 0 and t he Nyquist fr equency .

The singular values of t he fr equency r esponse ext end t he Bode magnit ude

r esponse for MIMO syst ems and ar e useful in r obust ness analysis. The

singular value r esponse of a SISO syst em is ident ical t o it s Bode magnit ude

r esponse. When invoked wit hout out put ar gument s, sigma pr oduces a singular

value plot on t he scr een.

sigma(sys) plot s t he singular values of t he fr equency r esponse of an ar bit r ar y

LTI model sys. This model can be cont inuous or discr et e, and SISO or MIMO.

The fr equency point s ar e chosen aut omat ically based on t he syst em poles and

zer os, or fr om sys.frequency if sys is an FRD.

sigma(sys,w) explicit ly specifies t he fr equency r ange or fr equency point s t o be

used for t he plot . To focus on a par t icular fr equency int er val [wmin,wmax], set

H s ( ) H j ω ( )

ω

H z ( ) T

s

H e

j ωT

s

( )

ω ω

N

π T

s

⁄ =

sigma

11-203

w = {wmin,wmax}. To use par t icular fr equency point s, set w t o t he

cor r esponding vect or of fr equencies. Use logspace t o gener at e logar it hmically

spaced fr equency vect or s. The fr equencies must be specified in r ad/sec.

sigma(sys,[],type) or sigma(sys,w,type) plot s t he following modified

singular value r esponses:

These opt ions ar e available only for squar e syst ems, t hat is, wit h t he same

number of input s and out put s.

To super impose t he singular value plot s of sever al LTI models on a single

figur e, use

sigma(sys1,sys2,...,sysN)

sigma(sys1,sys2,...,sysN,[],type) % modified SV plot

sigma(sys1,sys2,...,sysN,w) % specify frequency range/grid

The models sys1,sys2,...,sysN need not have t he same number of input s

and out put s. Each model can be eit her cont inuous- or discr et e-t ime. You can

also specify a dist inct ive color , linest yle, and/or mar ker for each syst em plot

wit h t he synt ax

sigma(sys1,'PlotStyle1',...,sysN,'PlotStyleN')

See bode for an example.

When invoked wit h out put ar gument s,

[sv,w] = sigma(sys)

sv = sigma(sys,w)

r et ur n t he singular values sv of t he fr equency r esponse at t he fr equencies w.

For a syst em wit h Nu input and Ny out put s, t he ar r ay sv has min(Nu,Ny) r ows

and as many columns as fr equency point s (lengt h of w). The singular values at

t he fr equency w(k) ar e given by sv(:,k).

type = 1 Singular values of t he fr equency r esponse , wher e is

t he fr equency r esponse of sys.

type = 2 Singular values of t he fr equency r esponse .

type = 3 Singular values of t he fr equency r esponse .

H

1 –

H

I H +

I H

1 –

+

sigma

11-204

Remark If sys is an FRD model, sigma(sys,w), w can only include fr equencies in

sys.frequency.

Example Plot t he singular value r esponses of

and .

H s ( )

0

3s

s

2

s 10 + +

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

s 1 +

s 5 +

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

2

s 6 +

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

=

I H s ( ) +

sigma

11-205

You can do t his by t yping

H = [0 tf([3 0],[1 1 10]) ; tf([1 1],[1 5]) tf(2,[1 6])]

subplot(211)

sigma(H)

subplot(212)

sigma(H,[],2)

Algorithm sigma uses t he svd funct ion in MATLAB t o comput e t he singular values of a

complex mat r ix.

See Also bode Bode plot

evalfr Response at single complex fr equency

freqresp Fr equency r esponse comput at ion

ltiview LTI syst em viewer

Frequency (rad/sec)

S

i

n

g

u

l

a

r

V

a

l

u

e

s

(

d

B

)

Singular Values

10

−2

10

−1

10

0

10

1

10

2

−60

−40

−20

0

20

Frequency (rad/sec)

S

i

n

g

u

l

a

r

V

a

l

u

e

s

(

d

B

)

Singular Values

10

−2

10

−1

10

0

10

1

10

2

−40

−30

−20

−10

0

10

20

sigma

11-206

nichols Nichols plot

nyquist Nyquist plot

size

11-207

11size

Purpose Pr ovide t he out put /input /ar r ay dimensions of LTI models, t he model or der of

TF, SS, and ZPK models, and t he number of fr equencies of FRD models

Syntax size(sys)

d = size(sys)

Ny = size(sys,1)

Nu = size(sys,2)

Sk = size(sys,2+k)

Ns = size(sys,'order')

Nf = size(sys,'frequency')

Description When invoked wit hout out put ar gument s, size(sys) r et ur ns a vect or of t he

number of out put s and input s for a single LTI model. The lengt hs of t he ar r ay

dimensions ar e also included in t he r esponse t o size when sys is an LTI ar r ay.

size is t he over loaded ver sion of t he MATLAB funct ion size for LTI object s.

d = size(sys) r et ur ns:

•The r ow vect or d = [Ny Nu] for a single LTI model sys wit h Ny out put s and

Nu input s

•The r ow vect or d = [Ny Nu S1 S2 ... Sp] for an S1-by-S2-by-...-by-Sp ar r ay

of LTI models wit h Ny out put s and Nu input s

Ny = size(sys,1) r et ur ns t he number of out put s of sys.

Nu = size(sys,2) r et ur ns t he number of input s of sys.

Sk = size(sys,2+k) r et ur ns t he lengt h of t he k-t h ar r ay dimension when sys

is an LTI ar r ay.

Ns = size(sys,'order') r et ur ns t he model or der of a TF, SS, or ZPK model.

This is t he same as t he number of st at es for st at e-space models. When sys is

an LTI ar r ay of SS models wit h differ ing number s of st at es in each model:

•Ns is t he mult idimensional ar r ay of t he or der s of each of t he models in t he

LTI ar r ay.

•The dimensions of Ns ar e given by t he ar r ay dimensions of t he LTI ar r ay sys.

Nf = size(sys,'frequency') r et ur ns t he number of fr equencies when sys is

an FRD. This is t he same as t he lengt h of sys.frequency.

size

11-208

Example Consider t he r andom LTI ar r ay of st at e-space models

sys = rss(5,3,2,3);

It s dimensions ar e obt ained by t yping

size(sys)

3x1 array of state-space models

Each model has 3 outputs, 2 inputs, and 5 states.

See Also isempty Test if LTI model is empt y

issiso Test if LTI model is SISO

ndims Number of dimensions of an LTI ar r ay

sminreal

11-209

11sminr eal

Purpose Per for m model r educt ion based on st r uct ur e

Syntax msys = sminreal(sys)

Description msys = sminreal(sys) eliminat es t he st at es of t he st at e-space model sys t hat

don’t affect t he input /out put r esponse. All of t he st at es of t he r esult ing

st at e-space model msys ar e also st at es of sys and t he input /out put r esponse of

msys is equivalent t o t hat of sys.

sminreal eliminat es only st r uct ur ally non minimal st at es, i.e., st at es t hat can

be discar ded by looking only at har d zer o ent r ies in t he A, B, and C mat r ices.

Such st r uct ur ally nonminimal st at es ar ise, for example, when linear izing a

Simulink model t hat includes some unconnect ed st at e-space or t r ansfer

funct ion blocks.

Remark The model r esult ing fr om sminreal(sys) is not necessar ily minimal, and may

have a higher or der t han one r esult ing fr om minreal(sys). However ,

sminreal(sys) r et ains t he st at e st r uct ur e of sys, while, in gener al,

minreal(sys) does not .

Example Suppose you concat enat e t wo SS models, sys1 and sys2.

sys = [sys1,sys2];

This oper at ion is depict ed in t he diagr am below.

If you ext r act t he subsyst em sys1 fr om sys, wit h

sys(1,1)

+

y

u

v

sys1

sys2

sminreal

11-210

all of t he st at es of sys, including t hose of sys2 ar e r et ained. To eliminat e t he

unobser vable st at es fr om sys2, while r et aining t he st at es of sys1, t ype

sminreal(sys(1,1))

See Also minreal Model r educt ion by r emoving unobser vable/

uncont r ollable st at es or cancelling pole/zer o pair s

ss

11-211

11ss

Purpose Specify st at e-space models or conver t an LTI model t o st at e space

Syntax sys = ss(a,b,c,d)

sys = ss(a,b,c,d,Ts)

sys = ss(d)

sys = ss(a,b,c,d,ltisys)

sys = ss(a,b,c,d,'Property1',Value1,...,'PropertyN',ValueN)

sys = ss(a,b,c,d,Ts,'Property1',Value1,...,'PropertyN',ValueN)

sys_ss = ss(sys)

sys_ss = ss(sys,'minimal')

Description ss is used t o cr eat e r eal-valued st at e-space models (SS object s) or t o conver t

t r ansfer funct ion or zer o-pole-gain models t o st at e space.

Creation of State-Space Models

sys = ss(a,b,c,d) cr eat es t he cont inuous-t ime st at e-space model

For a model wit h Nx st at es, Ny out put s, and Nu input s:

•a is an Nx-by-Nx r eal-valued mat r ix.

•b is an Nx-by-Nu r eal-valued mat r ix.

•c is an Ny-by-Nx r eal-valued mat r ix.

•d is an Ny-by-Nu r eal-valued mat r ix.

The out put sys is an SS model t hat st or es t he model dat a (see “St at e-Space

Models” on page 2-14). If , you can simply set d t o t he scalar 0 (zer o),

r egar dless of t he dimension.

sys = ss(a,b,c,d,Ts) cr eat es t he discr et e-t ime model

x

·

Ax Bu + =

y Cx Du + =

D 0 =

x n 1 + [ ] Ax n [ ] Bu n [ ] + =

y n [ ] Cx n [ ] Du n [ ] + =

ss

11-212

wit h sample t ime Ts (in seconds). Set Ts = –1 or Ts = [] t o leave t he sample

t ime unspecified.

sys = ss(d) specifies a st at ic gain mat r ix and is equivalent t o

sys = ss([],[],[],d)

sys = ss(a,b,c,d,ltisys) cr eat es a st at e-space model wit h gener ic LTI

pr oper t ies inher it ed fr om t he LTI model ltisys (including t he sample t ime).

See “Gener ic Pr oper t ies” on page 2-26 for an over view of gener ic LTI

pr oper t ies.

See “Building LTI Ar r ays” on page 4-12 for infor mat ion on how t o build ar r ays

of st at e-space models.

Any of t he pr evious synt axes can be followed by pr oper t y name/pr oper t y value

pair s.

'PropertyName',PropertyValue

Each pair specifies a par t icular LTI pr oper t y of t he model, for example, t he

input names or some not es on t he model hist or y. See t he set ent r y and t he

example below for det ails. Not e t hat

sys = ss(a,b,c,d,'Property1',Value1,...,'PropertyN',ValueN)

is equivalent t o t he sequence of commands.

sys = ss(a,b,c,d)

set(sys,'Property1',Value1,...,'PropertyN',ValueN)

Conversion to State Space

sys_ss = ss(sys) conver t s an ar bit r ar y TF or ZPK model sys t o st at e space.

The out put sys_ss is an equivalent st at e-space model (SS object ). This

oper at ion is known as state-space realization.

sys_ss = ss(sys,'minimal') pr oduces a st at e-space r ealizat ion wit h no

uncont r ollable or unobser vable st at es. This is equivalent t o sys_ss =

minreal(ss(sys)).

D

ss

11-213

Examples Example 1

The command

sys = ss(A,B,C,D,0.05,'statename',{'position' 'velocity'},...

'inputname','force',...

'notes','Created 10/15/96')

cr eat es a discr et e-t ime model wit h mat r ices and sample t ime 0.05

second. This model has t wo st at es labeled position and velocity, and one

input labeled force (t he dimensions of should be consist ent wit h

t hese number s of st at es and input s). Finally, a not e is at t ached wit h t he dat e

of cr eat ion of t he model.

Example 2

Comput e a st at e-space r ealizat ion of t he t r ansfer funct ion

by t yping

H = [tf([1 1],[1 3 3 2]) ; tf([1 0 3],[1 1 1])];

sys = ss(H);

size(sys)

State-space model with 2 outputs, 1 input, and 5 states.

Not e t hat t he number of st at es is equal t o t he cumulat ive or der of t he SISO

ent r ies of H(s).

To obt ain a minimal r ealizat ion of H(s), t ype

sys = ss(H,'min');

size(sys)

State-space model with 2 outputs, 1 input, and 3 states.

A B C D , , ,

A B C D , , ,

H s ( )

s 1 +

s

3

3s

2

3s 2 + + +

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

s

2

3 +

s

2

s 1 + +

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

=

ss

11-214

The r esult ing st at e-space model or der has or der t hr ee, t he minimum number

of st at es needed t o r epr esent H(s). This can be seen dir ect ly by fact or ing H(s)

as t he pr oduct of a fir st or der syst em wit h a second or der one.

See Also dss Specify descr ipt or st at e-space models.

frd Specify FRD models or conver t t o an FRD.

get Get pr oper t ies of LTI models.

set Set pr oper t ies of LTI models.

ssdata Ret r ieve t he mat r ices of st at e-space model.

tf Specify t r ansfer funct ions or conver t t o TF.

zpk Specify zer o-pole-gain models or conver t t o ZPK.

H s ( )

1

s 2 +

------------ 0

0 1

s 1 +

s

2

s 1 + +

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

s

2

3 +

s

2

s 1 + +

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

=

A B C D , , ,

ss2ss

11-215

11ss2ss

Purpose St at e coor dinat e t r ansfor mat ion for st at e-space models

Syntax sysT = ss2ss(sys,T)

Description Given a st at e-space model sys wit h equat ions

(or t heir discr et e-t ime count er par t ), ss2ss per for ms t he similar it y

t r ansfor mat ion on t he st at e vect or and pr oduces t he equivalent

st at e-space model sysT wit h equat ions.

sysT = ss2ss(sys,T) r et ur ns t he t r ansfor med st at e-space model sysT given

sys and t he st at e coor dinat e t r ansfor mat ion T. The model sys must be in

st at e-space for m and t he mat r ix T must be inver t ible. ss2ss is applicable t o

bot h cont inuous- and discr et e-t ime models.

Example Per for m a similar it y t r ansfor m t o impr ove t he condit ioning of t he mat r ix.

T = balance(sys.a)

sysb = ss2ss(sys,inv(T))

See ssbal for a mor e dir ect appr oach.

See Also balreal Gr amian-based I/O balancing

canon Canonical st at e-space r ealizat ions

ssbal Balancing of st at e-space models using diagonal

similar it y t r ansfor mat ions

x

·

Ax Bu + =

y Cx Du + =

x T x = x

x

·

T AT

1 –

x T Bu + =

y CT

1 –

x Du + =

A

ssbal

11-216

11ssbal

Purpose Balance st at e-space models using a diagonal similar it y t r ansfor mat ion

Syntax [sysb,T] = ssbal(sys)

[sysb,T] = ssbal(sys,condT)

Description Given a st at e-space model sys wit h mat r ices ,

[sysb,T] = ssbal(sys)

comput es a diagonal similar it y t r ansfor mat ion and a scalar such t hat

has appr oximat ely equal r ow and column nor ms. ssbal r et ur ns t he balanced

model sysb wit h mat r ices

and t he st at e t r ansfor mat ion wher e is t he new st at e.

[sysb,T] = ssbal(sys,condT) specifies an upper bound condT on t he

condit ion number of . Since balancing wit h ill-condit ioned can

inadver t ent ly magnify r ounding er r or s, condT gives cont r ol over t he wor st -case

r oundoff amplificat ion fact or . The default value is condT=1/eps.

Example Consider t he cont inuous-t ime st at e-space model wit h t he following dat a.

a = [1 1e4 1e2;0 1e2 1e5;10 1 0];

b = [1;1;1];

c = [0.1 10 1e2];

sys = ss(a,b,c,0)

A B C D , , , ( )

T α

T AT

1 –

T B α ⁄

αCT

1 –

0

T AT

1 –

T B α ⁄ αCT

1 –

D , , , ( )

x T x = x

T T

A

1 10

4

10

2

0 10

2

10

5

10 1 0

, = B

1

1

1

, = C

0.1 10 100

=

ssbal

11-217

Balance t his model wit h ssbal by t yping

ssbal(sys)

a =

x1 x2 x3

x1 1 2500 0.39063

x2 0 100 1562.5

x3 2560 64 0

b =

u1

x1 0.125

x2 0.5

x3 32

c =

x1 x2 x3

y1 0.8 20 3.125

d =

u1

y1 0

Continuous-time system.

Dir ect inspect ion shows t hat t he r ange of numer ical values has been

compr essed by a fact or 100 and t hat t he and mat r ices now have near ly

equal nor ms.

Algorithm ssbal uses t he MATLAB funct ion balance t o comput e and .

See Also balreal Gr amian-based I/O balancing

ss2ss St at e coor dinat e t r ansfor mat ion

B C

T α

ssdata

11-218

11ssdat a

Purpose Quick access t o st at e-space model dat a

Syntax [a,b,c,d] = ssdata(sys)

[a,b,c,d,Ts] = ssdata(sys)

Description [a,b,c,d] = ssdata(sys) ext r act s t he mat r ix (or mult idimensional ar r ay)

dat a fr om t he st at e-space model (LTI ar r ay) sys. If sys is a

t r ansfer funct ion or zer o-pole-gain model (LTI ar r ay), it is fir st conver t ed t o

st at e space. See Table 11-16, “St at e-Space Model Pr oper t ies,” on page 11-196

for mor e infor mat ion on t he for mat of st at e-space model dat a.

[a,b,c,d,Ts] = ssdata(sys) r et ur ns t he sample t ime Ts in addit ion t o a, b,

c, and d.

You can access t he r emaining LTI pr oper t ies of sys wit h get or by dir ect

r efer encing, for example,

sys.statename

See Also dssdata Quick access t o descr ipt or st at e-space dat a

get Get pr oper t ies of LTI models

set Set model pr oper t ies

ss Specify st at e-space models

tfdata Quick access t o t r ansfer funct ion dat a

zpkdata Quick access t o zer o-pole-gain dat a

A B C D , , , ( )

stack

11-219

11st ack

Purpose Build an LTI ar r ay by st acking LTI models or LTI ar r ays along ar r ay

dimensions of an LTI ar r ay

Syntax sys = stack(arraydim,sys1,sys2,...)

Description sys = stack(arraydim,sys1,sys2,...) pr oduces an ar r ay of LTI models sys

by st acking (concat enat ing) t he LTI models (or LTI ar r ays) sys1,sys2,...

along t he ar r ay dimension arraydim. All models must have t he same number

of input s and out put s (t he same I/O dimensions). The I/O dimensions ar e not

count ed in t he ar r ay dimensions. See “Dimensions, Size, and Shape of an LTI

Ar r ay” on page 4-7, and “Building LTI Ar r ays Using t he st ack Funct ion” on

page 4-15 for mor e infor mat ion.

Example If sys1 and sys2 ar e t wo LTI models wit h t he same I/O dimensions:

•stack(1,sys1,sys2) pr oduces a 2-by-1 LTI ar r ay.

•stack(2,sys1,sys2) pr oduces a 1-by-2 LTI ar r ay.

•stack(3,sys1,sys2) pr oduces a 1-by-1-by-2 LTI ar r ay.

step

11-220

11st ep

Purpose St ep r esponse of LTI syst ems

Syntax step(sys)

step(sys,t)

step(sys1,sys2,...,sysN)

step(sys1,sys2,...,sysN,t)

step(sys1,'PlotStyle1',...,sysN,'PlotStyleN')

[y,t,x] = step(sys)

Description step calculat es t he unit st ep r esponse of a linear syst em. Zer o init ial st at e is

assumed in t he st at e-space case. When invoked wit h no out put ar gument s, t his

funct ion plot s t he st ep r esponse on t he scr een.

step(sys) plot s t he st ep r esponse of an ar bit r ar y LTI model sys. This model

can be cont inuous or discr et e, and SISO or MIMO. The st ep r esponse of

mult i-input syst ems is t he collect ion of st ep r esponses for each input channel.

The dur at ion of simulat ion is det er mined aut omat ically based on t he syst em

poles and zer os.

step(sys,t) set s t he simulat ion hor izon explicit ly. You can specify eit her a

final t ime t = Tfinal (in seconds), or a vect or of evenly spaced t ime samples

of t he for m

t = 0:dt:Tfinal

For discr et e syst ems, t he spacing dt should mat ch t he sample per iod. For

cont inuous syst ems, dt becomes t he sample t ime of t he discr et ized simulat ion

model (see “Algor it hm”), so make sur e t o choose dt small enough t o capt ur e

t r ansient phenomena.

To plot t he st ep r esponses of sever al LTI models sys1,..., sysN on a single

figur e, use

step(sys1,sys2,...,sysN)

step(sys1,sys2,...,sysN,t)

step

11-221

All syst ems must have t he same number of input s and out put s but may

ot her wise be a mix of cont inuous- and discr et e-t ime syst ems. This synt ax is

useful t o compar e t he st ep r esponses of mult iple syst ems.

You can also specify a dist inct ive color , linest yle, and/or mar ker for each

syst em. For example,

step(sys1,'y:',sys2,'g--')

plot s t he st ep r esponse of sys1 wit h a dot t ed yellow line and t he st ep r esponse

of sys2 wit h a gr een dashed line.

When invoked wit h out put ar gument s,

[y,t] = step(sys)

[y,t,x] = step(sys) % for state-space models only

y = step(sys,t)

r et ur n t he out put r esponse y, t he t ime vect or t used for simulat ion, and t he

st at e t r aject or ies x (for st at e-space models only). No plot is dr awn on t he

scr een. For single-input syst ems, y has as many r ows as t ime samples (lengt h

of t), and as many columns as out put s. In t he mult i-input case, t he st ep

r esponses of each input channel ar e st acked up along t he t hir d dimension of y.

The dimensions of y ar e t hen

and y(:,:,j) gives t he r esponse t o a unit st ep command inject ed in t he jt h

input channel. Similar ly, t he dimensions of x ar e

Example Plot t he st ep r esponse of t he following second-or der st at e-space model.

lengt h of t ( ) number of out put s ( ) number of input s ( ) × ×

lengt h of t ( ) number of st at es ( ) number of input s ( ) × ×

step

11-222

a = [–0.5572 –0.7814;0.7814 0];

b = [1 –1;0 2];

c = [1.9691 6.4493];

sys = ss(a,b,c,0);

step(sys)

The left plot shows t he st ep r esponse of t he fir st input channel, and t he r ight

plot shows t he st ep r esponse of t he second input channel.

x

·

1

x

·

2

0.5572 – 0.7814 –

0.7814 0

x

1

x

2

1 1 –

0 2

u

1

u

2

+ =

y

1.9691 6.4493

x

1

x

2

=

Time (sec.)

A

m

p

l

i

t

u

d

e

Step Response

0 5 10 15 20

−4

−2

0

2

4

6

8

10

12

From: U1

0 5 10 15 20

From: U2

step

11-223

Algorithm Cont inuous-t ime models ar e conver t ed t o st at e space and discr et ized using

zer o-or der hold on t he input s. The sampling per iod is chosen aut omat ically

based on t he syst em dynamics, except when a t ime vect or t = 0:dt:Tf is

supplied (dt is t hen used as sampling per iod).

See Also impulse Impulse r esponse

initial Fr ee r esponse t o init ial condit ion

lsim Simulat e r esponse t o ar bit r ar y input s

ltiview LTI syst em viewer

tf

11-224

11t f

Purpose Specify t r ansfer funct ions or conver t LTI model t o t r ansfer funct ion for m

Syntax sys = tf(num,den)

sys = tf(num,den,Ts)

sys = tf(M)

sys = tf(num,den,ltisys)

sys = tf(num,den,'Property1',Value1,...,'PropertyN',ValueN)

sys = tf(num,den,Ts,'Property1',Value1,...,'PropertyN',ValueN)

sys = tf('s')

sys = tf('z')

tfsys = tf(sys)

tfsys = tf(sys,'inv') % for state-space sys only

Description tf is used t o cr eat e r eal-valued t r ansfer funct ion models (TF object s) or t o

conver t st at e-space or zer o-pole-gain models t o t r ansfer funct ion for m.

Creation of Transfer Functions

sys = tf(num,den) cr eat es a cont inuous-t ime t r ansfer funct ion wit h

numer at or (s) and denominat or (s) specified by num and den. The out put sys is a

TF object st or ing t he t r ansfer funct ion dat a (see “Tr ansfer Funct ion Models” on

page 2-8).

In t he SISO case, num and den ar e t he r eal-valued r ow vect or s of numer at or and

denominat or coefficient s or der ed in descending power s of . These t wo vect or s

need not have equal lengt h and t he t r ansfer funct ion need not be pr oper . For

example, h = tf([1 0],1) specifies t he pur e der ivat ive .

To cr eat e MIMO t r ansfer funct ions, specify t he numer at or and denominat or of

each SISO ent r y. In t his case:

•num and den ar e cell ar r ays of r ow vect or s wit h as many r ows as out put s and

as many columns as input s.

• The r ow vect or s num{i,j} and den{i,j} specify t he numer at or and

denominat or of t he t r ansfer funct ion fr om input j t o out put i (wit h t he SISO

convent ion).

s

h s ( ) s =

tf

11-225

If all SISO ent r ies of a MIMO t r ansfer funct ion have t he same denominat or ,

you can set den t o t he r ow vect or r epr esent at ion of t his common denominat or .

See “Examples” for mor e det ails.

sys = tf(num,den,Ts) cr eat es a discr et e-t ime t r ansfer funct ion wit h sample

t ime Ts (in seconds). Set Ts = –1 or Ts = [] t o leave t he sample t ime

unspecified. The input ar gument s num and den ar e as in t he cont inuous-t ime

case and must list t he numer at or and denominat or coefficient s in descending

power s of .

sys = tf(M) cr eat es a st at ic gain M (scalar or mat r ix).

sys = tf(num,den,ltisys) cr eat es a t r ansfer funct ion wit h gener ic LTI

pr oper t ies inher it ed fr om t he LTI model ltisys (including t he sample t ime).

See “Gener ic Pr oper t ies” on page 2-26 for an over view of gener ic LTI

pr oper t ies.

Ther e ar e sever al ways t o cr eat e LTI ar r ays of t r ansfer funct ions. To cr eat e

ar r ays of SISO or MIMO TF models, eit her specify t he numer at or and

denominat or of each SISO ent r y using mult idimensional cell ar r ays, or use a

for loop t o successively assign each TF model in t he ar r ay. See “Building LTI

Ar r ays” on page 4-12 for mor e infor mat ion.

Any of t he pr evious synt axes can be followed by pr oper t y name/pr oper t y value

pair s

'Property',Value

Each pair specifies a par t icular LTI pr oper t y of t he model, for example, t he

input names or t he t r ansfer funct ion var iable. See set ent r y and t he example

below for det ails. Not e t hat

sys = tf(num,den,'Property1',Value1,...,'PropertyN',ValueN)

is a shor t cut for

sys = tf(num,den)

set(sys,'Property1',Value1,...,'PropertyN',ValueN)

Transfer Functions as Rational Expressions in s or z

You can also use r eal-valued r at ional expr essions t o cr eat e a TF model. To do

so, fir st t ype eit her :

z

tf

11-226

•s = tf('s') t o specify a TF model using a r at ional funct ion in t he Laplace

var iable, s.

•z = t f('z',Ts) t o specify a TF model wit h sample t ime Ts using a r at ional

funct ion in t he discr et e-t ime var iable, z.

Once you specify eit her of t hese var iables, you can specify TF models dir ect ly

as r at ional expr essions in t he var iable s or z by ent er ing your t r ansfer funct ion

as a r at ional expr ession in eit her s or z.

Conversion to Transfer Function

tfsys = tf(sys) conver t s an ar bit r ar y SS or ZPK LTI model sys t o t r ansfer

funct ion for m. The out put tfsys (TF object ) is t he t r ansfer funct ion of sys. By

default , tf uses zero t o comput e t he numer at or s when conver t ing a st at e-space

model t o t r ansfer funct ion for m. Alt er nat ively,

tfsys = tf(sys,'inv')

uses inver sion for mulas for st at e-space models t o der ive t he numer at or s. This

algor it hm is fast er but less accur at e for high-or der models wit h low gain at

.

Examples Example 1

Cr eat e t he t wo-out put /one-input t r ansfer funct ion

wit h input current and out put s torque and ang velocity.

s 0 =

H p ( )

p 1 +

p

2

2p 2 + +

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

1

p

---

=

tf

11-227

To do t his, t ype

num = {[1 1] ; 1}

den = {[1 2 2] ; [1 0]}

H = tf(num,den,'inputn','current',...

'outputn',{'torque' 'ang. velocity'},...

'variable','p')

Transfer function from input "current" to output...

p + 1

torque: -------------

p^2 + 2 p + 2

1

ang. velocity: -

p

Not e how set t ing t he 'variable' pr oper t y t o 'p' causes t he r esult t o be

displayed as a t r ansfer funct ion of t he var iable .

Example 2

To use a r at ional expr ession t o cr eat e a SISO TF model, t ype

s = tf('s');

H = s/(s^2 + 2*s +10);

This pr oduces t he same t r ansfer funct ion as

h = t f([1 0],[1 2 10]);

Example 3

Specify t he discr et e MIMO t r ansfer funct ion

p

H z ( )

1

z 0.3 +

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

z

z 0.3 +

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

z – 2 +

z 0.3 +

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

3

z 0.3 +

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

=

tf

11-228

wit h common denominat or and sample t ime of 0.2 seconds.

nums = {1 [1 0];[–1 2] 3}

Ts = 0.2

H = tf(nums,[1 0.3],Ts) % Note: row vector for common den. d(z)

Example 4

Comput e t he t r ansfer funct ion of t he st at e-space model wit h t he following dat a.

To do t his, t ype

sys = ss([–2 –1;1 –2],[1 1;2 –1],[1 0],[0 1])

tf(sys)

Transfer function from input 1 to output:

s

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

s^2 + 4 s + 5

Transfer function from input 2 to output:

s^2 + 5 s + 8

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

s^2 + 4 s + 5

Example 5

You can use a for loop t o specify a 10-by-1 ar r ay of SISO TF models.

s = tf('s')

H = tf(zeros(1,1,10));

for k=1:10,

H(:,:,k) = k/(s^2+s+k);

end

The fir st st at ement pr e-allocat es t he TF ar r ay and fills it wit h zer o t r ansfer

funct ions.

Discrete-Time

Conventions

The cont r ol and digit al signal pr ocessing (DSP) communit ies t end t o use

differ ent convent ions t o specify discr et e t r ansfer funct ions. Most cont r ol

d z ( ) z 0.3 + =

A

2 – 1 –

1 2 –

, = B

1 1

2 1 –

, = C

1 0

, = D

0 1

=

tf

11-229

engineer s use t he var iable and or der t he numer at or and denominat or t er ms

in descending power s of , for example,

The polynomials and ar e t hen specified by t he r ow vect or s

[1 0 0] and [1 2 3], r espect ively. By cont r ast , DSP engineer s pr efer t o wr it e

t his t r ansfer funct ion as

and specify it s numer at or as 1 (inst ead of [1 0 0]) and it s denominat or as

[1 2 3].

tf swit ches convent ion based on your choice of var iable (value of t he

'Variable' pr oper t y).

For example,

g = tf([1 1],[1 2 3],0.1)

specifies t he discr et e t r ansfer funct ion

because is t he default var iable. In cont r ast ,

h = tf([1 1],[1 2 3],0.1,'variable','z^–1')

Variable Convention

'z' (default ) Use t he r ow vect or [ak ... a1 a0] t o specify t he

polynomial (coefficient s or der ed in

descending power s of ).

'z^–1', 'q' Use t he r ow vect or [b0 b1 ... bk] t o specify t he

polynomial (coefficient s in

ascending power s of or ).

z

z

h z ( )

z

2

z

2

2z 3 + +

---------------------------- =

z

2

z

2

2z 3 + +

h z

1 –

( )

1

1 2z

1 –

3z

2 –

+ +

--------------------------------------- - =

a

k

z

k

... a

1

z a

0

+ + +

z

b

0

b

1

z

1 –

... b

k

z

k –

+ + +

z

1 –

q

g z ( )

z 1 +

z

2

2z 3 + +

---------------------------- =

z

tf

11-230

uses t he DSP convent ion and cr eat es

See also filt for dir ect specificat ion of discr et e t r ansfer funct ions using t he

DSP convent ion.

Not e t hat tf st or es dat a so t hat t he numer at or and denominat or lengt hs ar e

made equal. Specifically, tf st or es t he values

num = [0 1 1]; den = [1 2 3]

for g (t he numer at or is padded wit h zer os on t he left ) and t he values

num = [1 1 0]; den = [1 2 3]

for h (t he numer at or is padded wit h zer os on t he r ight ).

Algorithm tf uses t he MATLAB funct ion poly t o conver t zer o-pole-gain models, and t he

funct ions zero and pole t o conver t st at e-space models.

See Also filt Specify discr et e t r ansfer funct ions in DSP for mat

frd Specify a fr equency r esponse dat a model

get Get pr oper t ies of LTI models

set Set pr oper t ies of LTI models

ss Specify st at e-space models or conver t t o st at e space

tfdata Ret r ieve t r ansfer funct ion dat a

zpk Specify zer o-pole-gain models or conver t t o ZPK

h z

1 –

( )

1 z

1 –

+

1 2z

1 –

3z

2 –

+ +

--------------------------------------- - z g z ( ) = =

tfdata

11-231

11t fdat a

Purpose Quick access t o t r ansfer funct ion dat a

Syntax [num,den] = tfdata(sys)

[num,den] = tfdata(sys,'v')

[num,den,Ts] = tfdata(sys)

Description [num,den] = tfdata(sys) r et ur ns t he numer at or (s) and denominat or (s) of

t he t r ansfer funct ion for t he TF, SS or ZPK model (or LTI ar r ay of TF, SS or

ZPK models) sys. For single LTI models, t he out put s num and den of tfdata ar e

cell ar r ays wit h t he following char act er ist ics:

•num and den have as many r ows as out put s and as many columns as input s.

•The (i,j) ent r ies num{i,j} and den{i,j} ar e r ow vect or s specifying t he

numer at or and denominat or coefficient s of t he t r ansfer funct ion fr om input

j t o out put i. These coefficient s ar e or der ed in descending power s of or .

For ar r ays sys of LTI models, num and den ar e mult idimensional cell ar r ays

wit h t he same sizes as sys.

If sys is a st at e-space or zer o-pole-gain model, it is fir st conver t ed t o t r ansfer

funct ion for m using tf. See Table 11-15, “LTI Pr oper t ies,” on page 11-195 for

mor e infor mat ion on t he for mat of t r ansfer funct ion model dat a.

For SISO t r ansfer funct ions, t he synt ax

[num,den] = tfdata(sys,'v')

for ces tfdata t o r et ur n t he numer at or and denominat or dir ect ly as r ow vect or s

r at her t han as cell ar r ays (see example below).

[num,den,Ts] = tfdata(sys) also r et ur ns t he sample t ime Ts.

You can access t he r emaining LTI pr oper t ies of sys wit h get or by dir ect

r efer encing, for example,

sys.Ts

sys.variable

Example Given t he SISO t r ansfer funct ion

h = tf([1 1],[1 2 5])

s z

tfdata

11-232

you can ext r act t he numer at or and denominat or coefficient s by t yping

[num,den] = tfdata(h,'v')

num =

0 1 1

den =

1 2 5

This synt ax r et ur ns t wo r ow vect or s.

If you t ur n h int o a MIMO t r ansfer funct ion by t yping

H = [h ; tf(1,[1 1])]

t he command

[num,den] = tfdata(H)

now r et ur ns t wo cell ar r ays wit h t he numer at or /denominat or dat a for each

SISO ent r y. Use celldisp t o visualize t his dat a. Type

celldisp(num)

and MATLAB r et ur ns t he numer at or vect or s of t he ent r ies of H.

num{1} =

0 1 1

num{2} =

0 1

Similar ly, for t he denominat or s, t ype

celldisp(den)

den{1} =

1 2 5

den{2} =

1 1

See Also get Get pr oper t ies of LTI models

ssdata Quick access t o st at e-space dat a

tfdata

11-233

tf Specify t r ansfer funct ions

zpkdata Quick access t o zer o-pole-gain dat a

totaldelay

11-234

11t ot aldelay

Purpose Ret ur n t he t ot al combined I/O delays for an LTI model

Syntax td = totaldelay(sys)

Description td = totaldelay(sys) r et ur ns t he t ot al combined I/O delays for an LTI model

sys. The mat r ix td combines cont r ibut ions fr om t he InputDelay, OutputDelay,

and ioDelayMatrix pr oper t ies, (see set on page 11-193 or t ype ltiprops for

det ails on t hese pr oper t ies).

Delays ar e expr essed in seconds for cont inuous-t ime models, and as int eger

mult iples of t he sample per iod for discr et e-t ime models. To obt ain t he delay

t imes in seconds, mult iply td by t he sample t ime sys.Ts.

Example sys = tf(1,[1 0]); % TF of 1/s

sys.inputd = 2; % 2 sec input delay

sys.outputd = 1.5; % 1.5 sec output delay

td = totaldelay(sys)

td =

3.5000

The r esult ing I/O map is

This is equivalent t o assigning an I/O delay of 3.5 seconds t o t he or iginal model

sys.

See Also delay2z Change t r ansfer funct ions of discr et e-t ime LTI models

wit h delays t o r at ional funct ions or absor bs FRD delays

int o t he fr equency r esponse phase infor mat ion

hasdelay Tr ue for LTI models wit h delays

e

2s – 1

s

---e

1.5s –

× e

3.5s – 1

s

--- =

zero

11-235

11zer o

Purpose Tr ansmission zer os of LTI models

Syntax z = zero(sys)

[z,gain] = zero(sys)

Description zero comput es t he zer os of SISO syst ems and t he t r ansmission zer os of MIMO

syst ems. For a MIMO syst em wit h mat r ices , t he t r ansmission

zer os ar e t he complex values for which t he nor mal r ank of

dr ops.

z = zero(sys) r et ur ns t he (t r ansmission) zer os of t he LTI model sys as a

column vect or .

[z,gain] = zero(sys) also r et ur ns t he gain (in t he zer o-pole-gain sense) if

sys is a SISO syst em.

Algorithm The t r ansmission zer os ar e comput ed using t he algor it hm in [1].

See Also pole Comput e t he poles of an LTI model

pzmap Comput e t he pole-zer o map

References [1] Emami-Naeini, A. and P. Van Door en, “Comput at ion of Zer os of Linear

Mult ivar iable Syst ems,” Automatica, 18 (1982), pp. 415–430.

A B C D , , , ( )

λ

A λI – B

C D

zgrid

11-236

11zgr id

Purpose Gener at e a z-plane gr id of const ant damping fact or s and nat ur al fr equencies

Syntax zgrid

zgrid(z,wn)

Description zgrid gener at es a gr id of const ant damping fact or s fr om zer o t o one in st eps of

0.1 and nat ur al fr equencies fr om zer o t o in st eps of , and plot s t he gr id

over t he cur r ent axis. If t he cur r ent axis cont ains a discr et e z-plane r oot locus

diagr am or pole-zer o map, zgrid dr aws t he gr id over t he plot wit hout alt er ing

t he cur r ent axis limit s.

zgrid(z,wn) plot s a gr id of const ant damping fact or and nat ur al fr equency

lines for t he damping fact or s and nor malized nat ur al fr equencies in t he vect or s

z and wn, r espect ively. If t he cur r ent axis cont ains a discr et e z-plane r oot locus

diagr am or pole-zer o map, zgrid(z,wn) dr aws t he gr id over t he plot . The

fr equency lines for unnor malized (t r ue) fr equencies can be plot t ed using

zgrid(z,wn/Ts)

wher e Ts is t he sample t ime.

zgrid([],[]) dr aws t he unit cir cle.

Example Plot z-plane gr id lines on t he r oot locus for t he syst em

by t yping

H = tf([2 –3.4 1.5],[1 –1.6 0.8],–1)

Transfer function:

2 z^2 – 3.4 z + 1.5

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

z^2 – 1.6 z + 0.8

Sampling time: unspecified

π π 10 ⁄

H z ( )

2z

2

3.4z – 1.5 +

z

2

1.6z – 0.8 +

----------------------------------------- =

zgrid

11-237

To see t he z-plane gr id on t he r oot locus plot , t ype

rlocus(H)

zgrid

axis('square')

Limitations zgrid plot s t he gr id over t he cur r ent axis r egar dless of whet her t he axis

cont ains a r oot locus diagr am or pole-zer o map. Ther efor e, if t he cur r ent axis

cont ains, for example, a st ep r esponse, you may super impose a meaningless

z-plane gr id over t he plot .

See Also pzmap Plot pole-zer o map of LTI syst ems

rlocus Plot r oot locus

sgrid Gener at e s-plane gr id lines

−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1

−1

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

Real Axis

I

m

a

g

A

x

i

s

zpk

11-238

11zpk

Purpose Specify zer o-pole-gain models or conver t LTI model t o zer o-pole-gain for m

Syntax sys = zpk(z,p,k)

sys = zpk(z,p,k,Ts)

sys = zpk(M)

sys = zpk(z,p,k,ltisys)

sys = zpk(z,p,k,'Property1',Value1,...,'PropertyN',ValueN)

sys = zpk(z,p,k,Ts,'Property1',Value1,...,'PropertyN',ValueN)

sys = zpk('s')

sys = zpk('z')

zsys = zpk(sys)

zsys = zpk(sys,'inv') % for state-space sys only

Description zpk is used t o cr eat e zer o-pole-gain models (ZPK object s) or t o conver t TF or SS

models t o zer o-pole-gain for m.

Creation of Zero-Pole-Gain Models

sys = zpk(z,p,k) cr eat es a cont inuous-t ime zer o-pole-gain model wit h zer os

z, poles p, and gain(s) k. The out put sys is a ZPK object st or ing t he model dat a

(see “LTI Object s” on page 2-3).

In t he SISO case, z and p ar e t he vect or s of r eal or complex conjugat e zer os and

poles, and k is t he r eal-valued scalar gain.

Set z or p t o [] for syst ems wit hout zer os or poles. These t wo vect or s need not

have equal lengt h and t he model need not be pr oper (t hat is, have an excess of

poles).

You can also use r at ional expr essions t o cr eat e a ZPK model. To do so, use

eit her :

h s ( ) k

s z 1 ( ) – ( ) s z 2 ( ) – ( )... s z m ( ) – ( )

s p 1 ( ) – ( ) s p 2 ( ) – ( )... s p n ( ) – ( )

---------------------------------------------------------------------------------- =

zpk

11-239

•s = zpk('s') t o specify a ZPK model fr om a r at ional t r ansfer funct ion of t he

Laplace var iable, s.

•z = zpk('z',Ts) t o specify a ZPK model wit h sample t ime Ts fr om a r at ional

t r ansfer funct ion of t he discr et e-t ime var iable, z.

Once you specify eit her of t hese var iables, you can specify ZPK models dir ect ly

as r eal-valued r at ional expr essions in t he var iable s or z.

To cr eat e a MIMO zer o-pole-gain model, specify t he zer os, poles, and gain of

each SISO ent r y of t his model. In t his case:

•z and p ar e cell ar r ays of vect or s wit h as many r ows as out put s and as many

columns as input s, and k is a mat r ix wit h as many r ows as out put s and as

many columns as input s.

•The vect or s z{i,j} and p{i,j} specify t he zer os and poles of t he t r ansfer

funct ion fr om input j t o out put i.

•k(i,j) specifies t he (scalar ) gain of t he t r ansfer funct ion fr om input j t o

out put i.

See below for a MIMO example.

sys = zpk(z,p,k,Ts) cr eat es a discr et e-t ime zer o-pole-gain model wit h

sample t ime Ts (in seconds). Set Ts = –1 or Ts = [] t o leave t he sample t ime

unspecified. The input ar gument s z, p, k ar e as in t he cont inuous-t ime case.

sys = zpk(M) specifies a st at ic gain M.

sys = zpk(z,p,k,ltisys) cr eat es a zer o-pole-gain model wit h gener ic LTI

pr oper t ies inher it ed fr om t he LTI model ltisys (including t he sample t ime).

See “Gener ic Pr oper t ies” on page 2-26 for an over view of gener ic LTI

pr oper t ies.

To cr eat e an ar r ay of ZPK models, use a for loop, or use mult idimensional cell

ar r ays for z and p, and a mult idimensional ar r ay for k.

Any of t he pr evious synt axes can be followed by pr oper t y name/pr oper t y value

pair s.

'PropertyName',PropertyValue

zpk

11-240

Each pair specifies a par t icular LTI pr oper t y of t he model, for example, t he

input names or t he input delay t ime. See set ent r y and t he example below for

det ails. Not e t hat

sys = zpk(z,p,k,'Property1',Value1,...,'PropertyN',ValueN)

is a shor t cut for t he following sequence of commands.

sys = zpk(z,p,k)

set(sys,'Property1',Value1,...,'PropertyN',ValueN)

Zero-Pole-Gain Models as Rational Expressions in s or z

You can also use r at ional expr essions t o cr eat e a ZPK model. To do so, fir st t ype

eit her :

•s = zpk('s') t o specify a ZPK model using a r at ional funct ion in t he Laplace

var iable, s.

•z = zpk('z',Ts) t o specify a ZPK model wit h sample t ime Ts using a

r at ional funct ion in t he discr et e-t ime var iable, z.

Once you specify eit her of t hese var iables, you can specify ZPK models dir ect ly

as r at ional expr essions in t he var iable s or z by ent er ing your t r ansfer funct ion

as a r at ional expr ession in eit her s or z.

Conversion to Zero-Pole-Gain Form

zsys = zpk(sys) conver t s an ar bit r ar y LTI model sys t o zer o-pole-gain for m.

The out put zsys is a ZPK object . By default , zpk uses zero t o comput e t he zer os

when conver t ing fr om st at e-space t o zer o-pole-gain. Alt er nat ively,

zsys = zpk(sys,'inv')

uses inver sion for mulas for st at e-space models t o comput e t he zer os. This

algor it hm is fast er but less accur at e for high-or der models wit h low gain at

.

Variable

Selection

As for t r ansfer funct ions, you can specify which var iable t o use in t he display

of zer o-pole-gain models. Available choices include (default ) and for

cont inuous-t ime models, and (default ), , or for discr et e-t ime

models. Reassign t he 'Variable' pr oper t y t o over r ide t he default s. Changing

t he var iable affect s only t he display of zer o-pole-gain models.

s 0 =

s p

z z

1 –

q z

1 –

=

zpk

11-241

Example Example 1

Specify t he following zer o-pole-gain model.

To do t his, t ype

z = {[] ; –0.5}

p = {0.3 ; [0.1+i 0.1–i]}

k = [1 ; 2]

H = zpk(z,p,k,–1) % unspecified sample time

Example 2

Conver t t he t r ansfer funct ion

h = tf([–10 20 0],[1 7 20 28 19 5])

Transfer function:

–10 s^2 + 20 s

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

s^5 + 7 s^4 + 20 s^3 + 28 s^2 + 19 s + 5

t o zer o-pole-gain for m by t yping

zpk(h)

Zero/pole/gain:

–10 s (s–2)

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

(s+1)^3 (s^2 + 4s + 5)

H z ( )

1

z 0.3 –

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

2 z 0.5 + ( )

z 0. 1 – j + ( ) z 0.1 – j – ( )

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

=

zpk

11-242

Example 3

Cr eat e a discr et e-t ime ZPK model fr om a r at ional expr ession in t he var iable z,

by t yping

z = zpk('z',0.1);

H = (z+.1)*(z+.2)/(z^2+.6*z+.09)

Zero/pole/gain:

(z+0.1) (z+0.2)

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

(z+0.3)^2

Sampling time: 0.1

Algorithm zpk uses t he MATLAB funct ion roots t o conver t t r ansfer funct ions and t he

funct ions zero and pole t o conver t st at e-space models.

See Also frd Conver t t o fr equency r esponse dat a models

get Get pr oper t ies of LTI models

set Set pr oper t ies of LTI models

ss Conver t t o st at e-space models

tf Conver t t o TF t r ansfer funct ion models

zpkdata Ret r ieve zer o-pole-gain dat a

zpkdata

11-243

11zpkdat a

Purpose Quick access t o zer o-pole-gain dat a

Syntax [z,p,k] = zpkdata(sys)

[z,p,k] = zpkdata(sys,'v')

[z,p,k,Ts,Td] = zpkdata(sys)

Description [z,p,k] = zpkdata(sys) r et ur ns t he zer os z, poles p, and gain(s) k of t he zer o-

pole-gain model sys. The out put s z and p ar e cell ar r ays wit h t he following

char act er ist ics:

•z and p have as many r ows as out put s and as many columns as input s.

•The (i,j) ent r ies z{i,j} and p{i,j} ar e t he (column) vect or s of zer os and

poles of t he t r ansfer funct ion fr om input j t o out put i.

The out put k is a mat r ix wit h as many r ows as out put s and as many columns

as input s such t hat k(i,j) is t he gain of t he t r ansfer funct ion fr om input j t o

out put i. If sys is a t r ansfer funct ion or st at e-space model, it is fir st conver t ed

t o zer o-pole-gain for m using zpk. See Table 11-15, “LTI Pr oper t ies,” on page

11-195 for mor e infor mat ion on t he for mat of st at e-space model dat a.

For SISO zer o-pole-gain models, t he synt ax

[z,p,k] = zpkdata(sys,'v')

for ces zpkdata t o r et ur n t he zer os and poles dir ect ly as column vect or s r at her

t han as cell ar r ays (see example below).

[z,p,k,Ts,Td] = zpkdata(sys) also r et ur ns t he sample t ime Ts and t he

input delay dat a Td. For cont inuous-t ime models, Td is a r ow vect or wit h one

ent r y per input channel (Td(j) indicat es by how many seconds t he jt h input is

delayed). For discr et e-t ime models, Td is t he empt y mat r ix [] (see d2d for

delays in discr et e syst ems).

You can access t he r emaining LTI pr oper t ies of sys wit h get or by dir ect

r efer encing, for example,

sys.Ts

sys.inputname

zpkdata

11-244

Example Given a zer o-pole-gain model wit h t wo out put s and one input

H = zpk({[0];[–0.5]},{[0.3];[0.1+i 0.1–i]},[1;2],–1)

Zero/pole/gain from input to output...

1

#1: -------

(z–0.3)

2 (z+0.5)

#2: -------------------

(z^2 – 0.2z + 1.01)

Sampling time: unspecified

you can ext r act t he zer o/pole/gain dat a embedded in H wit h

[z,p,k] = zpkdata(H)

z =

[ 0]

[-0.5000]

p =

[ 0.3000]

[2x1 double]

k =

1

2

To access t he zer os and poles of t he second out put channel of H, get t he cont ent

of t he second cell in z and p by t yping

z{2,1}

ans =

–0.5000

p{2,1}

ans =

0.1000+ 1.0000i

0.1000– 1.0000i

zpkdata

11-245

See Also get Get pr oper t ies of LTI models

ssdata Quick access t o st at e-space dat a

tfdata Quick access t o t r ansfer funct ion dat a

zpk Specify zer o-pole-gain models

zpkdata

11-246

I-1

Index

A

acker 11-11

addit ion of LTI models 3-11

scalar 3-12

adjoint . S ee per t r ansposit ion

algebr aic loop 11-76

aliasing 5-13

analysis models

specifying 6-56

S ee also Simulink LTI Viewer

append 3-16, 3-17, 4-29, 11-12

ar r ay dimensions 4-7

ar r ays. S ee LTI ar r ays

augstate 11-15

axes gr ouping menu 6-23

B

balancing r ealizat ions 5-7, 11-16, 11-216

balreal 11-16

block diagr am. S ee model building

bode (Bode Plot s) 11-19

unit s for plot s 5-12

building LTI ar r ays 4-12

C

c2d 11-24

cancellat ion 11-140

canon 11-27

canonical r ealizat ions 5-7, 11-27

care 11-29

cell ar r ay 2-11, 2-14, 11-90, 11-231

chgunits 11-33

classical cont r ol 9-3, 9-20

closed loop. S ee feedback

companion r ealizat ions 11-27

compar ing models 5-13, 11-19, 11-94, 11-127,

11-134

compensat or s

feedback 7-6

Root Locus Design GUI 8-28, 8-31, 8-41

concat enat ion, model 2-10

hor izont al 3-17

LTI ar r ays 4-15, 11-219

st at e-space model or der , effect s on 3-10

ver t ical 3-17

condit ioning, st at e-space models 10-4

connect 11-33, 11-34

connect ion

feedback 9-11, 11-73

par allel 3-12, 9-54, 11-168

ser ies 3-13, 9-15, 11-191

st ar pr oduct (LFT) 11-115

const r uct or funct ions, LTI object s 2-4

cont inuous-t ime 5-2, 11-104

conver sion t o. S ee conver sion, model

r andom model 11-189

cont r ol design. S ee design

cont r ollabilit y

gr amian 11-91

mat r ix (ctrb) 11-43

st air case for m 11-45

conver sion, model

aut omat ic 2-43

bet ween model t ypes 2-42, 3-3, 11-212, 11-226,

11-240

cont inuous t o discr et e (c2d) 3-20, 11-24

discr et e t o cont inuous (d2c) 2-36, 3-20, 11-48

wit h negat ive r eal poles 3-21, 11-49

FRD model, t o 2-42

r esampling 3-27

discr et e models 11-51

Index

I-2

SS model, t o 2-42

st at e-space, t o 2-44, 11-212

TF model, t o 2-42

ZPK model, t o 2-42

covar 11-40

covar iance

er r or 9-56, 9-62, 11-110

noise 7-9, 11-110

out put 11-40, 11-110

st at e 11-40, 11-110

ctrb 11-43

ctrbf 11-45

D

d2c 11-48

d2d 3-27, 11-51

damp 11-52

damping 11-52, 11-200, 11-236

dare 11-54

dcgain 11-57, 11-58

delay2z 11-58

delays

ar it hmet ic oper at ions 3-15

c2d and d2c conver sions 3-25

combining 2-54, 11-234

conver sion 11-58

conver sion t o SS 2-54

delay2z 11-58

discr et e-t ime models 2-52

discr et izat ion 3-24

exist ence of, t est for 11-93

hasdelay 11-93

I/O 2-26, 2-45, 2-46, 11-195

infor mat ion, r et r ieving 2-54

input 2-26, 2-50, 11-195

out put 2-26, 2-45, 2-50, 11-196

Padé appr oximat ion 2-55, 11-164

suppor t ed funct ionalit y 2-45

t ime 11-195

delays input 2-45

delet ion

par t s of LTI ar r ays 4-23

par t s of LTI models 3-9

denominat or

common denominat or 11-78, 11-225

pr oper t y 2-28, 11-197

specificat ion 2-8, 2-10, 2-11, 2-22, 11-77

value 2-25

descr ipt or syst ems. S ee st at e-space models,

descr ipt or

deselect ion of it ems in a window 6-11

design 1-20

classical 9-3, 9-20

compensat or s 7-6

Kalman est imat or 7-9, 9-36, 9-57, 11-108,

11-112

LQG 1-20, 7-8, 7-10, 9-31, 11-59, 11-117

pole placement 7-5, 11-11, 11-170

r egulat or s 7-6, 7-10, 9-31, 11-117, 11-176

r obust ness 9-29

r oot locus 7-3, 9-9, 9-24

st at e est imat or 7-5, 7-9, 11-70, 11-108, 11-112

design model 8-11, 11-187

compensat or for 8-11

diagonal r ealizat ions 11-27

digit al filt er

filt 2-23

specificat ion 2-22, 11-77

dimensions

ar r ay 4-7

I/O 4-7

Dir ac impulse 11-94

discr et e-t ime models 5-2, 11-104

Index

I-3

cont r ol design 9-20

equivalent cont inuous poles 11-52

fr equency 5-13, 11-23

Kalman est imat or 9-50, 11-108

r andom 11-62

r esampling 3-27

S ee also LTI models

discr et izat ion 2-36, 3-20, 9-21, 11-24

available met hods 11-24

delay syst ems 3-24

fir st -or der hold 3-22

int er sample behavior 11-129

mat ched poles/zer os 3-23

Tust in met hod 3-22

zer o-or der hold 3-20

dlqr 11-59

dlyap 11-61

drmodel 11-62

drss 11-62

dsort 11-64

DSP convent ion 11-77, 11-198, 11-228

dss 11-65

dssdata 11-67

dual. S ee t r ansposit ion

E

er r or covar iance 9-56, 9-62, 11-110

esort 11-68

estim 11-70

est imat or 7-5, 7-9, 11-70, 11-108, 11-112

cur r ent 11-110

discr et e 11-108

discr et e for cont inuous plant 11-112

gain 7-6

evalfr 11-72

ext r act ion

LTI ar r ays, in 4-21

LTI models, in 3-5

F

feedback 11-73

feedback 9-11, 11-73

algebr aic loop 11-76

negat ive 11-73

posit ive 11-73

feedt hr ough gain 2-28

filt 2-23, 11-77, 11-79, 11-82

filt er ing. S ee Kalman est imat or

final t ime. S ee t ime r esponse

fir st -or der hold (FOH) 3-22, 11-24

wit h delays 3-24

frd 11-79

FRD (fr equency r esponse dat a) object s 2-3, 2-18,

11-79

conver sion t o 2-42

dat a 11-82

frdata 11-82

fr equencies

indexing by 3-7

r efer encing by 3-7

unit s, conver sion 11-33

singular value plot s 11-202

uses 2-3

frdata 11-82

freqresp 11-84

fr equency

cr ossover 11-137

for discr et e syst ems 5-13, 11-23

gr id 5-12

linear ly spaced fr equencies 5-13

logar it hmically spaced fr equencies 5-13, 11-19

nat ur al 11-52, 11-200, 11-236

Index

I-4

Nyquist 5-13, 11-23

r ange 5-12

fr equency r esponse 2-18, 5-11

at single fr equency (evalfr) 11-72

Bode plot 11-19

cust omized plot s 5-17

discr et e-t ime fr equency 5-13, 11-23

freqresp 11-84

magnit ude 11-19

MIMO 5-12, 11-19, 11-149, 11-156

Nichols char t (ngrid) 11-147

Nichols plot 11-149

Nyquist plot 11-156

phase 11-19

plot t ing 5-13, 11-19, 11-134

singular value plot 11-202

viewing t he gain and phase mar gins 11-137

G

gain 2-11

est imat or gain 7-6, 7-9

feedt hr ough 2-28

low fr equency (DC) 11-57

pr oper t y

LTI pr oper t ies gain 2-28

select ion 7-3, 7-6, 7-9

st at e-feedback gain 7-9, 11-59

gain mar gins 9-29, 11-19, 11-137

gensig 11-87

get 2-31, 11-89

gram 11-91, 11-93

gr amian (gram) 11-16, 11-91

gr oup. S ee I/O gr oups

GUI 8-2

H

Hamilt onian mat r ix and pencil 11-29

hasdelay 2-54, 11-93

hidden oscillat ions 11-129

I

I/O

concat enat ion 3-16

delays 2-26, 2-45, 2-46, 11-195

dimensions 5-2, 11-207

LTI ar r ays 4-7

gr oups 2-26

r efer encing models by gr oup name 3-8

names 2-26, 2-37

conflict s, naming 3-4

r efer encing models by 3-8

r elat ion 3-5

impulse 11-94

impulse r esponse 11-94

indexing int o LTI ar r ays 4-20

single index access 4-20

inher it ance 3-3, 11-65, 11-212

initial 11-98

init ial condit ion 11-98

innovat ion 11-110

input 2-2

delays 2-26, 2-45, 2-50, 11-195

Dir ac impulse 11-94

gener at e t est input signals 11-87

gr oups 2-26

names 2-26, 11-196

S ee also InputName

number of input s 5-2, 11-207

pulse 11-87, 11-94

r esampling 11-129

sine wave 11-87

Index

I-5

squar e wave 11-87

input point block 6-56

S ee also Simulink LTI Viewer

InputDelay. S ee delays

InputGroup 2-26, 2-27

conflict s, naming 3-4

S ee also I/O gr oups

InputName 2-34, 2-36

conflict s, naming 3-4

S ee also I/O names

int er connect ion. S ee model building

int er sample behavior 11-129

inv 11-101

inver sion 11-101

limit at ions 11-102

model 3-13

ioDelayMatrix. S ee delay

isct 11-104

isdt 11-104

isempty 11-105

isproper 11-106

issiso 11-107

K

Kalman

filt er . S ee Kalman est imat or

filt er ing 7-11, 9-50

gain 7-9

kalman 11-108

Kalman est imat or

cont inuous 7-9, 9-36

cur r ent 11-110

discr et e 9-50, 11-108

discr et e for cont inuous plant 11-112

innovat ion 11-110

st eady-st at e 7-9, 11-108

t ime-var ying 9-57

kalmd 11-112

L

LFT (linear -fr act ional t r ansfor mat ion) 11-115

LQG (linear quadr at ic-gaussian) met hod

cont inuous LQ r egulat or 7-9, 9-36, 11-121

cost funct ion 9-36, 11-59, 11-121

cur r ent r egulat or 11-118

design 1-20, 7-8, 7-10, 9-31, 9-47

discr et e LQ r egulat or 11-59, 11-123

Kalman st at e est imat or 7-9, 11-108, 11-112

LQ-opt imal gain 7-9, 9-36, 11-121, 11-123,

11-125

opt imal st at e-feedback gain 7-9, 11-121, 11-123,

11-125

out put weight ing 11-125

r egulat or 1-21, 7-10, 9-31, 11-117

weight ing mat r ices 7-9

lqr 11-121

lqrd 11-123

lqry 11-125

lsim 11-126

LTI (linear t ime-invar iant ) 2-2

LTI ar r ays 4-1

accessing models 4-20

analysis funct ions 4-30

ar r ay dimensions 4-7

building 4-15, 11-219

building LTI ar r ays 4-12

building wit h rss 4-12

building wit h tf, zpk, ss, and frd 4-17

concat enat ion 4-15, 11-219

conver sion, model.S ee conver sion

delet ing par t s of 4-23

dimensions, size, and shape 4-7

Index

I-6

ext r act ing subsyst ems 4-21

indexing int o 4-20

int er connect ion funct ions 4-25

LTI Viewer , model select or 6-28, 6-31

model dimensions 4-7

oper at ions on 4-25

dimension r equir ement s 4-27

special cases 4-27

r eassigning par t s of 4-22

SS models 4-23

shape, changing 11-179

size 4-7

stack 4-15, 11-219

LTI models

addit ion 3-11

scalar 3-12

building 3-16

char act er ist ics 5-2

compar ing mult iple models 5-13, 11-19, 11-94,

11-127, 11-134

concat enat ion

effect s on model or der 3-10

hor izont al 3-17

ver t ical 3-17

cont inuous 5-2

conver sion 2-42, 3-3

cont inuous/discr et e 3-20

S ee also conver sion, model

cr eat ing 2-8

dimensions 11-146

discr et e 2-20, 5-2, 11-104

discr et izat ion, mat ched poles/zer os 3-23

empt y 2-12, 5-2, 11-105

frd 11-79

fr equency r esponse. S ee fr equency r esponse

funct ions, analysis 5-4

I/O gr oup or channel name, r efer encing by 3-8

int er connect ion funct ions 3-16

inver sion 3-13

model dat a, accessing 2-24, 11-218

model or der r educt ion 5-20, 11-16, 11-142

modifying 3-5

mult iplicat ion 3-13

ndims 11-146

nor ms 11-152

oper at ions 3-1, 3-2

pr ecedence r ules 3-3

S ee also oper at ions

pr oper t r ansfer funct ion 5-2, 11-106

r andom 11-62, 11-189

r esizing 3-9

second-or der 11-163

SISO 11-107

ss 11-211

subsyst em, modifying 3-10

subt r act ion 3-12

t ime r esponse. S ee t ime r esponse

t ype 5-2

zpk 11-238

LTI object s 2-26, 2-33

const r uct ing 2-4

met hods 2-4

pr oper t ies. S ee LTI pr oper t ies

S ee also LTI models

LTI pr oper t ies 2-4, 2-26, 2-34

accessing pr oper t y values (get) 2-31, 2-33,

11-89

admissible values 11-194

displaying pr oper t ies 2-32, 11-89

gener ic pr oper t ies 2-26

I/O gr oups. S ee I/O, gr oups

I/O names. S ee I/O, names

inher it ance 3-3, 11-65, 11-212

Index

I-7

model-specific pr oper t ies 2-28

online help (ltiprops) 2-26

pr oper t y names 2-26, 2-30, 11-89, 11-193

pr oper t y values 2-26, 2-31, 11-89, 11-193

set t ing 2-30, 11-193, 11-212, 11-225, 11-240

sample t ime 3-3

var iable pr oper t y 3-4

LTI Viewer 11-133

axes gr ouping menu 6-23

command line init ializing 6-5

file menu 6-15

fr equency domain plot unit s 6-44

get t ing help 6-16

impor t ing models 6-11, 6-15

mult iselect ion and deselect ion 6-11

line pr oper t ies, or der 6-47

linest yle pr oper t ies 6-46

LTI ar r ay select or 6-28

LTI ar r ays 6-28, 6-31

model select ion 6-32, 6-35

menu it ems, select ion 6-20

menus, LTI Viewer 6-15

Model Select or for LTI Ar r ays window 6-28

opening a new 6-16

plot opt ions 6-7, 6-9

plot t ypes

changing 6-19

select ion 6-20

pr int ing 6-16

r efr eshing syst ems 6-16

r esponse char act er ist ics 6-9, 6-43

r esponse pr efer ences, set t ing 6-40

r ight -click menus 6-7

MIMO models 6-21

select ing a menu it em 6-20

SISO models 6-18

r ise t ime 6-43

select I/Os menu 6-26

set t ling t ime 6-43

Simulink models. S ee Simulink LTI Viewer

syst ems, deselect ing 6-19

syst ems, select ing 6-19

Tools menu 6-39

Viewer Configur at ion menu 6-39

zooming 6-12

ltiview 11-133

lyap 11-135

Lyapunov equat ion 11-41, 11-92

cont inuous 11-135

discr et e 11-61

M

map, I/O 3-5

margin 11-137

mar gins, gain and phase 9-29, 11-19, 11-137

mat ched pole-zer o 11-24

met hods 2-4

MIMO 2-2, 3-17, 5-10, 5-12, 11-94

minreal 11-140

model building 3-16

appending LTI models 11-12

feedback connect ion 9-11, 11-73

LFT connect ion 11-115

modeling block diagr ams (connect) 11-34

par allel connect ion 3-12, 9-54, 11-168

ser ies connect ion 3-13, 9-15, 11-191

model dynamics, funct ion list 5-4

Model Input s and Out put s block set 6-51

model or der r educt ion 5-20, 11-16, 11-142,

11-209

Model Select or for LTI Ar r ays window 6-28

modeling. S ee model building

modred 11-142

Index

I-8

mult iplicat ion 3-13

scalar 3-13

mult iselect ion of it ems in a window 6-11

N

nat ur al fr equency 11-52

ndims 11-146

ngrid 11-147

Nichols

char t 11-147

plot (nichols) 11-149

nichols 11-149

noise

covar iance 7-9, 11-110

measur ement 7-8, 11-70

pr ocess 7-8, 11-70

whit e 5-9, 7-8, 11-40

norm 11-152

nor ms of LTI syst ems (norm) 11-152

Notes 2-27

numer at or

pr oper t y 2-28, 11-197

specificat ion 2-8, 2-10, 2-11, 2-22, 11-77

value 2-25, 11-90

numer ical st abilit y 10-6

Nyquist

fr equency 5-13, 11-23

plot (nyquist) 11-156

nyquist 11-156

O

object -or ient ed pr ogr amming 2-4

object s. S ee LTI object s

obser vabilit y

gr amian 11-91

mat r ix (ctrb) 11-159

st air case for m 11-161

obsv 11-159

obsvf 11-161

oper at ions on LTI models

addit ion 3-11

append 3-17

append 11-12

ar it hmet ic 3-11

augment ing st at e wit h out put s 11-15

concat enat ion 2-10, 3-10, 3-17

diagonal building 11-12

ext r act ing a subsyst em 2-6

inver sion 3-13, 11-101

mult iplicat ion 3-13

over loaded 2-4

per t r ansposit ion 3-14

pr ecedence 3-3

r esizing 3-9

sor t ing t he poles 11-64, 11-68

subsyst em, ext r act ion 3-5

subt r act ion 3-12

t r ansposit ion 3-14

ord2 11-163

out put 2-2

covar iance 11-40, 11-110

delays 2-26, 2-45, 2-50, 11-196

gr oups 2-26

names 2-26, 11-196

names. S ee also OutputName

number of out put s 5-2, 11-207

out put point block 6-56

S ee also Simulink LTI Viewer

OutputDelay. S ee delays

OutputGroup 2-26, 2-27

gr oup names, conflict s 3-4

Index

I-9

S ee also I/O, gr oups

OutputName 2-34

conflict s, naming 3-4

S ee also I/O, names

over shoot 5-9

P

pade 11-164

Padé appr oximat ion (pade) 2-55, 11-164

parallel 11-168

par allel connect ion 3-12, 9-54, 11-168

per t r ansposit ion 3-14

phase mar gins 9-29, 11-19, 11-137

place 11-170

plot configur at ion, LTI Viewer 6-39

plot t ing

cust omized plot s 5-17

fr equency r esponse. S ee fr equency r esponse

mult iple syst ems 5-13, 11-19, 11-94, 11-127,

11-134

Nichols char t (ngrid) 11-147

s-plane gr id (sgrid) 11-200

t ime r esponses 5-9

S ee also t ime r esponse 5-9

z-plane gr id (zgrid) 11-236

pole 11-172

pole placement 7-5, 11-11, 11-170

condit ioning 7-7

poles 2-12

comput ing 11-172

damping 11-52, 11-200, 11-236

equivalent cont inuous poles 11-52

mult iple 11-172

nat ur al fr equency 11-52, 11-200, 11-236

pole-zer o map 11-173

pr oper t y 2-28

sor t ing by magnit ude (dsort) 11-64

sor t ing by r eal par t (esort) 11-68

s-plane gr id (sgrid) 11-200

z-plane gr id (zgrid) 11-236

pole-zer o

cancellat ion 11-140

map (pzmap) 11-173

pr ecedence r ules 2-5, 3-3

pr oper t r ansfer funct ion 5-2, 11-106

pr oper t ies

sample t ime 3-3

var iable 3-4

pr oper t ies. S ee LTI pr oper t ies

pulse 11-87, 11-94

pzmap 11-173

R

r andom models 11-62, 11-189

r ealizat ion

st at e coor dinat e t r ansfor mat ion 5-7, 11-28,

11-215

r ealizat ions 5-7, 11-212

balanced 5-7, 11-16, 11-216

canonical 5-7, 11-27

companion for m 11-27

minimal 11-140

modal for m 11-27

Redheffer st ar pr oduct 11-115

S ee also LFT

r educed-or der models 5-20, 11-16, 11-142

r egulat ion 1-20, 7-8, 9-31, 11-176

per for mance 7-9

r esampling 3-27

r esampling (d2d) 11-51

reshape 11-179

r esponse char act er ist ics 6-43

Index

I-10

S ee also LTI Viewer

r esponse pr efer ences, set t ing 6-40

r esponse, I/O 3-5

Riccat i equat ion 7-9

cont inuous (care) 11-29

discr et e (dare) 11-54

for LQG design 11-110, 11-121

Η∞-like 11-31

st abilizing solut ion 11-29, 11-54

r ight -click menus

LTI ar r ays 6-28

r ight -click menus, LTI Viewer 6-7

S ee also LTI Viewer , r ight -click menus

r ise t ime 5-9

rlocfind 11-180

rlocus 11-182

rltool 11-179, 11-185

rmodel 11-189

r obust ness 9-29

r oot locus

design 7-3, 9-9, 9-24

plot (rlocus) 11-182

select gain fr om 11-180

S ee also Root Locus Design GUI

Root Locus Design GUI 7-3, 8-1, 11-185

add gr id/boundar y 8-24

axes set t ings 8-19

clear ing model and compensat or dat a 8-46

compensat or s 8-11, 11-187

edit ing 8-3, 8-28, 8-31, 8-41

configur at ion, design model 8-10, 11-187

cont inuous t o discr et e model conver sion 8-3,

8-38, 8-45

cont r oller design 8-6

design model 8-11

design r egion boundar ies 8-24

design specificat ions 8-35

discr et e t o cont inuous model conver sion 8-3,

8-38, 8-45

dr awing a Simulink diagr am fr om 8-44

feedback st r uct ur e 8-10, 11-187

gain set point 8-13

impor t ing models 8-7, 8-9

list ing poles and zer os 8-41

model sour ce 8-38, 8-39

opening 8-6

pr int ing 8-28

t oolbar 8-28

zoom t ools 8-16

zooming 8-15

Root Locus Design GUI compensat or s edit ing 8-3

rss 11-189

building an LTI ar r ay wit h 4-12

S

sample t ime 2-20, 2-26, 2-27, 2-34, 3-3

accessing 2-24, 11-218

choices of for plot t ing 5-11

r esampling 3-27, 11-51

set t ing 2-36, 11-195, 11-225, 11-239

unspecified 2-27, 11-23

scaling 10-15

second-or der model 11-163

select fr om LTI ar r ay menu 6-28

select I/Os menu 6-26

series 11-191

ser ies connect ion 3-13, 9-15, 11-191

set 2-30, 11-193

set t ling t ime 5-9

signal gener at or 11-87

simulat ion of linear syst ems. S ee t ime r esponse

Simulink LTI Viewer 6-48, 6-50

Index

I-11

analysis models 6-50

clear ing 6-53

open and closed loop 6-56

saving 6-65

specifying 6-53, 6-56

input point blocks 6-53

linear izing models 6-53, 6-63

opening 6-50

oper at ing condit ions, changing 6-61

oper at ing condit ions, set t ing 6-58

oper at ing point s 6-53

out put point blocks 6-53

Simulink menu 6-53

specifying models for 6-51

sine wave 11-87

singular value plot (bode) 11-202

SISO 2-2, 5-2, 8-2, 11-107

size 11-207

sminreal 11-209

squar e wave 11-87

ss 2-15, 11-211

SS object s. S ee st at e-space models

st abilit y

numer ical 10-6

st abilizable 11-31

st abilizing, Riccat i equat ion 11-29, 11-54

stack 4-15, 11-219

st ar pr oduct 11-115

st at e 2-14

augment ing wit h out put s 11-15

covar iance 11-40, 11-110

est imat or 7-5, 7-9, 11-70, 11-108, 11-112

feedback 7-5, 11-59

mat r ix 2-28

names 2-29, 11-196

number of st at es 4-10, 11-207

t r ansfor mat ion 5-7, 11-28, 11-215

uncont r ollable 11-140

unobser vable 11-140, 11-161

vect or 2-2

st at e-space models 2-2, 2-3, 10-8

balancing 5-7, 11-16, 11-216

condit ioning 10-4

conver sion t o 2-42

S ee also conver sion

descr ipt or 2-16, 2-24, 11-65, 11-67

dss 11-65

init ial condit ion r esponse 11-98

mat r ices 2-15

model dat a 2-15

or der r educt ion. S ee model or der r educt ion

quick dat a r et r ieval 2-24, 11-67, 11-218

r andom

cont inuous-t ime 11-189

discr et e-t ime models 11-62

r ealizat ions 5-7, 11-212

scaling 10-15

specificat ion 2-14, 11-211

ss 2-15, 11-211

t r ansfer funct ions of 2-42

st eady st at e er r or 5-9

st ep r esponse 11-220

subsyst em 2-6, 3-5

subsyst em oper at ions on LTI models

subsyst em, modifying 3-10

subt r act ion 3-12

Sylvest er equat ion 11-135

symplect ic pencil 11-55

T

Td. S ee delays

tf 2-8, 11-224

TF object s. S ee t r ansfer funct ions

Index

I-12

tfdata

out put , for m of 2-24

t ime delays. S ee delays

t ime r esponse 5-9

cust omized plot s 5-17

final t ime 5-10, 11-94

impulse r esponse (impulse) 11-94

init ial condit ion r esponse (initial) 11-98

MIMO 5-10, 11-94, 11-126

plot t ing 5-13, 11-94, 11-127, 11-134

r esponse t o ar bit r ar y input s (lsim) 11-87,

11-126

st ep r esponse (step) 11-220

t ime r ange

t o whit e noise 5-9, 11-40

vect or of t ime samples 5-10

t ime-var ying Kalman filt er 9-57

totaldelay 2-54, 11-234

t r ansfer funct ions 2-2, 2-3, 10-8

common denominat or 11-78, 11-225

const r uct ing wit h r at ional expr essions 2-9

conver sion t o 2-42

denominat or 2-8

discr et e-t ime 2-20, 2-22, 11-77, 11-198,

11-228

DSP convent ion 2-22, 11-77, 11-198, 11-228

filt 2-23, 11-77

MIMO 2-10, 3-17, 11-224

numer at or 2-8

quick dat a r et r ieval 2-24, 11-231

r andom 11-62, 11-189

specificat ion 2-8, 11-224

st at ic gain 2-11, 11-225

tf 2-8, 11-224

TF object , display for 2-9

var iable pr oper t y 2-28, 3-4, 11-198, 11-228

t r ansmission zer os. S ee zer os

t r ansposit ion 3-14

t r iangle appr oximat ion 3-22, 11-24

Ts. S ee sample t ime

Tust in appr oximat ion 3-22, 11-24

wit h fr equency pr ewar ping 3-23, 11-24

t ypogr aphic convent ions 5

tzero. S ee zero

U

under sampling 11-129

Userdata 2-27

V

var iable pr oper t y 3-4

Viewer Configur at ion 6-39

W

whit e noise 5-9

S ee also noise

Z

zero 11-235

zer o-or der hold (ZOH) 3-20, 9-21, 11-24

wit h delays 3-24

zer o-pole-gain (ZPK) models 2-2, 2-3, 10-14

conver sion t o 2-42

MIMO 2-13, 3-17, 11-239

quick dat a r et r ieval 2-24, 11-243

specificat ion 2-12, 11-238

st at ic gain 11-239

zpk 2-12, 11-238

zer os 2-12

comput ing 11-235

Index

I-13

pole-zer o map 11-173

pr oper t y 2-28

t r ansmission 11-235

zooming

LTI Viewer 6-12

Root Locus Design GUI 8-15

zpk 2-12, 11-238

ZPK object s. S ee zer o-pole-gain (ZPK) models

zpkdata

out put , for m of 2-24

How to Contact The MathWorks:

PHONE

¤

FAX MAIL

508-647-7000 508-647-7001

Phone Fax Mail

u

INTERNET

**The MathWorks, Inc. 24 Prime Park Way Natick, MA 01760-1500
**

http://www.mathworks.com ftp.mathworks.com comp.soft-sys.matlab

Web Anonymous FTP server Newsgroup Technical support Product enhancement suggestions Bug reports Documentation error reports Subscribing user registration Order status, license renewals, passcodes Sales, pricing, and general information

@

support@mathworks.com suggest@mathworks.com bugs@mathworks.com doc@mathworks.com subscribe@mathworks.com service@mathworks.com info@mathworks.com

**Control System Toolbox User’s Guide © COPYRIGHT 1992 - 1999 by The MathWorks, Inc.
**

The software described in this document is furnished under a license agreement. The software may be used or copied only under the terms of the license agreement. No part of this manual may be photocopied or reproduced in any form without prior written consent from The MathWorks, Inc. U.S. GOVERNMENT: If Licensee is acquiring the Programs on behalf of any unit or agency of the U.S. Government, the following shall apply: (a) For units of the Department of Defense: the Government shall have only the rights specified in the license under which the commercial computer software or commercial software documentation was obtained, as set forth in subparagraph (a) of the Rights in Commercial Computer Software or Commercial Software Documentation Clause at DFARS 227.7202-3, therefore the rights set forth herein shall apply; and (b) For any other unit or agency: NOTICE: Notwithstanding any other lease or license agreement that may pertain to, or accompany the delivery of, the computer software and accompanying documentation, the rights of the Government regarding its use, reproduction, and disclosure are as set forth in Clause 52.227-19 (c)(2) of the FAR. MATLAB, Simulink, Stateflow, Handle Graphics, and Real-Time Workshop are registered trademarks and Target Language Compiler are trademarks of The MathWorks, Inc. Other product or brand names are trademarks or registered trademarks of their respective holders.

Printing History: July 1992 December 1996 January 1998 January 1999

First printing Second printing Revised for MATLAB 5 Third printing Revised for MATLAB 5.2 Fourth printing Revised for Version 4.2 (Release 11)

Contents

Preface

Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Typographic Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

Quick Start

1

LTI Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . MIMO Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Model Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LTI Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1-3 1-4 1-5 1-6

LTI Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7 Model Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-10 Operations on LTI Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-11 Continuous/Discrete Conversions . . . . . . . . . . . . . . . . . . . . . 1-13 Time and Frequency Response . . . . . . . . . . . . . . . . . . . . . . . . 1-14 The LTI Viewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-17

i

System Interconnections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-19 Control Design Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-20 The Root Locus Design GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-23

LTI Models

2

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LTI Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using LTI Models in the Control System Toolbox . . . . . . . . . . . Other Uses of FRD Models . . . . . . . . . . . . . . . . . . . . . . . . . . . LTI Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating an LTI Object: An Example . . . . . . . . . . . . . . . . . . . LTI Properties and Methods . . . . . . . . . . . . . . . . . . . . . . . . . . Precedence Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Viewing LTI Systems As Matrices . . . . . . . . . . . . . . . . . . . . . . . Command Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2-2 2-2 2-3 2-3 2-3 2-4 2-4 2-5 2-5 2-6

Creating LTI Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8 Transfer Function Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8 SISO Transfer Function Models . . . . . . . . . . . . . . . . . . . . . . . 2-8 MIMO Transfer Function Models . . . . . . . . . . . . . . . . . . . . . 2-10 Pure Gains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11 Zero-Pole-Gain Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12 SISO Zero-Pole-Gain Models . . . . . . . . . . . . . . . . . . . . . . . . . 2-12 MIMO Zero-Pole-Gain Models . . . . . . . . . . . . . . . . . . . . . . . 2-13 State-Space Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-14 Descriptor State-Space Models . . . . . . . . . . . . . . . . . . . . . . . . . 2-16 Frequency Response Data (FRD) Models . . . . . . . . . . . . . . . . . 2-17 Discrete-Time Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-20 Discrete-Time TF and ZPK Models . . . . . . . . . . . . . . . . . . . 2-21 Discrete Transfer Functions in DSP Format . . . . . . . . . . . . 2-22 Data Retrieval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-24

ii

Contents

LTI Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Generic Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Model-Specific Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Setting LTI Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Accessing Property Values Using get . . . . . . . . . . . . . . . . . . . . Direct Property Referencing . . . . . . . . . . . . . . . . . . . . . . . . . . . Additional Insight into LTI Properties . . . . . . . . . . . . . . . . . . . Sample Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Input Names and Output Names . . . . . . . . . . . . . . . . . . . . . Input Groups and Output Groups . . . . . . . . . . . . . . . . . . . . Model Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Explicit Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Automatic Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Caution About Model Conversions . . . . . . . . . . . . . . . . . . . . . . Time Delays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Supported Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Specifying Input/Output Delays . . . . . . . . . . . . . . . . . . . . . . . . Distillation Column Example . . . . . . . . . . . . . . . . . . . . . . . . Specifying Delays on the Inputs or Outputs . . . . . . . . . . . . . . . InputDelay and OutputDelay Properties . . . . . . . . . . . . . . . Specifying Delays in Discrete-Time Models . . . . . . . . . . . . . . . Mapping Discrete-Time Delays to Poles at the Origin . . . . Retrieving Information About Delays . . . . . . . . . . . . . . . . . . . . Conversion of Models with Delays to State Space . . . . . . . . . . Padé Approximation of Time Delays . . . . . . . . . . . . . . . . . . . . .

2-26 2-26 2-28 2-30 2-31 2-33 2-34 2-34 2-36 2-37 2-42 2-42 2-43 2-43 2-45 2-45 2-46 2-47 2-50 2-51 2-52 2-53 2-54 2-54 2-55

Simulink Block for LTI Systems . . . . . . . . . . . . . . . . . . . . . . . 2-57 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-59

iii

Operations on LTI Models

3

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2 Precedence and Property Inheritance . . . . . . . . . . . . . . . . . . 3-3 Extracting and Modifying Subsystems . . . . . . . . . . . . . . . . . . Referencing FRD Models Through Frequencies . . . . . . . . . . . . . Referencing Channels by Name . . . . . . . . . . . . . . . . . . . . . . . . . Resizing LTI Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Arithmetic Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Addition and Subtraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Multiplication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Inversion and Related Operations . . . . . . . . . . . . . . . . . . . . . . Transposition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Pertransposition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Operations on State-Space Models with Delays . . . . . . . . . . . .

3-5 3-7 3-8 3-9 3-11 3-11 3-13 3-13 3-14 3-14 3-15

Model Interconnection Functions . . . . . . . . . . . . . . . . . . . . . 3-16 Concatenation of LTI Models . . . . . . . . . . . . . . . . . . . . . . . . . . 3-17 Feedback and Other Interconnection Functions . . . . . . . . . . . 3-18 Continuous/Discrete Conversions of LTI Models . . . . . . . . Zero-Order Hold . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . First-Order Hold . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Tustin Approximation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Tustin with Frequency Prewarping . . . . . . . . . . . . . . . . . . . . . Matched Poles and Zeros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Discretization of Systems with Delays . . . . . . . . . . . . . . . . . . . Delays and Continuous/Discrete Model Conversions . . . . . . .

3-20 3-20 3-22 3-22 3-23 3-23 3-24 3-25

iv

Contents

Resampling of Discrete-Time Models . . . . . . . . . . . . . . . . . . . 3-27 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-28

Arrays of LTI Models

4

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . When to Collect a Set of Models in an LTI Array . . . . . . . . . . . Restrictions for LTI Models Collected in an Array . . . . . . . . . . Where to Find Information on LTI Arrays . . . . . . . . . . . . . . . . .

4-2 4-2 4-2 4-3

The Concept of an LTI Array . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4 Higher Dimensional Arrays of LTI Models . . . . . . . . . . . . . . . . 4-6 Dimensions, Size, and Shape of an LTI Array . . . . . . . . . . . . 4-7 size and ndims . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-9 reshape . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-11 Building LTI Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Generating LTI Arrays Using rss . . . . . . . . . . . . . . . . . . . . . . . Building LTI Arrays Using for Loops . . . . . . . . . . . . . . . . . . . . Building LTI Arrays Using the stack Function . . . . . . . . . . . . Building LTI Arrays Using tf, zpk, ss, and frd . . . . . . . . . . . . . Specifying Arrays of TF models tf . . . . . . . . . . . . . . . . . . . . . The Size of LTI Array Data for SS Models . . . . . . . . . . . . . . Indexing Into LTI Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Accessing Particular Models in an LTI Array . . . . . . . . . . . . . Single Index Referencing of Array Dimensions . . . . . . . . . . Extracting LTI Arrays of Subsystems . . . . . . . . . . . . . . . . . . . Reassigning Parts of an LTI Array . . . . . . . . . . . . . . . . . . . . . . LTI Arrays of SS Models with Differing Numbers of States Deleting Parts of an LTI Array . . . . . . . . . . . . . . . . . . . . . . . . .

4-12 4-12 4-12 4-15 4-17 4-17 4-18 4-20 4-20 4-21 4-21 4-22 4-23 4-23

Operations on LTI Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-25 Example: Addition of Two LTI Arrays . . . . . . . . . . . . . . . . . . . 4-26

v

Dimension Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Special Cases for Operations on LTI Arrays . . . . . . . . . . . . . . Examples of Operations on LTI Arrays with Single LTI Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Examples: Arithmetic Operations on LTI Arrays and SISO Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Other Operations on LTI Arrays . . . . . . . . . . . . . . . . . . . . . . . .

4-27 4-27 4-28 4-29 4-30

Model Analysis Tools

5

General Model Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . 5-2 Model Dynamics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4 State-Space Realizations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-7 Time and Frequency Response . . . . . . . . . . . . . . . . . . . . . . . . . 5-9 Time Responses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-9 Frequency Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-11 Plotting and Comparing Multiple Systems . . . . . . . . . . . . . . . 5-13 Customizing the Plot Display . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17 Model Order Reduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20

The LTI Viewer

6

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2 Functionality of the LTI Viewer . . . . . . . . . . . . . . . . . . . . . . . . . 6-2 Getting Started Using the LTI Viewer: An Example . . . . . . 6-4 Initializing the LTI Viewer with Multiple Plots . . . . . . . . . . . . 6-5 Right-Click Menus: Setting Response Characteristics . . . . . . . 6-7

vi

Contents

Displaying Response Characteristics on a Plot . . . . . . . . . . . . . 6-9 Importing Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-11 Zooming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-12 The LTI Viewer Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The File Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Importing a New Model into the LTI Viewer Workspace . . Opening a New LTI Viewer . . . . . . . . . . . . . . . . . . . . . . . . . . Refreshing Systems in the LTI Viewer Workspace . . . . . . . Printing Response Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . Getting Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Static Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Interactive Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Right-Click Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Right-Click Menu for SISO Models . . . . . . . . . . . . . . . . . . Selecting a Menu Item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Right-Click Menu for MIMO Models . . . . . . . . . . . . . . . . . The Axes Grouping Submenu . . . . . . . . . . . . . . . . . . . . . . . . The Select I/Os Menu Item . . . . . . . . . . . . . . . . . . . . . . . . . . The Right-Click Menu for LTI Arrays . . . . . . . . . . . . . . . . . . . The Model Selector for LTI Arrays . . . . . . . . . . . . . . . . . . . . . . Indexing into the Array Dimensions of an LTI Array . . . . . Indexing into the LTI Array Using Design Specification Criteria . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The LTI Viewer Tools Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . Viewer Configuration Window . . . . . . . . . . . . . . . . . . . . . . . . . Response Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Setting Response Time Durations and Frequency Ranges . Customizing Step Response Specifications . . . . . . . . . . . . . Changing the Frequency Domain Plot Units . . . . . . . . . . . . Linestyle Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Changing the Response Curve Linestyle Properties . . . . . . The Order in which Line Properties are Assigned . . . . . . . . Simulink LTI Viewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using the Simulink LTI Viewer . . . . . . . . . . . . . . . . . . . . . . . . A Sample Analysis Task . . . . . . . . . . . . . . . . . . . . . . . . . . . . Opening the Simulink LTI Viewer . . . . . . . . . . . . . . . . . . . . . .

6-15 6-15 6-15 6-16 6-16 6-16 6-16 6-16 6-17 6-18 6-18 6-20 6-21 6-23 6-26 6-28 6-31 6-32 6-35 6-39 6-39 6-40 6-41 6-43 6-44 6-44 6-46 6-47 6-48 6-48 6-49 6-50

vii

Specifying the Simulink Model Portion for Analysis . . . . . . . . Adding Input Point or Output Point Blocks to the Diagram Removing Input Points and Output Points . . . . . . . . . . . . . Specifying Open- Versus Closed-Loop Analysis Models . . . Setting the Operating Conditions . . . . . . . . . . . . . . . . . . . . . . . Modifying the Block Parameters . . . . . . . . . . . . . . . . . . . . . . . . Performing Linear Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . Importing a Linearized Analysis Model to the LTI Viewer . Analyzing the Bode Plot of the Linearized Analysis Model Specifying Another Analysis Model . . . . . . . . . . . . . . . . . . . Comparing the Bode Plots of the Two Linearized Analysis Models . . . . . . . . . . . . . . . . . . . . . . . . Saving Analysis Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

6-53 6-53 6-56 6-56 6-57 6-61 6-61 6-62 6-63 6-63 6-63 6-65

Control Design Tools

7

Root Locus Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-3 Pole Placement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . State-Feedback Gain Selection . . . . . . . . . . . . . . . . . . . . . . . . . . State Estimator Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Pole Placement Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7-5 7-5 7-5 7-6

LQG Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-8 Optimal State-Feedback Gain . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-9 Kalman State Estimator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-9 LQG Regulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-10 LQG Design Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-10

viii Contents

The Root Locus Design GUI

8

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2 A Servomechanism Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-4 Controller Design Using the Root Locus Design GUI . . . . . 8-6 Opening the Root Locus Design GUI . . . . . . . . . . . . . . . . . . . . . 8-6 Importing Models into the Root Locus Design GUI . . . . . . . . . . 8-7 Opening the Import LTI Design Model Window . . . . . . . . . . 8-9 Choosing a Feedback Structure . . . . . . . . . . . . . . . . . . . . . . 8-10 Specifying the Design Model . . . . . . . . . . . . . . . . . . . . . . . . . 8-11 Changing the Gain Set Point and Zooming . . . . . . . . . . . . . . . 8-13 Dragging Closed-loop Poles to Change the Gain Set Point . 8-14 Zooming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-15 Storing and Retrieving Axes Limits . . . . . . . . . . . . . . . . . . . 8-19 Displaying System Responses . . . . . . . . . . . . . . . . . . . . . . . . . . 8-20 Designing a Compensator to Meet Specifications . . . . . . . . . . 8-22 Specifying Design Region Boundaries on the Root Locus . . 8-24 Placing Compensator Poles and Zeros: General Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-26 Placing Compensator Poles and Zeros Using the Root Locus Toolbar . . . . . . . . . . . . . . . . . . . . . . 8-27 Editing Compensator Pole and Zero Locations . . . . . . . . . . 8-31 Saving the Compensator and Models . . . . . . . . . . . . . . . . . . . . 8-36 Additional Root Locus Design GUI Features . . . . . . . . . . . . Specifying Design Models: General Concepts . . . . . . . . . . . . . . Creating Models Manually Within the GUI . . . . . . . . . . . . . Designating the Model Source . . . . . . . . . . . . . . . . . . . . . . . Getting Help with the Root Locus Design GUI . . . . . . . . . . . . Using the Help Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using the Status Bar for Help . . . . . . . . . . . . . . . . . . . . . . . Tooltips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Erasing Compensator Poles and Zeros . . . . . . . . . . . . . . . . . . . Listing Poles and Zeros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Printing the Root Locus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Drawing a Simulink Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . Converting Between Continuous and Discrete Models . . . . . .

8-38 8-38 8-38 8-39 8-39 8-40 8-40 8-40 8-41 8-41 8-44 8-44 8-45

ix

Clearing Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-46 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-48

Design Case Studies

9

Yaw Damper for a 747 Jet Transport . . . . . . . . . . . . . . . . . . . . 9-3 Open-Loop Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-6 Root Locus Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-9 Washout Filter Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-14 Hard-Disk Read/Write Head Controller . . . . . . . . . . . . . . . . 9-20 LQG Regulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Process and Disturbance Models . . . . . . . . . . . . . . . . . . . . . . . . Model Data for the x-Axis . . . . . . . . . . . . . . . . . . . . . . . . . . . Model Data for the y-Axis . . . . . . . . . . . . . . . . . . . . . . . . . . . LQG Design for the x-Axis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LQG Design for the y-Axis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Cross-Coupling Between Axes . . . . . . . . . . . . . . . . . . . . . . . . . . MIMO LQG Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Kalman Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Discrete Kalman Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Steady-State Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Time-Varying Kalman Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . Time-Varying Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

9-31 9-31 9-34 9-34 9-34 9-42 9-43 9-47 9-50 9-50 9-51 9-57 9-58 9-63

x

Contents

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-152 Creation of State-Space Models . . . . . . . . . . . . . . . 10-4 Numerical Stability . 10-4 Conditioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-213 Creation of Transfer Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-6 Choice of LTI Model . . . . . . . . . . . . . . . . . . . . . . 11-213 Example 2 . . . . . . . . . . . . . . . 11-211 Conversion to State Space . 10-14 Scaling . . . . . . . . . . 10-8 Transfer Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-31 Continuous Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-3 Modal Form . . . . . . . . . . . . . . . . . . . . . . . . 10-15 Summary . . . . . . . . . . . . . . . 11-225 xi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-57 Discrete Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Reliable Computations 1 0 Conditioning and Numerical Stability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-27 Example 1 . . . . . . . . . . . . . . . . 10-8 State Space . 11-224 Transfer Functions as Rational Expressions in s or z . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-17 References . 11-212 Example 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-18 Reference 1 1 Category Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-57 H2 Norm . . . . . . 11-152 Infinity Norm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-27 Companion Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-30 Example 2 . . . . . . . . . . . . . . . . . . . . 10-8 Zero-Pole-Gain Models . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Example 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Zero-Pole-Gain Models as Rational Expressions in s or z Conversion to Zero-Pole-Gain Form . . . . . . . . . . . . . . . . . . . . . . . . Example 4 . . . . . . . . . . . . . . Example 1 . . . . . . . . . . . . . Example 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-226 11-226 11-227 11-227 11-228 11-238 11-240 11-240 11-241 11-241 11-242 xii Contents . . . . . . Example 2 . . . . . . . . . . . . . . . . . . Example 1 . . . . . . . . . . . . . . . . . . . . . . . . . . .Conversion to Transfer Function . . . . . . . . Creation of Zero-Pole-Gain Models . . . . . . . . . . . . Example 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . 4 Getting Started Typographic Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . 5 . . . . . . . . . . 3 . . . . .Preface Installation . . . . . . . . . .

and modeling techniques. tools that are not found in the toolbox can be created by writing new M-files. which implements common control system design. expressed mostly in M-files. Time responses. and estimation. frequency responses. and most importantly. and root loci can be computed and graphed. and numerical analysis capabilities provide a reliable foundation for control system engineering as well as many other disciplines. Conversions between various model representations are provided. Control systems can be modeled as transfer functions or in zero-pole-gain or state-space form. and FFTs are just a few examples of MATLAB’s important numerical tools. allowing you to use both classical and modern techniques. eigenvalues. matrix computation. Complex arithmetic. MATLAB’s linear algebra. More generally. 2 . Other functions allow pole placement. The Control System Toolbox uses MATLAB matrix structures and builds upon the foundations of MATLAB to provide functions specialized to control engineering. matrix inversion. analysis. The Control System Toolbox is a collection of algorithms.Preface MATLAB® has a rich collection of functions immediately useful to the control engineer or system theorist. root-finding. You can manipulate both continuous-time and discrete-time systems. Finally. optimal control.

type ctrldemo.m runs through some basic control design and analysis functions and the demonstration files jetdemo. for example. at the MATLAB prompt. To determine if the Control System Toolbox is already installed on your system. To start a demo.Installation Installation Instructions for installing the Control System Toolbox can be found in the MATLAB Installation Guide for your platform. milldemo.m. 3 . The demonstration M-file called ctrldemo.m.m. check for a subdirectory named control within the main toolbox directory or folder. We recommend that you store the files from this toolbox in a directory named control off the main matlab directory. diskdemo. Five demonstration files are available. and kalmdemo.m go through the design case studies described in Chapter 9.

the descriptions include options for invoking the tool.Preface Getting Started If you are a new user. For GUI-based tools. and references to additional reading material. 4 . Many reference descriptions also include helpful examples. For functions. begin with Chapters 2 through 5 to learn: • How to specify and manipulate linear time-invariant models • How to analyze such models and plot their time and frequency response If you are an experienced toolbox user. a description of the function’s algorithm. as well as a complete explanation of options and operation. reference descriptions include a synopsis of the function’s syntax. see: • The New Features Guide for details on the latest release • Chapter 1 for an overview of some product features • Chapter 4 to learn about LTI arrays • Chapter 6 for an introduction to the LTI Viewer GUI • Chapter 8 for an introduction to the Root Locus Design GUI All toolbox users should use Chapter 11 for reference information on functions and tools.

italics An array is an ordered collection of information. Monospace type MATLAB output Menu names. Keys Mathematical expressions Boldface Press the Return key. menu items. Monospace italics for components you can replace with any variable. operators. The magic function uses the syntax M = magic(n) Monospace type for text that must appear as shown. and constants in standard type. Functions. and controls New terms Boldface Choose the File menu. This vector represents the polynomial p = x2 + 2x + 3 MATLAB responds with A = 5 Variables in italics. enter A = 5 Function names Function syntax Monospace type The cos function finds the cosine of each array element. 5 .Typographic Conventions Typographic Conventions To Indicate This Guide Uses Monospace type Example Example code To assign the value 5 to A.

Preface 6 .

. . . . . . . . . . . . . . . . . . . Model Conversion LTI Arrays . . . . . . . . . . . 1-7 Model Characteristics . . . . . . . . . . . . . . . . 1-11 Continuous/Discrete Conversions . . . . . . . . . . . . . . . . . . . . 1-19 Control Design Tools . . . . . . . .1 Quick Start LTI Models . . . . . 1-3 1-4 1-5 1-6 LTI Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-23 . . . . . . . . . . . . . . . . . . 1-17 System Interconnections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13 Time and Frequency Response The LTI Viewer . . . . 1-10 Operations on LTI Models . . . . . . . . . 1-20 The Root Locus Design GUI . . . . . . . . . . . . 1-14 . . . . . . MIMO Systems . . . .

1-2 .1 Quick Start This chapter provides a quick overview of some features of the Control Systems Toolbox.

sys sys sys sys = = = = tf(num. or FRD object.[1 1]) % creates transfer function 1/(s+1) and MATLAB responds with Transfer function: 1 ----s + 1 Type 1+h MATLAB responds with Transfer function: s + 2 ----s + 1 1-3 . For example.den) zpk(z. type h = tf(1.c.frequencies) % % % % transfer function zero/pole/gain state space frequency response data To find out information about LTI models.d) frd(response. respectively. You can construct the corresponding models using the constructor functions.p. The output sys is a model-specific data structure called a TF.b.LTI Models LTI Models You can specify linear time-invariant (LTI) systems as transfer function (TF) models. state-space (SS) models. or frequency response data (FRD) model.k) ss(a. zero/pole/gain (ZPK) models. type ltimodels See also “Creating LTI Models” on page 2-8. SS. These objects store the model data and enable you to manipulate the LTI model as a single entity. see “LTI Objects” on page 2-3 for more information. ZPK.

1) (z–0.frequency.p. including arbitrary MIMO transfer functions and zero/pole/gain models.b.b. sys.5.den.Ts) ss(a.c.Ts) frd(response. [num.den.5) --------------(z+0.Ts] = tfdata(sys) [z.05) and MATLAB responds with Zero/pole/gain: (z–0.05 You can retrieve the model data stored in the LTI object sys with the following commands (see “Data Retrieval” on page 2-24 for more information). For example.k.3) Sampling time: 0.c.Ts) For more information.Ts) zpk(z.3].p. sys sys sys sys = = = = tf(num.[–0.d. type sys = zpk(0.Ts] = zpkdata(sys) [a.frequency. you can access this data by direct structure-like referencing (see “Direct Property Referencing” on page 2-33 for more information).Ts] = ssdata(sys) [response. append the sample time Ts to the previous calling sequences.d.k. see “Discrete-Time Models” on page 2-20.0.num sys.1. MIMO transfer functions are arrays of single-input/single-output (SISO) transfer functions 1-4 . as in this example.1 0.a sys.1 Quick Start To create discrete-time models.Ts MIMO Systems You can also create multi-input/multi-output (MIMO) models.Ts] = frdata(sys) Alternately.

zpk. For example. sys_ss = ss(sys) converts some tf or zpk model sys to state space.LTI Models where each SISO entry is characterized by its numerator and denominator. For example.5. you can create the same transfer function by matrix-like concatenation of its SISO entries h11 = tf(0. see.1] % Note: use regular matrix for gains H = zpk(Zeros.[1 0]) h12 = tf([1 1].5. “MIMO Transfer Function Models” on page 2-10 for more information.5 ------s s+1 ----------s+2 Alternatively.[1 2]) H = [h11.–1} % Note: use [] when no zero Poles = {0 .Poles. the following commands specify H ( s ) above as a zero/pole/gain model Zeros = {[].–2} Gains = [0. num = {0. For example. frd. Similarly.den) % 1-by-2 cell array of numerators % 1-by-2 cell array of denominators creates the one-output/two-input transfer function H ( s ) = 0. see “Model Conversion” on page 2-42 for more information.[1 2 1]) zpk(h) % transfer function 1/(s^2+2s+1) 1-5 .Gains) Model Conversion The functions tf.[1 1]} den = {[1 0]. and ss also perform model conversion. Cell arrays provide an ideal means to specify the resulting arrays of numerators and denominators. if you type h = tf(1.5.5/s % (s+1)/(s+2) MIMO zero/pole/gain systems are defined in a similar fashion.[1 2]} H = tf(num.h12] % 0.

” 1-6 .1 Quick Start MATLAB derives the zero/pole/gain representation of the transfer function h Zero/pole/gain: 1 ------(s+1)^2 LTI Arrays You can now create multidimensional arrays of LTI models and manipulate them as a single entity. LTI arrays are useful to perform batch analysis on an entire set of models. see Chapter 4. For more information. “Arrays of LTI Models.

sample time = 0. and get to display the current properties of the system. the TF.0.5 sec set(sys) a: Nx-by-Nx matrix (Nx = no. of outputs) d: Ny-by-Nu matrix e: Nx-by-Nx matrix (or empty) StateName: Nx-by-1 cell array of strings Ts: scalar InputDelay: Nu-by-1 vector OutputDelay: Ny-by-1 vector ioDelayMatrix: Ny-by-Nu array (I/O delays) InputName: Nu-by-1 cell array of strings OutputName: Ny-by-1 cell array of strings InputGroup: M-by-2 cell array if M input groups OutputGroup: P-by-2 cell array if P output groups Notes: array or cell array of strings UserData: arbitrary 1-7 .% 1/(z+1). of states) b: Nx-by-Nu matrix (Nu = no. For information on LTI properties. type ltiprops See also “LTI Properties” on page 2-26 and “Time Delays” on page 2-45.5) . For example. type sys = ss(–1.1.LTI Properties LTI Properties In addition to the model data. and input or output names. and SS objects can store extra information. ZPK. time delays. FRD.1. Use set to list all LTI properties and their assignable values. of inputs) c: Ny-by-Nx matrix (Ny = no. such as the system sample time. The various pieces of information that can be attached to an LTI object are called the LTI properties.0.

give names to the input and output of the SISO state-space model sys.Ts% Get sample time value 1-8 . you can also use a structure-like syntax for accessing or modifying a single property. see “Setting LTI Properties” on page 2-30 for more information. type sys.'inputn') MATLAB responds with ans = 'thrust' Finally.'inputname'.'outputname'.'thrust'.3 sec. sys. For example.5 InputDelay: 0 OutputDelay: 0 ioDelayMatrix: 0 InputName: {''} OutputName: {''} InputGroup: {0x2 cell} OutputGroup: {0x2 cell} Notes: {} UserData: [] You can also use set and get to access/modify LTI properties in a Handle Graphics® fashion. For example.Ts = 0. % Set sample time to 0.1 Quick Start Type: get(sys) a: -1 b: 1 c: 1 d: 0 e: [] StateName: {''} Ts: 0. Type set(sys.'velocity') get(sys.3.

LTI Properties MATLAB returns ans = 3.0000e–01 1-9 .

W) % pade(sys) % number of inputs. and DC gain. outputs. See “General Model Characteristics” on page 5-2 for more information.1 Quick Start Model Characteristics The Control System Toolbox contains commands to query such model characteristics as the I/O dimensions. and array dimensions number of dimensions returns 1 for continuous systems returns 1 for discrete systems true if system has delays system poles system (transmission) zeros DC gain system norms (H2 and Linfinity) covariance of response to white noise Pade approximation of input delays 1-10 . zeros. These commands apply to both continuous. size(sys) % ndims(sys) % isct(sys) % isdt(sys) % hasdelay(sys) % pole(sys) % zero(sys) % dcgain(sys) % norm(sys) % covar(sys. poles. Their LTI-based syntax is summarized below (with sys denoting an arbitrary LTI model).and discrete-time model.

addition performs a parallel interconnection. Hence the sum of a transfer function and a state-space model is always a state-space model. see “Precedence Rules” on page 2-5 for more information.[1 2])% 2*1/s*(s+1)/(s+2) and MATLAB responds Transfer function: 2 s + 2 --------s^2 + 2 s If the operands are models of different types. multiplication. Type tf(1.[1 0])*tf([1 1].Operations on LTI Models Operations on LTI Models You can perform simple matrix operations. sys(3. State-space models have highest precedence while transfer functions have lowest precedence. transposition. Type 2 * tf(1. For instance. the resulting model type is determined by precedence rules. or concatenation on LTI models. Matrix-like indexing for extracting subsystems is also supported.1) 1-11 . if sys is a MIMO system with two inputs and three outputs. see “Extracting and Modifying Subsystems” on page 3-5 for more information. see “Inversion and Related Operations” on page 3-13. and pertransposition. Thanks to MATLAB object-oriented programming capabilities.[1 2])% 1/s + (s+1)/(s+2) and MATLAB responds: Transfer function s^2 + 2 s + 2 ------------s^2 + 2 s Multiplication performs a series interconnection. Other available operations include system inversion. See Chapter 3. such as addition. For example. “Operations on LTI Models” for more information. these operations assume appropriate functionalities when applied to LTI models.[1 0]) + tf([1 1].

[1 0]) redefines the relation between the first input and third output as an integrator.1 Quick Start extracts the subsystem mapping the first input to the third output. 1-12 . Similarly. Note that row indices select the outputs while column indices select the inputs. sys(3.1) = tf(1.

1-13 . sysd = c2d(sysc.'foh')% uses first-order hold sysc = d2c(sysd.Continuous/Discrete Conversions Continuous/Discrete Conversions The commands c2d. sysd = c2d(sysc. Various discretization/interpolation methods are available.Ts. For example. Tustin approximation with or without prewarping.Ts) % resampling at the period Ts See “Continuous/Discrete Conversions of LTI Models” on page 3-20 for more information.'tustin')% uses Tustin approx. and matched zero-pole. respectively. including zero-order hold (default). d2c.Ts) % discretization w/ sample period Ts sysc = d2c(sysd) % equivalent continuous-time model sysd1= d2d(sysd. and discrete to discrete (resampling) conversions. and d2d perform continuous to discrete. first-order hold. discrete to continuous.

sys = [tf(1.and discrete-time LTI models sys without restriction on the number of inputs or outputs.[1 1]) 1 . tf([1 5].x0) lsim(sys.[1 1 10]) tf(–1. step(sys) impulse(sys) initial(sys.x0) bode(sys) nyquist(sys) nichols(sys) sigma(sys) freqresp(sys. For MIMO systems.1 Quick Start Time and Frequency Response The following commands produce various time and frequency response plots for LTI models (see “Time and Frequency Response” on page 5-9 for more information).u. they produce an array of plots with one plot per I/O channel. For example.t.w) % % % % % % % % % step response impulse response undriven response to initial condition response to input u Bode plot Nyquist plot Nichols plot singular value plot complex frequency response These commands work for both continuous.[1 0])]. bode(sys) 1-14 .

'r'.sys2. use the syntax bode(sys1. For example. see “Plotting and Comparing Multiple Systems” on page 5-13 for more information... To superimpose and compare the responses of several LTI systems.Time and Frequency Response produces the Bode plot shown below. bode(sys1.sys2.'b--') draws the response of sys1 with a red solid line and the response of sys2 with a dashed blue line. 1-15 .. much as with the plot command.) You can also control the plot style by specifying a color/linestyle/marker for each system.sys3.

wmax] 1-16 .tfinal) bode(sys. type step(sys. range = [wmin.{wmin.wmax}) % final time = tfinal % freq. To override the default range.1 Quick Start These commands automatically determine an appropriate simulation horizon or frequency range based on the system dynamics.

sysn) where sys1. The LTI Viewer is an interactive user interface that assists you with the analysis of LTI model responses by facilitating such functions as: • Toggling between types of response plots • Plotting responses of several LTI models • Zooming into regions of the response plots • Calculating response characteristics..The LTI Viewer The LTI Viewer You can also analyze time and frequency domain responses using the LTI Viewer.. or a cell array.. you can initialize an LTI Viewer showing the step response of the LTI model sys by ltiview('step'. such as settling time • Displaying different I/O channels • Changing the plot styles of the response plots To initialize an LTI Viewer.sysn are names of LTI models in the MATLAB workspace and plottype is either a string for one of the following plot types... type ltiview ltiview can also be called with additional input arguments that allow you to specify the type of LTI model response displayed when the window is first opened.sys1. containing up to six of the following strings 'step' 'impulse' 'initial' 'lsim' 'pzmap' 'bode' 'nyquist' 'nichols' 'sigma' For example.sys) 1-17 .... The generic syntax is ltiview(plottype. see “The LTI Viewer” on page 6-1 for more information.

“The LTI Viewer.1 Quick Start For more detail on the use of the LTI Viewer and how it can be integrated into a Simulink diagram.” 1-18 . see Chapter 6.

. See “Precedence Rules” on page 2-5 for more information.. and TF.sys2) lft(sys1. Specifically. state-space sys1 and transfer function sys2).. 1-19 . ZPK. When combining LTI models of different types (for example.sys2) series(sys1.sys2.q) % % % % % % appends systems inputs and outputs general parallel connection general series connection feedback loop LFT interconnection (star product) state-space model of block diagram Note that simple parallel and series interconnections can be performed by direct addition and multiplication.) parallel(sys1. the type of the resultant model is determined by the same precedence rules as for arithmetic operations. respectively. see “Model Interconnection Functions” on page 3-16 for more information.sys2) feedback(sys1.sys2) connect(sys. Related commands include append(sys1. the ranking of the different types of LTI models from highest to lowest precedence is FRD. SS.System Interconnections System Interconnections You can derive LTI models for various system interconnections ranging from simple series connections to more complex block diagrams.

Note that an open-loop state-space model is · x = Ax + Bu + Bd (state equations) (measurements) y n = Cx + n where ( A. dlqr. pole placement.1 Quick Start Control Design Tools The Control System Toolbox supports three mainstream control design methodologies: gain selection from root locus. consider the regulation problem illustrated by Figure 1-1. C ) is a state-space realization of 100 ⁄ ( s 2 + s + 100 ) . As an example of LQG design. there is some measurement noise n . The first two techniques are covered by the rlocus and place commands. B. The goal is to regulate the plant output y around zero. The system is driven by the white noise disturbance d . The cost function J( u ) = ∞ E ( n 2 ) = 0.01 ∫0 ( 10y2 + u 2 ) dt is used to specify the trade-off between regulation performance and cost of control. 1-20 . and to form the resulting LQG regulator (lqgreg). to design the Kalman filter (kalman). and the noise intensities are given by E ( d 2 ) = 1. and linear-quadratic-Gaussian (LQG) regulation. and lqry). The LQG design tools include commands to compute the LQ-optimal state-feedback gain (lqr. See “LQG Design” on page 7-8 for more information.

[1 1 100]))% state-space plant model % Design LQ-optimal gain K K = lqry(sys. kalman. % input [u.[^ ^]).Control Design Tools Plant + d + u F(s) yn LQG regulator u+d 100 -----------------------------2 + s + 100 s y + + n Figure 1-1: Simple Regulation Loop The following commands design the optimal LQG regulator F ( s ) for this problem.1) % u = –Kx minimizes J(u) % Separate control input u and disturbance input d P = sys(:. 1-21 .0.d].1.01) % Form LQG regulator = LQ gain + Kalman filter F = lqgreg(Kest. output y % Design Kalman state estimator KEST Kest = kalman(P. sys = ss(tf(100. Note that lqry.K) The last command returns a state-space model F of the LQG regulator F ( s ) .10. and lqgreg perform discrete-time LQG design when applied to discrete plants.

F.'b-') Impulse Response 10 8 6 4 Amplitude 2 0 −2 −4 −6 −8 0 2 4 6 Time (sec. close the loop with feedback and compare the open.) 8 10 12 1-22 .1 Quick Start To validate the design. % Close loop clsys = feedback(sys.clsys.'r--'.+1) % Note positive feedback % Open. closed-loop impulse responses impulse(sys.vs.and closed-loop impulse responses with impulse.

The Root Locus Design GUI The Root Locus Design GUI You can also design a compensator using the Root Locus Design Graphical User Interface (GUI). For example. Adding a second input argument. the root locus of the closed-loop poles and their locations for the current compensator gain are drawn. See Chapter 8. 1-23 . The Root Locus Design GUI is an interactive graphical user interface that assists you in designing a compensator by providing the following features: • Tuning the value of the feedback or compensator gain • Adding/removing compensator poles and zeros directly on the root locus plot • Dragging compensator poles and zeros around in the root locus plane • Examining changes in the closed-loop response whenever the compensator is changed • Drawing boundaries on the root locus plane for parameters such as minimum damping ratio. as in rltool(sys. rltool(sys) initializes a Root Locus Design GUI with the linear time invariant (LTI) object sys as the plant. The closed-loop model is generated by placing the compensator and design model in the forward path of a negative unity feedback system. When one or two input arguments are provided. “The Root Locus Design GUI” for more information.comp) also initializes the LTI object comp as the root locus compensator. etc. simply type rltool rltool can also be called with additional input arguments that allow you to initialize the plant and compensator used in the Root Locus Design GUI. • Zooming in to regions of the root locus To initialize the Root Locus Design GUI.

1 Quick Start 1-24 .

. . . . . . . . . . . 2-45 Simulink Block for LTI Systems . 2-42 Time Delays . . . . . . . . . . . . . . . . . 2-57 References . 2-2 Creating LTI Models . . . . . . . . . . . . . 2-8 LTI Properties . . . . . . . . . . . . . . . . . . . . . . . .2 LTI Models Introduction . . . . . . . . . . . . . . . . . . 2-59 . . . . . . . . . . . . . . . . . . 2-26 Model Conversion . . . . . . . . . . . . . . . . . . . . . .

In addition. for example. In addition. C.and discrete-time systems. you can store several LTI models in an array under a single variable name. B. and an analogy between LTI systems and matrices. LTI Models You can specify LTI models as: • Transfer functions (TF). you can store experimentally collected frequency response data in an FRD. H(z) = 2 ( z – 0. dx ----.1 ) 2 • State-space models (SS). including LTI objects. See Chapter 4.1 ) (z + z + 1) -------------------------------------------( z + 0. This section introduces key concepts about the MATLAB representation of LTI models.5 ) -----------------------z ( z + 0.2 ) ( z + 0.2 LTI Models Introduction The Control System Toolbox offers extensive tools to manipulate and analyze linear time-invariant (LTI) models. Systems can be single-input/single-output (SISO) or multiple-input/multiple-output (MIMO). for example. it summarizes the basic commands you can use on LTI objects. “Arrays of LTI Models” for information on LTI arrays. precedence rules for operations. s+2 P ( s ) = --------------------------s 2 + s + 10 • Zero-pole-gain models (ZPK).= Ax + Bu dt y = Cx + Du where A. and D are matrices of appropriate dimensions. It supports both continuous. x is the state vector. for example. and u and y are the input and output vectors. 2-2 . For example. • Frequency response data (FRD) models FRD models consist of sampled measurements of a system’s frequency response.

2-3 . or ZPK model using system identification techniques. four matrices for state-space models. and frequency domain loop-shaping. These techniques include root locus analysis. the Control System Toolbox provides customized data structures (LTI objects) for each type of model.” and analyze them using the model analysis functions. in that they don’t have a parametric representation. and ZPK models using the arithmetic and model interconnection operations described in Chapter 3. SS. SS. pole placement. ZPK. ZPK. “Model Analysis Tools. Other Uses of FRD Models FRD models are unique model types available in the Control System Toolbox collection of LTI model types. LTI Objects Depending on the type of model you use. the data for your model may consist of a simple numerator/denominator pair for SISO transfer functions. These four LTI objects encapsulate the model data and enable you to manipulate LTI systems as single entities rather than collections of data vectors or matrices. you can also use them to: • Perform frequency-domain analysis on systems with nonlinearities using describing functions. described in Chapter 5. In addition to the standard operations you may perform on FRD models. SS. These are called the TF. and FRD objects. and multiple sets of zeros and poles for MIMO zero-pole-gain models or frequency and response vectors for FRD models. but analysis is restricted to frequency-domain methods. such as bode and step. and FRD models. • Validate identified models against experimental frequency response data. SS. “Operations on LTI Models. Using a variety of design techniques. you can design compensators for systems specified with TF. For FRD models. you can either: • Obtain an identified TF.” FRD models can be manipulated and analyzed in much the same way you analyze the other model types. For convenience. • Use frequency-domain analysis techniques.Introduction Using LTI Models in the Control System Toolbox You can manipulate TF. LQG optimal control.

The functions that operate on a particular object are called the object methods. or FRD for LTI objects) and have pre-defined fields called object properties. see Chapter 14. or frd. For LTI objects. “Classes and Objects” in Using MATLAB. For example. zpk. delay times.2 LTI Models Creating an LTI Object: An Example An LTI object of the type TF. For details on operations on LTI objects.[1 1 10]) creates a TF object. These may include customized versions of simple operations such as addition or multiplication. Objects are MATLAB structures with an additional flag indicating their class (TF. input or output names. that stores the numerator and denominator coefficients of the transfer function s+2 P ( s ) = --------------------------s 2 + s + 10 See “Creating LTI Models” on page 2-8 for methods for creating all of the LTI object types. P = tf([1 2].[1 1 10]) Q = 2 + P performs transfer function addition. For more details on objects. For example. tf. SS. P. ss. ZPK. “Operations on LTI Models. LTI Properties and Methods The LTI object implementation relies on MATLAB object-oriented programming capabilities. 2s + 3s + 22 Q ( s ) = 2 + P ( s ) = ---------------------------------2 s + s + 10 The object-specific versions of such standard operations are called overloaded operations. ZPK. sample time. methods. P = tf([1 2]. and input or output groups (see “LTI Properties” on page 2-26 for details). or FRD is created whenever you invoke the corresponding constructor function. SS. and object-oriented programming. these properties include the model data.” 2 2-4 . see Chapter 3.

ZPK. FRD > SS > ZPK > TF Thus ZPK takes precedence over TF. Specifically. The transfer matrix H maps inputs to outputs. an LTI system is represented by the linear input/ output map y = Hu This map is characterized by its transfer matrix H. TF or SS) the resulting model should be. TF. Such type conflicts are resolved by precedence rules. and FRD objects are ranked according to the precedence hierarchy. SS takes precedence over both TF and ZPK. In other words. If these LTI models are represented as LTI objects of different types (for example. 2-5 . certain basic operations on LTI systems are naturally expressed with a matrix-like syntax. and all operands are first converted to this type before performing the operation. Viewing LTI Systems As Matrices In the frequency domain. a function of either the Laplace or Z-transform variable. so there are as many columns as inputs and as many rows as outputs. If you think of LTI systems in terms of (transfer) matrices. and FRD takes precedence over all three. any operation involving two or more LTI models produces: • An FRD object if at least one operand is an FRD object • An SS object if no operand is an FRD object and at least one operand is an SS object • A ZPK object if no operand is an FRD or SS object and at least one is an ZPK object • A TF object only if all operands are TF objects Operations on systems of different types work as follows: the resulting type is determined by the precedence rules.Introduction Precedence Rules Operations like addition and commands like feedback operate on more than one LTI model at a time. SS. it is not obvious what type (for example. the first operand is TF and the second operand is SS).

2 ) u 1 u 2 H ( 3.1:2) provides the I/O relation between the first two inputs (column indices) and the third output (row index). Create descriptor state-space model. 1 ) H ( 3. Command Summary The next two tables give an overview of the main commands you can apply to LTI models. subsystems of a given LTI model sys can be extracted using matrix-like subscripting. 2-6 . Retrieve FRD model data. 1 ) y 2 = H ( 2. 1 ) H ( 2. 2 ) y3 for y = Hu. Generate random continuous state-space model.2 LTI Models For example. Query LTI model properties. Create an FRD model. Create discrete filter with DSP convention. Table 2-1: Creating LTI Models or Getting Data From Them Command drss dss filt frd frdata get rss Description Generate random discrete state-space model. Similarly. sys(3. the parallel connection of two LTI systems sys1 and sys2 can be expressed as sys = sys1 + sys2 because parallel connection amounts to adding the transfer matrices. 1 ) H ( 2. which is consistent with y1 H ( 1. For instance.

Get output/input/array dimensions or model order. descriptor state-space data) or convert it to cell array format. Conversion to an FRD model. Conversion to state space. Padé approximation of input delays. Create a transfer function. Conversion to zero-pole-gain.to discrete-time conversion. tf tfdata zpk zpkdata Table 2-2: Converting LTI Models Command c2d d2c d2d frd pade ss tf zpk Description Continuous.to continuous-time conversion. Create a zero-pole-gain model. Discrete. Conversion to transfer function. Retrieve transfer function data. Retrieve state-space data (respectively. Retrieve zero-pole-gain data. 2-7 . Create a state-space model. Resampling of discrete-time models.Introduction Table 2-1: Creating LTI Models or Getting Data From Them (Continued) Command set size ss ssdata. dssdata Description Set LTI model properties.

The specification of discrete-time transfer function models is a simple extension of the continuous-time case (see “Discrete-Time Models” on page 2-20). and frd. SISO or MIMO LTI models with tf. or FRD objects that store this data in a single MATLAB variable. Transfer Function Models This section explains how to specify continuous-time SISO and MIMO transfer function models. respectively. both polynomials of the Laplace variable s. ZPK. zpk. SISO Transfer Function Models A continuous-time SISO transfer function n(s) h ( s ) = ---------d(s) is characterized by its numerator n ( s ) and denominator d ( s ) . zpk. These functions take the model data as input and produce TF. ss. and frequency response data models. ZPK. and frd create transfer function models. SS. ss. This section shows how to create continuous or discrete. type h = tf(num.2 LTI Models Creating LTI Models The functions tf. state-space models. There are two ways to specify SISO transfer functions: • Using the tf command • As rational expressions in the Laplace variable s To specify a SISO transfer function model h ( s ) = n ( s ) ⁄ d ( s ) using the tf command. zero-pole-gain models.den) 2-8 . and SS models for systems whose transfer matrices have real-valued coefficients. Note: You can only specify TF. In this section you can also read about how to specify transfer functions consisting of pure gains.

See “Model Conversion” on page 2-42 for more information. unless you convert the variable s to ZPK. You can also specify transfer functions as rational expressions in the Laplace variable s by: 1 Defining the variable s as a special TF model s = tf('s'). The resulting variable h is a TF object containing the numerator and denominator data. 2 Entering your transfer function as a rational expression in s For example. 2-9 . Note: You need only define the variable s as a TF model once. H = s/(s^2 + 2*s +10). when these polynomials are ordered in descending powers of s. once s is defined with tf as in 1. For example. All of the subsequent models you create using rational expressions of s are specified as TF objects. respectively.[1 2 10]).Creating LTI Models where num and den are row vectors listing the coefficients of the polynomials n ( s ) and d ( s ). produces the same transfer function as h = tf([1 0]. you can create the transfer function h ( s ) = s ⁄ ( s 2 + 2s + 10 ) by typing h = tf([1 0].[1 2 10]) MATLAB responds with Transfer function: s -------------s^2 + 2 s + 10 Note the customized display used for TF objects.

can be concatenated to form H ( s ). There are several ways to specify MIMO transfer function models. h21 = (s+2)/(s^2+4*s+5). H = [h11. h11 = tf([1 –1]. h21] This syntax mimics standard matrix concatenation and tends to be easier and more readable for MIMO systems with many inputs and/or outputs. Alternatively. N and D) to represent the sets of numerator and denominator polynomials. “Structures and Cell Arrays” in Using MATLAB for more details on cell arrays.2 LTI Models MIMO Transfer Function Models MIMO transfer functions are two-dimensional arrays of elementary SISO transfer functions. See “Model Interconnection Functions” on page 3-16 for more details on concatenation operations for LTI systems.[1 1]). 2-10 . including: • Concatenation of SISO transfer function models • Using tf with cell array arguments Consider the rational transfer matrix s–1 ----------s+1 . to define MIMO transfer functions using tf. h21 = tf([1 2]. H(s) = s+2 --------------------------s 2 + 4s + 5 You can specify H ( s ) by concatenation of its SISO entries. you need two cell arrays (say. respectively. s = tf('s') h11 = (s–1)/(s+1). For instance. or. See Chapter 13. equivalently.[1 4 5]).

Creating LTI Models For example.[1 4 5]}.. G = tf([1 0. % cell array for D(s) H = tf(N. s – 1 #1: ----s + 1 s + 2 ------------s^2 + 4 s + 5 #2: Notice that both N and D have the same dimensions as H.2 1]) produces the gain matrix G = 10 21 2-11 .D) MATLAB responds with Transfer function from input to output. the cell array entries N{i. for the rational transfer matrix H ( s ) .j} and D{i. the two cell arrays N and D should contain the row-vector representations of the polynomial entries of N( s ) = s–1 s+2 D( s ) = s+1 s 2 + 4s + 5 You can specify this MIMO transfer matrix H ( s ) by typing N = {[1 –1]. the ijth entry of the transfer matrix H ( s ) . For a general MIMO transfer matrix H ( s )..j} should be row-vector representations of the numerator and denominator of H ij ( s ). Pure Gains You can use tf with only one argument to specify simple gains or gain matrices as TF objects.[1 2]}. For example. % cell array for N(s) D = {[1 1].

.. This produces a ZPK object h that encapsulates the z. typing h = zpk(0. Zero-Pole-Gain Models This section explains how to specify continuous-time SISO and MIMO zero-pole-gain models. For example. and the poles. the denominator roots. p n are the real or complex conjugate pairs of zeros and poles of the transfer function h ( s ) . This model is closely related to the transfer function representation: the zeros are simply the numerator roots.2 LTI Models while E = tf creates an empty transfer function. and z 1 ...k) where z and p are the vectors of zeros and poles.. See “Discrete-Time Models” on page 2-20.. and k data. [1–i 1+i 2]. –2) 2-12 ..p.. z m and p 1 . ( s – z m ) h ( s ) = k -----------------------------------------------( s – p 1 ) . SISO Zero-Pole-Gain Models Continuous-time SISO zero-pole-gain models are of the form ( s – z 1 ) ... p. There are two ways to specify SISO zero-pole-gain models: • Using the zpk command • As rational expressions in the Laplace variable s The syntax to specify ZPK models directly using zpk is h = zpk(z.. The specification for discrete-time zero-pole-gain models is a simple extension of the continuous-time case. ( s – p n ) where k is a real-valued scalar (the gain). and k is the gain..

Note: You need only define the ZPK variable s once.K) 2-13 . You can also use the command zpk to specify MIMO ZPK models. unless you convert the variable s to TF. –2). The syntax to create a p-by-m MIMO zero-pole-gain model using zpk is H = zpk(Z. MIMO Zero-Pole-Gain Models Just as with TF models.Creating LTI Models produces Zero/pole/gain: –2 s -------------------(s–2) (s^2 – 2s + 2) You can also specify zero-pole-gain models as rational expressions in the Laplace variable s by: 1 Defining the variable s as a ZPK model s = zpk('s') 2 Entering the transfer function as a rational expression in s. All subsequent rational expressions of s will be ZPK models. [2 –1–i –1+i ]. For example. See “Model Conversion” on page 2-42 for more information on conversion to other model types. H = –2s/((s – 2)*(s^2 + 2*s + 2)).P. returns the same ZPK model as h = zpk([0]. you can also specify a MIMO ZPK model by concatenation of its SISO entries (see “Model Interconnection Functions” on page 3-16). once s is defined with zpk.

P = {0.K) creates the two-input/two-output zero-pole-gain model –1 ----s 2 ( s 2 – 2s + 2 ) -------------------------------------------------(s – 1 )( s – 2 )( s – 3 ) 3(s + 5) -------------------2 (s + 1) 0 H(s) = Notice that you use [] as a place-holder in Z (or P) when the corresponding entry of H ( s ) has no zeros (or poles). Continuous-time models are of the form dx ----.[–1 –1]. Such models may arise from the equations of physics.2 LTI Models where • Z is the p-by-m cell array of zeros (Z{i.= Ax + Bu dt y = Cx + Du where x is the state vector and u and y are the input and output vectors.j} = zeros of H ij ( s ) ) • P is the p-by-m cell array of poles (P{i. K = [–1 3.[1 2 3]. or by state-space realization of the system transfer function. 2-14 .P.[]}.j) = gain of H ij ( s ) ) For example.j} = poles of H ij ( s ) ) • K is the p-by-m matrix of gains (K(i. from state-space identification.[1–i 1+i] []}. H = zpk(Z.2 0].–5. typing Z = {[]. State-Space Models State-space models rely on linear differential or difference equations to describe the system dynamics.

you can use D = 0 (zero) as a shorthand for a zero matrix of the appropriate dimensions. • B is an Nx-by-Nu real-valued matrix.= Ax + Bu dt y = Cx where θ x = dθ -----dt 0 1 –5 –2 0 3 A = B = C = 0 1 This model is specified by typing sys = ss([0 1. Ny outputs.[0.+ 5θ = 3I 2 dt dt where θ is the angular displacement of the rotor and I the driving current. consider the following simple model of an electric motor. B.0) 2-15 .B. and Nu inputs • A is an Nx-by-Nx real-valued matrix.–5 –2].Creating LTI Models Use the command ss to create state-space models sys = ss(A.[0 1].D) For a model with Nx states. C. As an illustration.C. • D is an Ny-by-Nu real-valued matrix. For models with a zero D matrix.+ 2 -----. and D. The relation between the input current u = I and the angular velocity y = dθ ⁄ dt is described by the state-space equations dx ----. This produces an SS object sys that stores the state-space matrices A. dθ d2θ --------. • C is an Ny-by-Nx real-valued matrix.3].

and y1) are displayed whenever you leave these unspecified. B. or output names. Default names (here. and D matrices. They are of the form dx E ----.= Ax + Bu dt y = Cx + Du The Control System Toolbox supports only descriptor systems with a nonsingular E matrix. input. See “LTI Properties” on page 2-26 for more information on how to specify state. While such models have an equivalent explicit form dx ----. u1. input names. Descriptor State-Space Models Descriptor state-space (DSS) models are a generalization of the standard state-space models discussed above.2 LTI Models to which MATLAB responds a = x1 x2 b = x1 x2 c = y1 d = y1 u1 0 x1 0 x2 1. C.00000 x1 0 –5.= ( E – 1 A )x + ( E – 1 B )u dt y = Cx + Du 2-16 . x2. the display of state-space models includes state names. and output names.00000 u1 0 3. x1.00000 –2.00000 In addition to the A.00000 x2 1.

The function dss is the counterpart of ss for descriptor state-space models. sys = dss(A.C.eye(n). you may only have sampled frequency response data. w n. ….D.D.+ Fω = T dt y=ω with vector ω of angular velocities. suppose the frequency response function for the SISO system you want to model is G(w). For information on frequency response analysis of linear systems. w 2.J) % n = length of vector ω Frequency Response Data (FRD) Models In some instances.B. sin w i t G(w) = yi ( t ) 2-17 . in addition. For example. Suppose. rather than a transfer function or state-space model for the system you want to analyze or control.B. that you perform an experiment to evaluate G(w) at a fixed set of frequencies.Creating LTI Models it is often desirable to work with the descriptor form when the E matrix is poorly conditioned with respect to inversion. Specifically. as depicted below.E. you can specify this system as a descriptor model by sys = dss(–F. You can do this by driving the system with a sequence of sinusoids at each of these frequencies.E) creates a continuous-time DSS model with matrix data A.0. For example. w 1. If the inertia matrix J is poorly conditioned with respect to inversion.C. see Chapter 8 of [1]. consider the dynamical model dω J ------.eye(n).

The steady state output response of this system satisfies y i ( t ) = G ( w i ) sin ( w i t + ∠G ( w i ) ) .units) where • frequencies is a real vector of length Nf. • units is an optional string for the units of frequency: either 'rad/s' (default) or 'Hz' 2-18 .. The basic syntax for creating a SISO FRD model is sys = frd(response.w i) }.2 LTI Models Here w i is the input frequency of each sinusoid. Once you store your data in an FRD model. and manipulate an FRD model in most of the same ways you manipulate TF. along with a corresponding vector of frequency points) that you obtain either through simulations or experimentally.. you can treat it as an LTI model. • response is a vector of length Nf of complex frequency response values for these frequencies. i = 1 . i = 1…n . n.frequencies. In this example. SS. the frequency response data is obtained from the set of response pairs: { (G ( w i ). i = 1…n A frequency response data (FRD) object is a model form you can use to store frequency response data (complex frequency response. and G(w) = G ( w ) exp ( j ∠G ( w ) ) . and ZPK models.

812505 –0.000312i –0..j.:) specifies the array of frequency response data from input j to output i at frequency frequency(k) 2-19 .mat contains a frequency vector freq. type load LTIexamples sys = frd(respG. m is the number of inputs. To load this frequency-domain data and construct an FRD model.000390i The syntax for creating a MIMO FRD model is the same as for the SISO case.Creating LTI Models For example. From input 1 to: Frequency(rad/s) ---------------1 2 4 5 output 1 -------–0. The following table summarizes the complex-valued response data format for FRD models..freq) Continuous-time frequency response with 1 output and 1 input at 5 frequency points.k. and Nf is the number of frequency data points (the length of frequency). Table 2-3: Data Format for the Argument response in FRD Models Model Form Response Data Format SISO model MIMO model with Ny outputs and Nu inputs S1-by-.-by-Sn array of models with Ny outputs and Nu inputs Vector of length Nf for which response(i) is the frequency response at the frequency frequency(i) Ny-by-Nu-by-Nf multidimensional array for which response(i. the MAT-file LTIexamples.043735 –0. where p is the number of outputs.. except that response is a p-by-m-by-Nf multidimensional array. for which response(i.075781 –0.092593 –0.-by-Sn multidimensional array.j..001625i –0. and a corresponding complex frequency response data vector respG.k) specifies the frequency response from input j to output i at frequency frequency(k) Ny-by-Nu-by-S1-by-.462963i –0.

and sys = ss(A.d.2 LTI Models Discrete-Time Models Creating discrete-time models is very much like creating continuous-time models.C.0.3].1) creates the discrete-time transfer function h ( z ) = ( z – 1 ) ⁄ ( z – 0.0.den.2]. ss.B. By convention.5 ) with sample time 0. and output vectors at the nth sample. u [ n ].k.Ts) zpk(z. h = tf([1 –0. y [ n ] denote the values of the state. To specify discrete-time LTI models using tf. Setting Ts = –1 leaves the sample time of a discrete-time model unspecified.D. zpk.p.c. except that you must also specify a sampling period or sample time for discrete-time models.b.frequency.5) specifies the discrete-time state-space model x [ n + 1 ] = Ax [ n ] + Bu [ n ] y [ n ] = Cx [ n ] + Du [ n ] with sampling period 0.Ts) frd(response.5 second. The sample time value should be scalar and expressed in seconds. or frd.Ts) For example. the sample time of continuous-time models is Ts = 0.–1) 2-20 . input.[1 –0.[1 0. sys1 sys2 sys3 sys4 = = = = tf(num.1 seconds. For example. h = tf([1 –1]. You can also use the value –1 to leave the sample time unspecified.5].Ts) ss(a. simply append the desired sample time value Ts to the list of inputs. The vectors x [ n ].

0.Creating LTI Models produces Transfer function: z – 0. H = (z+2)/(z^2 + 0.6*z + 0.1).2 ------z + 0. 2-21 . This procedure is described in “SISO Transfer Function Models” on page 2-8 and “SISO Zero-Pole-Gain Models” on page 2-12. it is often convenient to specify such models by: 1 Defining the variable z as a particular discrete-time TF or ZPK model with the appropriate sample time 2 Entering your TF or ZPK model directly as a rational expression in z.9).1). 0. creates the same TF model as H = tf([1 2]. Discrete-Time TF and ZPK Models You can specify discrete-time TF and ZPK models using tf and zpk as indicated above. [1 0. Alternatively. If you forget to specify the sample time when creating your model.9]. This would make h a continuous-time transfer function.6 0.3 Sampling time: unspecified Note: Do not simply omit Ts in this case. z = tf('z'. This approach parallels the procedure for specifying continuous-time TF or ZPK models using rational expressions. See “Sample Time” on page 2-34 for more information on setting this property. For example. you can still set it to the correct value by reassigning the LTI property Ts.

1)^2 #2: Sampling time: 0.5].2) (z^2 + 0.2 LTI Models Similarly. h = tf([1 0. For example.5] and [1 2 3].1)/(z+0. (z^2+0. z = zpk('z'.1). When the numerator and denominator have different degrees.–1) and leaves the sample time unspecified.5z –1 H ( z – 1 ) = --------------------------------------1 + 2z – 1 + 3z –2 would be specified as the row vectors [1 0.2*z+0. Discrete Transfer Functions in DSP Format In digital signal processing (DSP).2z + 0. • Once you have defined z as indicated above. For example. this convention clashes with the “descending powers of z ” convention assumed by tf (see “Transfer Function Models” on page 2-8.1)/(z^2+0.1 Note that: • The syntax z = tf('z') is equivalent to z = tf('z'.[1 2 3]) 2-22 . or tf on page 11-224). The same applies to z = zpk('z'). the numerator and denominator of 1 + 0. 0.1) (z+0. it is customary to write discrete transfer functions as rational expressions in z – 1 and to order the numerator and denominator coefficients in ascending powers of z – 1. H = [z/(z+0.1) -----------------(z+0. z #1: --------------(z+0.2*z+0. respectively.2) .01)] produces the single-input. two-output ZPK model Zero/pole/gain from input to output.. any rational expressions in z creates a discrete-time model of the same type and with the same sample time as z..

5 --------------------------2 + 2z + 3 z which differs from H ( z – 1 ) by a factor z . but expects num and den to list the numerator and denominator coefficients in ascending powers of z – 1 .den) for discrete transfer functions with unspecified sample time. Just as for tf. Its syntax is h = filt(num.5].5 z^–1 ------------------1 + 2 z^–1 + 3 z^–2 Sampling time: unspecified You can also use filt to specify MIMO transfer functions in z – 1. For example. typing h = filt([1 0. the input arguments num and den are then cell arrays of row vectors of appropriate dimensions (see “Transfer Function Models” on page 2-8 for details).Creating LTI Models produces the transfer function z + 0. To avoid such convention clashes.[1 2 3]) produces Transfer function: 1 + 0.den.Ts) to further specify the sample time Ts. and h = filt(num. Note that each row vector should comply with the “ascending powers of z –1 ” convention. 2-23 . the Control System Toolbox offers a separate function filt dedicated to the DSP-like specification of transfer functions. This function creates TF objects just like tf.

are cell arrays. The ones listed here correspond to the model property names described in Tables 2-2 – 2.2 LTI Models Data Retrieval The functions tf.b. as many columns as inputs.Ts] = ssdata(sys) [a.Ts] = dssdata(sys) [response. can only be an FRD model You can use any variable names you want in the output argument list of any of these functions. zpk. ss.c.den.e.den] = tfdata(H).b. den{1.1} 1 -s 2-24 .frequency.1}.Ts] = frdata(sysfr) Note that: • sys can be any type of LTI object.p.k.d. or FRD model sysfr.[1 2 10]) .c.d.5. tf(1. For example. and z and p assigned to zpkdata. and their ijth entry specifies the transfer function from the jth input to the ith output. The output arguments num and den assigned to tfdata. Conversely.[1 0])] creates the one-output/two-input transfer function s–1 H ( s ) = -----------------------------s 2 + 2s + 10 Typing [num.Ts] = tfdata(sys) % Ts = sample time [z. These cell arrays have as many rows as outputs. and frd pack the model data and sample time in a single LTI object. the input argument to frdata. SS. H = [tf([1 –1]. num{1. except an FRD model • sysfr.Ts] = zpkdata(sys) [a. even in the SISO case. [num. or ZPK model sys. the following commands provide convenient data retrieval for any type of TF.

H.den] = tfdata(sys.[1 2 5]).Ts] = zpkdata(sys.'v') produces num = 0 den = 1 2 5 1 3 Similarly.den{1.k. as vectors for SISO systems.Ts] = tfdata(sys. typing sys = tf([1 3].'v') returns the zeros.p. ans = 0 ans = 1 1 2 –1 10 Note that the same result is obtained using H. p. use the syntax [num.1} See “Direct Property Referencing” on page 2-33 for more information about this syntax.den.Creating LTI Models displays the coefficients of the numerator and denominator of the first input channel. 2-25 . and the poles. To obtain the numerator and denominator of SISO systems directly as row vectors. [z. z.num{1. [num.1}.'v') For example.

to LTI objects. i.. and FRD objects. ZPK. We distinguish between generic properties. common to all four types of LTI objects. ZPK. They are listed in the table below. SS. You also have the option to attribute additional information. These fields have names (the property names) and are assigned values (the property values). From a data structure standpoint. such as the input names or notes on the model history. This section gives a complete overview of the LTI properties. and model-specific properties that pertain only to one particular type of model. ZPK.2 LTI Models LTI Properties The previous section shows how to create LTI objects that encapsulate the model data and sample time. Generic Properties The generic properties are those shared by all four types of LTI models (TF. SS. and FRD objects). and FRD objects. Type help ltiprops for online help on available LTI properties. Table 2-4: Generic LTI Properties Property Name IoDelayMatrix InputDelay InputGroup InputName Notes OutputDelay OutputGroup OutputName Ts Userdata Description Property Value I/O delay(s) Input delay(s) Input channel groups Input channel names Notes on the model history Output delay(s) Output channel groups Output channel names Sample time Additional data Matrix Vector Cell array Cell vector of strings Text Vector Cell array Cell vector of strings Scalar Arbitrary 2-26 . the LTI properties are the various fields in the TF. SS. the various pieces of information that can be attached to the TF.e.

For more detailed information on how to use LTI properties. See “Input Groups and Output Groups” on page 2-37 for more information. For example. For example. Their default value is zero (no delay).LTI Properties The sample time property Ts keeps track of the sample time (in seconds) of discrete-time systems. Using the InputGroup and OutputGroup properties of LTI objects. and the last input as noise. The InputDelay. Finally. and assign names to the groups. The value of each of these properties is a cell vector of strings with as many cells as inputs or outputs. The default value is a cell of empty strings. Ts is 0 (zero) for continuous-time systems. 'pressure' } for a system with two outputs labeled temperature and pressure. OutputDelay. and ioDelayMatrix properties allow you to specify time delays in the input or output channels. while the Userdata property can accommodate arbitrary user-supplied data. The Notes property is dedicated to any text you want to supply with your model. They are both empty by default. and Ts is –1 for discrete-time systems with unspecified sample time. even for MIMO systems. you can create different groups of input or output channels. See “Time Delays” on page 2-45 for details on modeling delays. or for each input/output pair. 2-27 . see “Additional Insight into LTI Properties” on page 2-34. Ts is always a scalar. you may want to designate the first four inputs of a five-input model as controls. The InputName and OutputName properties enable you to give names to the individual input and output channels. Notes and Userdata are available to store additional information on the model. By convention. the OutputName property is set to { 'temperature' .

'q'. Table 2-5: TF-Specific Properties Property Name den num Variable Description Property Value Denominator(s) Numerator(s) Transfer function variable Real cell array of row vectors Real cell array of row vectors String 's'. or 'z^–1' Table 2-6: ZPK-Specific Properties Property Name k p Variable Description Property Value Gains Poles Transfer function variable Zeros Two-dimensional real matrix Cell array of column vectors String 's'. these are summarized in the following four tables. See set on page 11-193 for more information on these values. SS. or 'z^–1' Cell array of column vectors z Table 2-7: SS-Specific Properties Property Name a b c d Description Property Value State matrix A Input-to-state matrix B State-to-output matrix C Feedthrough matrix D 2-D real matrix 2-D real matrix 2-D real matrix 2-D real matrix 2-28 . For single LTI models. 'z'. 'q'. 'p'. or FRD). 'z'. 'p'. The property values differ for LTI arrays. ZPK.2 LTI Models Model-Specific Properties The remaining LTI properties are specific to one of the four model types (TF.

the StateName property is analogous to the InputName and OutputName properties and keeps track of the state names in state-space models. Note that tf produces the same result as filt when the Variable property is set to 'z^–1' or 'q'. The default values are 's' (Laplace variable s ) in continuous time and 'z' (Z-transform variable z ) in discrete time. One exception is the specification of discrete-time transfer functions with tf (see tf on page 11-224 for details). Note that the E matrix is set to [] (the empty matrix) for standard state-space models. 2-29 . a storage-efficient shorthand for the true value E = I . This property defines the frequency variable of transfer functions. The influence of the variable choice is mostly limited to the display of TF or ZPK models. Alternative choices include 'p' (equivalent to s ) and 'q' or 'z^–1' for the reciprocal q = z – 1 of the z variable.LTI Properties Table 2-7: SS-Specific Properties (Continued) Property Name e StateName Description Property Value Descriptor E matrix State names 2-D real matrix Cell vector of strings Table 2-8: FRD-Specific Properties Description Property Value Property Name Frequency ResponseData Frequency data points Frequency response Units for frequency Real-valued vector Complex-valued multidimensional array String 'rad/s' or 'Hz' Units Most of these properties are dedicated to storing the model data. The Variable property is only an attribute of TF and ZPK objects. Finally.

This section discusses the first two options. Actually. or frd.” and an output called “temperature. zpk. For example. 'user' is sufficient to refer to the Userdata property. The function set for LTI objects follows the same syntax as its Handle Graphics counterpart.3s delay 1 ----------s+1 temperature Figure 2-1: A Simple Heater Model You can use a TF object to represent this delay system. • You can also set property values using structure-like assignments. • PropertyValue is the value to assign to the property (see set on page 11-193 for details on admissible property values). As an illustration. 2-30 . you need only type any abbreviation of the property name that uniquely identifies the property.” energy e – 0.2 LTI Models Setting LTI Properties There are three ways to specify LTI property values: • You can set properties when creating LTI models with tf.PropertyValue where • PropertyName is a string specifying the property name. See “Direct Property Referencing” on page 2-33 for details on the third option.3 seconds. the input and output names. You can type the property name without regard for the case (upper or lower) of the letters in the name. and the model history by setting the corresponding LTI properties. Specifically. an input called “energy. • You can set or modify the properties of an existing LTI model with set. ss. each property is updated by a pair of arguments PropertyName. or by using the set command. consider the following simple SISO model for a heating system with an input delay of 0. and specify the time delay. You can either set these properties directly when you create the LTI model with tf.

you can also use the set command to obtain a listing of all settable properties for a given LTI model type. and Notes to sys.3)...'inputname'.PropertyName) 2-31 .'A simple heater model') Finally. set(sys.'Inputdelay'.0. The syntax is PropertyValue = get(sys. OutputName. of inputs) den: Ny-by-Nu cell of row vectors (Ny = no.. you can specify the delay directly when you create the model.'outputname'.[1 1]. of outputs) Variable: [ 's' | 'p' | 'z' | 'z^-1' | 'q' ] Ts: scalar InputDelay: Nu-by-1 vector OutputDelay: Ny-by-1 vector ioDelayMatrix: Ny-by-Nu array (I/O delays) InputName: Nu-by-1 cell array of strings OutputName: Ny-by-1 cell array of strings InputGroup: M-by-2 cell array if M input groups OutputGroup: P-by-2 cell array if P output groups Notes: array or cell array of strings UserData: arbitrary Accessing Property Values Using get You access the property values of an LTI model sys with get.'energy'. along with valid values for these properties. and then use the set command to assign InputName. sys = tf(1. 'notes'. For the transfer function sys created above set(sys) produces num: Ny-by-Nu cell of row vectors (Nu = no.LTI Properties For example.'temperature'.

'A simple circuit') get(h.. This topic is explained in the next section.[1 5 100].. 'outputn'. 'notes'. or any abbreviation with enough characters to identify the property uniquely. For example.2 LTI Models where the string PropertyName is either the full property name. use the syntax get(sys). Finally. In this example. 2-32 ...'current'. typing h = tf(100. get(h) produces num: {[0 0 100]} den: {[1 5 100]} Variable: 's' Ts: 0 InputDelay: 0 OutputDelay: 0 ioDelayMatrix: 0 InputName: {'voltage'} OutputName: {'current'} InputGroup: {0x2 cell} OutputGroup: {0x2 cell} Notes: {'A simple circuit'} UserData: [] Notice that default (output) values have been assigned to any LTI properties in this list that you have not specified..'notes') produces ans = 'A simple circuit' To display all of the properties of an LTI model sys (and their values).'voltage'..'inputname'. you can also access property values using direct structure-like referencing.

ZPK. SS.a = –1. You only need to type the minimum number of characters sufficient to identify the property name uniquely. sys.PropertyValue) For example. ans = 1 Similarly.2. The field names for LTI objects are the property names. Recall that LTI objects are basic MATLAB structures except for the additional flag that marks them as TF.4. Thus either of the commands sys. or FRD objects (see page 2-3).'PropertyName') set(sys.a and you get the value of the property “a” for the state-space model sys.3.LTI Properties Direct Property Referencing An alternative way to query/modify property values is by structure-like referencing. resets the state transition matrix for sys to –1. so you can retrieve or modify property values with the structure-like syntax. Unlike standard MATLAB structures. type sys = ss(1.'PropertyName'.PropertyName% gets property value sys.'InputName'. sys.InputName sys.inputn 2-33 .PropertyName = PropertyValue% sets property value These commands are respectively equivalent to PropertyValue = get(sys. PropertyValue = sys. you do not need to type the entire field name or use upper-case characters. See “LTI Arrays of SS Models with Differing Numbers of States” on page 4-23 for information on setting the properties of LTI arrays of state-space models with different numbers of states in each model.'u').

OutputDelay.0. type h = tf([1 0]. To do this.[2 1 1]. For detailed information on the use of InputDelay. For example.num{1}(2) = 2. Sample Time The sample time property Ts is used to specify the sampling period (in seconds) for either discrete-time or discretized continuous-time LTI models. and ioDelayMatrix.'variable'.[1. InputName.5 seconds. For basic information on Notes and Userdata. InputGroup. and OutputGroup LTI properties through a set of examples. Additional Insight into LTI Properties By reading this section. you can reset the numerator to p + 2 by typing h. OutputName. given the TF model h ( p ) = 1 ⁄ p h = tf(1. 2-34 . see “Generic Properties” on page 2-26. or equivalently. see “Time Delays” on page 2-45. with h.0]. you can learn more about using the Ts.5).'p').num{1} = [1 2]. Suppose you want to specify z H ( z ) = --------------------------2z 2 + z + 1 as a discrete-time transfer function model with a sampling period of 0.2 LTI Models produces ans = 'u' Any valid syntax for structures extends to LTI objects.

LTI Properties This sets the Ts property to the value 0. For example. The sample time of the resultant model is unspecified if all operands have unspecified sample times.–1) produces Transfer function: 1 ----z – 1 Sampling time: unspecified The same result is obtained by using the Variable property. all specified sample times must be identical. set Ts to – 1. get(h.1) 2-35 . With this inheritance rule for Ts.5000 For continuous-time models.0. the sample time property Ts is 0 by convention.[1 –1].'var'.Ts ans = 0.5].0.'z') In operations that combine several discrete-time models.[1 0.'Ts') ans = 0 To leave the sample time of a discrete-time LTI model unspecified.5.1.–1) and tf(0. type h = tf(1.[1 0]).[1 –1].5]. as is confirmed by h. the following two models are equivalent.[1 –1].[1 0. tf(0. For example.1. h = tf(1.[1 –1].1) + tf(1.1) + tf(1.0. h = tf(1. and the resulting discrete-time model inherits this common sample time.

'velocity'. set(h. ??? Error using ==> lti/plus In SYS1+SYS2.5) returns an error message.'velocity'.. The command set(sys.1.1) + tf(1.1) to discretize a continuous system sys at a 10Hz sampling rate..'p') Equivalently.. 'variable'.0.'outputname'.. output velocity.1) only affects the Ts property and does not alter the remaining model data. Use c2d and d2c to perform continuous-to-discrete and discrete-to-continuous conversions.'inputname'.'p') 2-36 . 'outputname'.[1 –1]..2 LTI Models Note that tf(0.. and transfer function H ( p ) = 1 ⁄ ( p + 10 ) by typing h = tf(1.[1 10]).[1 10]. Caution: Resetting the sample time of a continuous-time LTI model sys from zero to a nonzero value does not discretize the original model sys..'thrust'.'thrust'.0.'inputname'.. use sysd = c2d(sys..0.0.5].[1 0. Input Names and Output Names You can use the InputName and OutputName properties (in short. Use d2d to change the sample time of a discrete-time system and resample it. you can set these properties directly by typing h = tf(1. both models must have the same sample time. you can create a SISO model with input thrust. 'variable'. For example.'Ts'. I/O names) to assign names to any or all of the input and output channels in your LTI model. For example.

den). H = tf(num.{'temperature' . use the empty string '' as in H = tf(num. '' }) Input Groups and Output Groups In many applications. [1 2]}.'inputname'. In the MIMO case. type num = {3 . % H(s) has one output and two inputs set(H. For example.den. For example. you may want to create several (distinct or intersecting) groups of input or output channels and name these groups. Transfer function from input "temperature" to output: 3 -----s + 10 Transfer function from input "pressure" to output: s + 2 ----s To leave certain names undefined.{ 'temperature' . 'pressure'}) The specified input names appear in the display of H.LTI Properties This produces Transfer function from input "thrust" to output "velocity": 1 -----p + 10 Note how the display reflects the input and output names and the variable selection. den = {[1 10] . 2-37 .'inputname'. use cell vectors of strings to specify input or output channel names. you may want to label one set of input channels as noise and another set as controls. [1 0]}.

the first output to a group named temperature. three inputs. 2-38 . and three outputs.2 LTI Models To see how input and output groups (I/O groups) work: 1 Create a random state-space model with one state. 2 Assign the first two inputs to a group named controls. and the last two outputs to a group named measurements.

12533 u2 0 u3 0 c = y1 y2 y3 x1 1. 'InputGroup'. 2-39 .3.{[1 2] 'controls'}) set(h.1909 1. set(h.3).32729 0 0 u2 0 0 2.LTI Properties To do this.3 Continuous-time model.1892 0 d = y1 y2 y3 I/O Groups: Group Name controls temperature measurements u1 0. type h = rss(1.1364 0 0 I/O I O O Channel(s) 1. {[1] 'temperature'.1832 u3 –0.64884 b = x1 u1 0. 'OutputGroup'.2 1 2. [2 3] 'measurements'}) h and MATLAB returns a state-space model of the following form. a = x1 x1 –0.

• You can add input (or output) groups by appending rows to the cell array. 2-40 .InputGroup = [h. Channels for Group M . Vectors of Channel Indices Group Names { Channels for Group 1 Channels for Group 2 . • You can choose not to assign any of the group names when you assign the groups.Empty strings are assigned to the group names by default. {[3] 'disturbance'}]. . to specify M input groups (or output groups). In that case. In general. .If you append rows to a cell array with no group names assigned. you need an M-by-2 cell array organized as follows. Name for Group 2. adds another input group called disturbance to h.InputGroup. Name for Group M } Figure 2-2: Two Column Cell Array When you specify the cell array for input (or output) groups. .2 LTI Models Notice that the middle column of the I/O group listing indicates whether the group is an input group (I) or an output group (O). and leave off the second column of this array. you have to assign empty strings ('') to the group names. Name for Group 1. keep in mind: • Each row of this cell array designates a different input (output) group. For example. h.

inputgroup{1. to add channel three to the input group controls.LTI Properties You can use regular cell array syntax for accessing or modifying I/O group components.1} 3] or. type h.:) = [] ans = [1x2 double] 'measurements' Similarly.inputgroup{1.1} = [1 2 3] 2-41 . equivalently. type h. to delete the first output group. For example.OutputGroup(1.1} = [h. h.inputgroup{1. you can add or delete channels from an existing input or output group. Recalling that input group channels are stored in the first column of the corresponding cell array. temperature.

SS. and frd. zpk.333) ----------(s+2) Note that the transfer function of a state-space model with data ( A. you can convert the state-space model sys = ss(–2. B. the syntax for conversion to another model type is sys = tf(sys) sys = zpk(sys) sys = ss(sys) sys = frd(sys. ss. For example. or ZPK model sys.1. D ) is H ( s ) = D + C ( sI – A ) B –1 2-42 .1. This section shows how to convert models from one type to the other. Given any TF. In addition. C.2 LTI Models Model Conversion There are four LTI model types you can use with the Control System Toolbox: TF.frequency) % Conversion to TF % Conversion to ZPK % Conversion to SS % Conversion to FRD Notice that FRD models can’t be converted to the other model types. and FRD. ZPK. Explicit Conversion Model conversions are performed by tf.3) to a zero-pole-gain model by typing zpk(sys) to which MATLAB responds Zero/pole/gain: 3 (s+2. you must also include a vector of frequencies (frequency) as an input argument when converting to an FRD model. SS.

the algorithm for zero-order-hold discretization with c2d can only be performed on state-space models. For example. ZPK. For this reason. commands like tfdata expect one particular type of LTI models (TF). and SS. such commands automatically convert LTI models to the appropriate or required model type. in commands like initial or kalman. Similarly. it is often preferable to work with the state-space representation.1. Caution About Model Conversions When manipulating or converting LTI models. You get this type of 2-43 . automatic conversions to state space are disabled when the result depends on the choice of state coordinates. –1 Automatic Conversion Some algorithms operate only on one type of LTI model. Therefore. In particular. the accuracy of computations using high-order transfer functions is often poor. it is often beneficial to balance and scale state-space models using ssbal. For convenience. and H ( z ) = D + C ( zI – A ) B for discrete-time models.0) [num. For example. keep in mind that: • The three LTI model types TF. are not equally well-suited for numerical computations.Model Conversion for continuous-time models. Note that conversions to state-space models are not uniquely defined.den] = tfdata(sys) tfdata first converts the state-space model sys to an equivalent transfer function in order to return numerator and denominator data. In addition. for example. in sys = ss(0.1.

ss(tf(sys)) may return a model with different state-space matrices. if possible. • Conversions to the transfer function representation using tf may incur a loss of accuracy. Therefore. the transfer function poles may noticeably differ from the poles of the original zero-pole-gain or state-space model. For a given state-space model sys. or even a different number of states in the MIMO case. nor are they guaranteed to produce a minimal realization in the MIMO case. it is best to avoid converting back and forth between state-space and other model types. As a result.2 LTI Models balancing automatically when you convert any TF or ZPK model to state space using ss. • Conversions to state space are not uniquely defined in the SISO case. 2-44 .

parallel. For example.1s H(s) = 2 -s e e – 0. With these properties. and OutputDelay either when first creating your model with the tf. and feedback interconnections of discrete-time models with delays 2-45 . ss. InputDelay. you can specify delays in both continuous.and discrete-time LTI models.3s – 0. and θ is the time delay between x ( t ) and the output y ( t ) . or frd constructors. zpk. for example.Time Delays Time Delays Using the ioDelayMatrix. or later with the set command (see “LTI Properties and Methods” on page 2-4 for details). InputDelay. the continuous-time model with transfer function e –0. you can. and OutputDelay properties of LTI objects. Supported Functionality Most analysis commands support time delays.2s 10 s+1 -------------s + 10 s–1 ----------s+5 • State-space models with delayed inputs and/or delayed outputs. For example. · x ( t ) = Ax ( t ) + Bu ( t – τ ) y ( t ) = Cx ( t – θ ) + Du ( t – ( θ + τ ) ) where τ is the time delay between the input u ( t ) and the state vector x ( t ) . represent: • LTI models with independent delays for each input/output pair. You can assign the delay properties ioDelayMatrix. including: • All time and frequency response commands • Conversions between model types • Continuous-to-discrete conversions (c2d) • Horizontal and vertical concatenation • Series.

p. and τ ij is the time delay between input j and output i .k. den (respectively..'iodelaymatrix'..Tau) or H = zpk(z. We collectively refer to the scalars τ ij as the I/O delays. That is. k) specify the rational part [ h ij ( s ) ] of the transfer function H ( s ) • Tau is the matrix of time delays for each I/O pair.den.. In continuous time. Note that Tau and H ( s ) should have the same row and column dimensions.'iodelaymatrix'..B. e – sτ p m where the h ij ’s are rational functions of s . as in sys = ss(A. The syntax to create H ( s ) above is H = tf(num. See “Specifying Delays in Discrete-Time Models” on page 2-52 for details on the discrete-time counterpart.C.2 LTI Models • Interconnections of continuous-time delay systems as long as the resulting transfer function from input j to output i is of the form exp ( – sτ ij ) h ij ( s ) where h ij ( s ) is a rational function of s • Padé approximation of time delays (pade) Specifying Input/Output Delays Using the ioDelayMatrix property. Tau(i.Tau) where • num. z. You can also use the ioDelayMatrix property in conjunction with state-space models. such models have a transfer function of the form e H(s) = e – sτ p 1 – sτ 11 h 11 ( s ) : .p. e – sτ 1 m h 1m ( s ) : = [ exp ( – sτ ij ) h ij ( s ) ] h pm ( s ) h p1 ( s ) .'iodelaymatrix'.j) specifies the I/O delay τ ij in seconds.Tau) 2-46 . you can specify frequency-domain models with independent delays in each entry of the transfer function.D.

H(s) = exp ( – sτ ij ) r ij ( s ) Here r ij ( s ) is the ( i. The process of interest is the distillation column depicted by the figure below. be described by state-space equations with delayed inputs and outputs. This column is used to separate a mix of methanol and water (the feed) into bottom products (mostly water) and a methanol-saturated distillate. They cannot. in general. j ) entry of R ( s ) = D + C ( sI – A ) B –1 Note: State-space models with I/O delays have only a frequency-domain interpretation.Time Delays This creates the LTI model with the following transfer function. Distillation Column Example This example is adapted from [2] and illustrates the use of I/O delays in process modeling. 2-47 .

2 LTI Models Enriched vapor Cooling water Condensate Distillate Feed Reflux Reboiler Vapor Steam flow Bottom liquid Figure 2-3: Distillation Column Bottom products Schematically. water tends to flow downward and accumulate as the bottom liquid • The vapor exiting at the top of the column is condensed by a flow of cooling water. and the rest of the condensate (the reflux) is sent back to the column. tends to concentrate in the vapor moving upward. being more volatile than water. • Part of the bottom liquid is collected from the reboiler as bottom products (waste). 2-48 . Meanwhile. the distillation process functions as follows: • Steam flows into the reboiler and vaporizes the bottom liquid. Part of this condensed vapor is extracted as the distillate. This vapor is reinjected into the column and mixes with the feed • Methanol.

9..8 –18.4e 6.[1 3. You can specify this MIMO transfer function by typing H = tf({12.Time Delays The regulated output variables are: • Percentage X D of methanol in the distillate • Percentage X B of methanol in the bottom products. 'Xb'}) 2-49 ..0s + 1 R ( s ) – 7s – 3s S ( s ) – 19.6.8e – 18... 'outputname'. 'S'}.6 –19..4}.[10.9s + 1 14... The goal is to maximize X D by adjusting the reflux flow rate R and the steam flow rate S in the reboiler.7 1] [21 1].4s + 1 – 1s – 3s XD ( s ) XB ( s ) = Note the different time delays for each input/output pair.7 3].{'R' .------------------------16.7e + 1 21. The resulting transfer function model is 12.9e ----------------------. 'inputname'. the transient responses to pulses in steam and reflux flow are fitted by first-order plus delay models.{'Xd' . To obtain a linearized model around the steady-state operating conditions.------------------------10..4 1]}.9 1] [14.. {[16.. 'iodelay'.6e ----------------------...

these two models have different state trajectories since x ( t ) and z ( t ) are related by z ( t ) = x ( t – 0. they cannot be distinguished using the ioDelayMatrix property (the I/O delay value is 0.4 s + 1 Xb: Specifying Delays on the Inputs or Outputs While ideal for frequency-domain models with I/O delays. For example...6 exp(–7*s) * ---------10.. Yet.8 Xd: exp(–1*s) * ---------16..2 LTI Models The resulting TF model is displayed as Transfer function from input "R" to output.7 s + 1 6.1 ) – 0.1 ) 2-50 . the ioDelayMatrix property is inadequate to capture delayed inputs or outputs in state-space models.4 exp(–3*s) * ---------14.1 ) y(t ) = x( t) share the same transfer function e h ( s ) = --------------s+1 As a result. the two models · ( M 1 ) x ( t ) = – x ( t ) + u ( t – 0.9 Xd: exp(–3*s) * -------21 s + 1 –19. –18.1s · ( M2 ) z ( t ) = –z ( t ) + u( t ) y ( t ) = z ( t – 0.9 s + 1 Xb: Transfer function from input "S" to output.1 seconds in both cases). 12.

For example. For example. you can create the transfer function 1 -s H(s) = 2 ----------s+1 by typing s = tf('s').3 ) = C 2 x ( t ) + D 21 u 1 ( t – 0.0.[D11 D12.Time Delays Note that the 0.inputdelay = 0.[B1 B2].1 ) + D 22 u 2 ( t ) You can also use the InputDelay and OutputDelay properties to conveniently specify input or output delays in TF. InputDelay and OutputDelay Properties When the state trajectory is of interest.1) M2 = ss(–1. you can accurately specify the two models above by M1 = ss(–1. H.inputdelay = [0.2 ) = C 1 x ( t ) + D 11 u 1 ( t – 0.outputdelay = [0. H = [1/s . and on the output in the second model.1 second delay is on the input in the first model. or FRD models.0.1.[C1.'outputdelay'. 2/(s+1)].0.1 ) + B 2 u 2 ( t ) y 1 ( t + 0.1.C2]. two-output model · x ( t ) = Ax ( t ) + B 1 u 1 ( t – 0.1 0] sys. you should use the InputDelay and OutputDelay properties to distinguish between delays on the inputs and delays on the outputs in state-space models. you can specify a different delay for each input (or output) channel by assigning a vector value to InputDelay (or OutputDelay). sys = ss(A.1 % rational part e – 0.D21 D22]) sys. For example.1) In the MIMO case.1.3] creates the two-input.1 ) + D 12 u 2 ( t ) y 2 ( t + 0. ZPK.1s 2-51 .0.2 0.1.'inputdelay'.

iodelay = [0..[1 0. More generally. the equivalent I/O delay matrix is α1 + β 1 α1 + β2 : α 1 + βp α 2 + β1 α 2 + β2 : α2 + β p .0.. and OutputDelay properties to specify delays in discrete-time LTI models. InputDelay.1*s) * s 2 exp(–0.5 0.. α m ] and output delays [ β 1. or FRD model with input delays [ α 1.2]. αm + β 1 αm + β 2 : αm + βp Specifying Delays in Discrete-Time Models You can also use the ioDelayMatrix..1 .1]. 2/(s+1)].. . You specify time delays in discrete-time models with integer multiples of the sampling period. Such a delay contributes a factor z to the transfer function. The integer k you supply for the time delay of a discrete-time model specifies a time delay –k of k sampling periods.. ZPK.1*s) * ----s + 1 #2: By comparison. to produce an equivalent transfer function using the ioDelayMatrix property. . for a TF.. Notice that the 0.'inputdelay'. 0. you would need to type H = [1/s .. .1 second delay is repeated twice in the I/O delay matrix.. 1 #1: exp(–0.2 LTI Models The resulting model is displayed as Transfer function from input to output..3) 2-52 . β p ] .1. h = tf(1. H.. For example..

Mapping Discrete-Time Delays to Poles at the Origin Since discrete-time delays are equivalent to additional poles at z = 0 . H1 is a more efficient representation both in terms of storage and subsequent computations.Ts) % 1/(z^3–z^2) While these two models are mathematically equivalent.'inputdelay'.Time Delays produces the discrete-time transfer function Transfer function: 1 z^(–3) * ----------------z^2 + 0.Ts.[1 –1]. % sampling period H1 = tf(1. they can be easily absorbed into the transfer function denominator or the state-space equations. When necessary. For example.5 z + 0.2) –2 or directly as a third-order transfer function: H2 = tf(1.2 Sampling time: 0.[1 –1 0 0]. H2 = delay2z(H1) 2-53 .1 Notice the z^(–3) factor reflecting the three-sampling-period delay on the input. For example. the transfer function of the delayed integrator y[ k + 1 ] = y[ k] + u[k – 2] is z H ( z ) = ----------z–1 You can specify this model either as the first-order transfer function 1 ⁄ ( z – 1 ) with a delay of two sampling periods on the input Ts = 1. you can map all discrete-time delays to poles at the origin using the command delay2z.

Retrieving Information About Delays There are several ways to retrieve time delay information from a given LTI model sys: • Use property display commands to inspect the values of the ioDelayMatrix.'inputdelay') • Use the helper function hasdelay to determine if sys has any delay at all. Conversion of Models with Delays to State Space When you use ss to convert TF or ZPK models to state-space form. Type help totaldelay or see the Reference pages for details. and 0 (false) otherwise • Use the function totaldelay to determine the total delay between each input and each output (cumulative contribution of the ioDelayMatrix. input channel delays. For example. and output 2-54 .inputdelay now returns 0 (zero).iodelay get(sys. sys. the delays in the resulting state-space model are redistributed when it is possible to reduce the overall number of I/O delays. The syntax is hasdelay(sys) which returns 1 (true) if sys has any delay. InputDelay. and OutputDelay properties.2 LTI Models absorbs the input delay in H1 into the transfer function denominator to produce the third-order transfer function Transfer function: 1 --------z^3 – z^2 Sampling time: 1 Note that H2. and OutputDelay properties). InputDelay.

but is delay free. output. The resulting LTI model sysx is of the same type as sys. so as to minimize the overall number of input and output channel delays.9e 12.no. and the integer n specifies the Padé approximation order. and I/O delays.0s + 1 – 19. When this minimization takes place: • All or part of the I/O delay matrix is absorbed into the input and output delay vectors.nio) where the vectors ni and no.n) where sys is a continuous-time model with delays. you can use the syntax sysx = pade(sys.4e 6. output. For models with multiple delays or a mix of input. The resulting model has a minimum number of delays.------------------------16. and the matrix nio specify independent approximation orders for each input. two-output transfer function in this example is – 18.Time Delays channel delays.6e ----------------------. This minimizes the total number of I/O delays. Padé Approximation of Time Delays The function pade computes rational approximations of time delays in continuous-time LTI models.------------------------10.7e + 1 21. • The input delays are transferred to output delays (or vice-versa). consider the “Distillation Column Example” on page 2-47.4s + 1 – 7s – 1s – 3s H(s) = – 3s To compute a Padé approximation of H(s) using: • A first-order approximation for the 1 second and 3 second delays • A second-order approximation for the 7 second delay. For example.ni. 2-55 .8e ----------------------. respectively. The syntax is sysx = pade(sys. and similarly for no and nio. Set ni=[] if there are no input delays. and I/O delay. The two-input.9s + 1 14.

9 s^3 + 10.9 s – 12.[1 1.6 Xd: --------------------16.6 s + 0..2 LTI Models type pade(H..7 s^2 + 34.8 s + 25.6667 19. This command produces a rational transfer function.4 s – 12.4 s + 2 6.2 1]) where H is the TF representation of H ( s ) defined in the “Distillation Column Example” on page 2-47. –12.93 -------------------------14.6667 Xb: 2-56 .657 s + 1.[]. Transfer function from input "R" to output.616 --------------------------------------10.527 s + 0.[].6 s^2 – 5.6 Xd: ---------------------21 s^2 + 15 s + 0.4 s^2 + 10..2449 Xb: Transfer function from input "S" to output. 18..34 s^2 + 3.

Double-click on the block in your Simulink diagram to display or modify model information. The LTI System block can be accessed either by typing ltiblock at the MATLAB prompt or by selecting Control System Toolbox from the Blocksets and Toolboxes section of the main Simulink library. The LTI System block accepts both continuous and discrete LTI objects in either transfer function. enter either the variable name of an LTI object located in the MATLAB workspace (for example. The concept of “initial state” is not well-defined for 2-57 . This mask is linked to an LTI block in a Simulink diagram. In the editable text box labeled LTI system variable. Simulink converts the model to its state-space equivalent prior to initializing the simulation. Use the editable text box labeled Initial states to enter an initial state vector for state-space models. or state-space form. The LTI System block consists of the dialog box shown on the right in the figure above. tf(1. zero-pole-gain.Simulink Block for LTI Systems Simulink Block for LTI Systems You can incorporate LTI objects into Simulink diagrams using the LTI System block shown below. sys) or a MATLAB expression that evaluates to an LTI object (for example.[1 1])).

2-58 . As a result. you cannot enter nonzero initial states when you supply TF or ZPK models to LTI blocks in a Simulink diagram. Note: • For MIMO systems. • LTI blocks in a Simulink diagram cannot be used for FRD models or LTI arrays. as it depends on the choice of state coordinates used by the realization algorithm.2 LTI Models transfer functions or zero-pole-gain models. the input delays stored in the LTI object must be either all positive or all zero.

[2] Wood. 2-59 . 1707-1717.” Chemical Engineering Science. and R. 28 (1973). Addison-Wesley. “Terminal Composition Control of a Binary Distillation Column. pp.H. Bishop. Berry.References References [1] Dorf. 1998. R. Modern Control Systems. CA. and M.C. Menlo Park.W.K. R.

2 LTI Models 2-60 .

. . . . 3-28 . . . . . . . . . . . . 3-23 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Tustin Approximation . . . . . . . . . . . Inversion and Related Operations Transposition . . . . . . . 3-17 Feedback and Other Interconnection Functions . . . . . Pertransposition . . . . . . 3-20 . . . . Matched Poles and Zeros . . . . . . . . . . . . . . . . . . . . . 3-5 3-7 3-8 3-9 3-11 3-11 3-13 3-13 3-14 3-14 3-15 Model Interconnection Functions . . . . . . . . . . . . . . . . . . Referencing FRD Models Through Frequencies Referencing Channels by Name . . . . . . . . . . . . . 3-22 . . Discretization of Systems with Delays . . 3-27 References . . . . First-Order Hold . . . . . 3-22 . . Arithmetic Operations . Delays and Model Operations . . . . . . . . Delays and Continuous/Discrete Model Conversions . . . 3-24 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3 Operations on LTI Models Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-16 Concatenation of LTI Models . . . . . . . . . . . . . . . . . . Tustin with Frequency Prewarping . . . . . . . . . 3-23 . . . Resizing LTI Systems . . . . . . . . . . . . . . . . . . . . 3-3 Extracting and Modifying Subsystems . . . . . . 3-18 Continuous/Discrete Conversions of LTI Models Zero-Order Hold . . . . . . Addition and Subtraction . . . . 3-2 Precedence and Property Inheritance . . 3-25 Resampling of Discrete-Time Models . . Multiplication . . . 3-20 .

multiplication. To read about how you can apply these operations to arrays of LTI models. Such operations are “overloaded. or concatenation on LTI models. we discuss model type precedence and how LTI model properties are inherited when models are combined using these operations. You can read about discretization methods in this chapter as well.3 Operations on LTI Models Introduction You can perform basic matrix operations such as addition. before discussing operations on LTI models. The following topics and operations on LTI models are covered in this chapter: • Precedence and Property Inheritance • Extracting and Modifying Subsystems • Arithmetic Operations • Model Interconnection Functions • Continuous/Discrete-Time Conversions of LTI Models • Resampling of Discrete-Time Models These operations can be applied to LTI models of different types. To read about the available functions with which you can analyze LTI models. but are adapted so as to apply to the LTI model context. see Chapter 5. As a result. see “Operations on LTI Arrays” on page 4-25.” 3-2 .” which means that they use the same syntax as they do for matrices. These overloaded operations and their interpretation in this context are discussed in this chapter. “Model Analysis Tools.

For example. if sys1 is a transfer function and sys2 is a state-space model. some general rules are summarized below: • In operations combining discrete-time LTI models. and on state-space models in the second case. or a posteriori conversion of the result sys = tf(sys1 + sys2) Note: These alternatives are not equivalent numerically.Precedence and Property Inheritance Precedence and Property Inheritance You can apply operations to LTI models of different types. then the result of their addition sys = sys1 + sys2 is a state-space model. for example.Ts = –1) sample times. Another issue is property inheritance. computations are carried out on transfer functions in the first case. You can either use a priori conversion of the second operand sys = sys1 + tf(sys2). if there is one. all models must have identical or unspecified (sys. you can either: • Convert all operands to TF before performing the operation • Convert the result to TF after performing the operation Suppose. a transfer function (TF). how the operand property values are passed on to the result of the operation. you want to compute the transfer function of sys. The resulting type is then determined by the rules discussed in “Precedence Rules” on page 2-5. To supersede the precedence rules and force the result of an operation to be a given type. since state-space models have precedence over transfer function models. While inheritance is partly operation-dependent. in the above example. 3-3 . that is. Models resulting from such operations inherit the specified sample time. • Most operations ignore the Notes and Userdata properties.

when two LTI models sys1 and sys2 are combined using operations such as +. 'z^–1' has precedence over 'q' and 'z'. and feedback.].For discrete-time models. while 'q' has precedence over 'z'.].For continuous-time models. the resulting model inherits its I/O names and I/O groups from sys1 and sys2. For example. *. . append. 3-4 . the InputName property for sys1 + sys2 is left unspecified if sys1 and sys2 have different InputName property values. However. 'p' has precedence over 's'.3 Operations on LTI Models • In general. conflicting I/O names or I/O groups are not inherited. [. Conflicts are resolved according the following rules: . • A model resulting from operations on TF or ZPK models inherits its Variable property value from the operands. [.

and I/O relation y = Hu then H ( 3.1) is a state-space model with data a. time delay.Extracting and Modifying Subsystems Extracting and Modifying Subsystems Subsystems relate subsets of the inputs and outputs of a system. SubSys = sys(3. • When extracting a subsystem from a given state-space model.1). the subsystem sys(3. Use the command sminreal to eliminate unnecessary states in the subsystem. If sys is a state-space model with matrices a. b. sys(3. The transfer matrix of a subsystem is a submatrix of the system transfer matrix. and three.1). three outputs. For example.1 ) u 1 Accordingly.1) = NewSubSys redefines the I/O relation between the first input and third output. For example. if sys is a system with two inputs. if sys has an input group named controls consisting of channels one. For example.1). two.:). 3-5 . d. d(3. we use matrix-like subindexing to extract this subsystem. the resulting state-space model may not be minimal. then SubSys also has an input group named controls with the first channel of SubSys assigned to it. 1 ) gives the relation between the first input and third output. b(:. provided NewSubSys is a SISO LTI model. c(3. Note: • In the expression sys(3. the first index selects the output channel while the second index selects the input channel. You can use similar syntax to modify the LTI model sys. c. I/O name. y 3 = H ( 3.1) The resulting subsystem SubSys is an LTI model of the same type as sys. with its sample time. and I/O group property values inherited from sys.

retains its original model type (TF.1) selects the first input and all outputs.T ( s ) = s–1 --------------------------2 + 2s + 2 s 0 1 -s 3-6 . their frequencies must match. • If NewSubSys is an FRD model. SS.1:2) extracts the subsystem mapping the first two inputs to the third output. ZPK. the LTI model that has had a portion reassigned. consider the two-input/two-output transfer function 1 ---------------s + 0. • Reassigning parts of a MIMO state-space model generally increases its order. Furthermore. or FRD) regardless of the model type of NewSubSys. • Subsystem assignment does not reassign any I/O names or I/O group names of NewSubSys that are already assigned to NewSubSys. Other standard matrix subindexing extends to LTI objects as well. For example. and sys([1 3]. sys(:. sys(3.1 . then sys must also be an FRD model.:) extracts a subsystem with the same inputs.3 Operations on LTI Models Note: • sys. but only the first and third outputs. For example.

tf(0.4 --s #2: Referencing FRD Models Through Frequencies You can extract subsystems from FRD models.5 s – 1 ------------s^2 + 2 s + 2 #2: Transfer function from input 2 to output. type T(1. use the string 'Frequency' (or any abbreviation.1) Transfer function: 1 ------s + 0. You can also extract subsystems by indexing into the frequencies of an FRD model..1) = tf(1... such as.1 Next reassign T 11 ( s ) to 1 ⁄ ( s + 0..[1 0]) ] Transfer function from input 1 to output. To index into the frequencies of an FRD model. #1: 1 0. as long as it does not conflict with existing 3-7 . 'freq'.5 ) and modify the second input channel of T by typing T(1.Extracting and Modifying Subsystems To extract the transfer function T 11 ( s ) from the first input to the first output. T(:. as you do with other LTI model types.5]). by indexing into input and output (I/O) dimensions.4.[1 0. 1 #1: ------s + 0.2) = [ 1 .

2.2 5. then sys2 = sys(1. with one frequency data point.4]). with sys. For example.1000 You can also combine model extraction through frequencies with indexing into the I/O dimensions.'noise') 3-8 . sys2. two outputs.g. sys2 = sys('frequency'.Units specified in rad/s. For example.0 & sys.Frequency >1. and five. Similarly.freq ans = 1. and frequency vector [2.1 4.Frequency <1.2000 displays the second and third entries in the frequency vector. Referencing Channels by Name You can also extract subsystems using I/O group or channel names.1 rad/s. if sys has an input group named noise. four.1000 1. 2. 2:3).3 1.Frequency=[1 1. if sys is an FRD model with five frequencies. consisting of channels two.15). sys. you can use logical indexing into the frequencies. There are two ways you can specify FRD models using frequencies: • Using integers to index into the frequency vector of the FRD model • Using a Boolean (logical) expression to specify desired frequency points in an FRD model For example.Frequency ans = 1.1 1. then sys(1.'freq'.3 Operations on LTI Models I/O channel or group names) as a keyword.1) specifies sys2 as a SISO FRD model.2 1. sys2 = sys('frequency'.sys. sys2.. then you can create a new FRD model sys2 by indexing into the frequencies of sys as follows.3]. (e. if sys is an FRD model with two inputs.

[2 4 5] Similarly.1) = tf(1. [1 1]) reassigns the subsystem from the first input of sys to the output labeled pressure. respectively. There is an important difference between these two options: while concatenation obeys the precedence rules (see page 2-5). 3-9 .Extracting and Modifying Subsystems is equivalent to sys(1. You can reference a set of channels by input or output name by using a cell array of strings for the names.1:2) = [] In deletions. then sys('pressure'. To perform input/output augmentation. For example. Given a system sys with a single input. equivalently. if pressure is the name assigned to an output channel of the LTI model sys. or. and the same number of outputs as sys.'temperature'}) Resizing LTI Systems Resizing a system consists of adding or deleting inputs and/or outputs. subsystem assignment does not alter the model type. using sys(:. you can proceed by concatenation or subassignment. simply type sys(:. you can add a second input using sys = [sys. at least one of the row/column indexes should be the colon (:) selector. So. then these two output channels can be referenced using sys({'pressure'.2) = h. To delete the first two inputs. where h is any LTI model with one input. if sys has one output channel named pressure and one named temperature.h]. if sys and h are TF and SS objects. and the second statement produces a transfer function. the first statement produces a state-space model.

both concatenation and subsystem assignment increase the model order because they assume that sys and h have independent states.'d'. the statements sys.'b'. use set instead and modify the corresponding state-space data directly.[b1 b2]) cause an error because they create invalid intermediate models in which the B and D matrices have inconsistent column dimensions. Indeed.[d1 d2]) adds a second input to the state-space model sys by appending the B and D matrices. You should simultaneously modify both matrices with a single set command.[b1 b2].d1) set(sys.c. 3-10 .'b'. sys = ss(a.b1. For example. If you intend to keep the same state matrix and merely update the input-to-state or state-to-output relations.3 Operations on LTI Models For state-space models.b = [b1 b2] and set(sys.

it’s useful to keep in mind the matrix analogy for systems discussed in “Viewing LTI Systems As Matrices” on page 2-5.Arithmetic Operations Arithmetic Operations You can apply almost all arithmetic operations to LTI models.' ^ To understand how these operations work on LTI models. Specifically. Operation + Description Addition Subtraction Multiplication Right matrix divide Left matrix divide Matrix inversion Pertransposition Transposition Powers of an LTI model (as in s^2) – * / \ inv ' . including those shown below. adding LTI models is equivalent to connecting them in parallel. the LTI model sys = sys1 + sys2 3-11 . Addition and Subtraction As mentioned in “Viewing LTI Systems As Matrices” on page 2-5.

y1 + – sys2 sys1 u y y2 sys 3-12 . sys1 + sys2 produces a system with the same dimensions as sys1 whose ijth entry is sys1(i. the subtraction of two LTI models sys = sys1 – sys2 is depicted by the following block diagram. the state-space data associated with sys1 + sys2 is A1 0 0 A2 . B1 B2 . D1 + D2 Scalar addition is also supported and behaves as follows: if sys1 is MIMO and sys2 is SISO. B 1. B 2. Similarly. D 1 and A 2. y1 + + sys2 sys1 u y y2 sys If sys1 and sys2 are two state-space models with data A 1. C 1.3 Operations on LTI Models represents the parallel interconnection shown below. D 2 . C1 C 2 . C 2.j) + sys2.

C1 D1 C2 . B1 D2 B2 . sys = sys1 * sys2 returns an LTI model sys for the series interconnection shown below. Specifically. D 1 and A 2. the state-space data associated with sys1*sys2 is A1 B1 C2 0 A2 . B 1. B 2. C 2. C 1. then sys1*sys2 or sys2*sys1 is interpreted as an entry-by-entry scalar multiplication and produces a system with the same dimensions as sys1. y = H u → u = H y –1 This operation is defined only for square systems (that is. whose ijth entry is sys1(i. systems with as many inputs as outputs) and is performed using inv(sys) 3-13 . D1 D2 Finally. if sys1 is MIMO and sys2 is SISO. D 2 . v u sys2 sys1 y Notice the reverse orders of sys1 and sys2 in the multiplication and block diagram.j)*sys2.Arithmetic Operations Multiplication Multiplication of two LTI models connects them in series. Inversion and Related Operations Inversion of LTI models amounts to inverting the following input/output relationship. This is consistent with the way transfer matrices are combined in a series connection: if sys1 and sys2 have transfer matrices H 1 and H 2 . then y = H 1 v = H 1 ( H2 u ) = ( H1 × H2 ) u For state-space models sys1 and sys2 with data A 1.

the matrix of frequency response data at each frequency is transposed. CT. • For ZPK models (with input arguments. the pertransposed system has the transfer function G ( s ) = [ H ( –s ) ]T The discrete-time counterpart is G(z ) = [H(z )] –1 T Pertransposition of an LTI model sys is performed using sys' 3-14 .3 Operations on LTI Models The resulting inverse model is of the same type as sys. –D C . C. B. Related operations include: • Left division sys1\sys2. transposition produces the state-space model AT. DT. –1 BD –1 .' This is a literal operation with the following effect: • For TF models (with input arguments. which is equivalent to inv(sys1)*sys2 • Right division sys1/sys2. the cell arrays. num and den). which is equivalent to sys1*inv(sys2) For a state-space model sys with data A. in which case its state-space data is A – BD C . D . B. p. • For SS models (with model data A. C. inv(sys) is defined only when D is a square invertible matrix. z. and k). BT. • For FRD models (with complex frequency response matrix Response). and the matrix k are transposed. the cell arrays num and den are transposed. –1 D –1 Transposition You can transpose an LTI model sys using sys. Pertransposition For a continuous-time system with transfer function H ( s ) . z and p. D ).

to state-space models. The frequency response of the pertranspose of H ( s ). is the Hermitian transpose of the frequency response of H ( s ): G ( jw ) = H ( jw ) H .Arithmetic Operations You can use pertransposition to obtain the Hermitian (conjugate) transpose of the frequency response of a given system. 3-15 .\. w). Operations on State-Space Models with Delays When you apply operations such as +.[]. all or part of the I/O delay matrix of the resulting model is absorbed into the input and output delay vectors when it is possible to reduce the total number of I/O delays.*. G ( s ) = [ H ( – s ) ] T ./. type freqresp(sys'. To obtain the Hermitian transpose of the frequency response of a system sys over a frequency range specified by the vector w. The resulting model has a minimum number of such delays.

These functions are useful to model open.] [. general parallel and series connections (parallel and series). Interconnection Operator [. These include model interconnection functions to perform I/O concatenation ([. [. and feedback connections (feedback and lft).3 Operations on LTI Models Model Interconnection Functions The Control System Toolbox provides a number of functions to help with the model building process.].].and closed-loop systems. and append).] append Description Concatenates horizontally Concatenates vertically Appends models in a block diagonal configuration Augments the output by appending states Forms an SS model from a block diagonal LTI object for an arbitrary interconnection matrix Forms the feedback interconnection of two models Produces the LFT interconnection (Redheffer Star product) of two models Forms the generalized parallel connection of two models Forms the generalized series connection of two models augstate connect feedback lft parallel series 3-16 .

Model Interconnection Functions Concatenation of LTI Models LTI model concatenation is done in a manner similar to the way you concatenate matrices in MATLAB. H 2 u1 u2 y1 y2 = H1 H2 u Horizontal Concatenation Vertical Concatenation You can use concatenation as an easy way to create MIMO transfer functions or zero-pole-gain models.sys2)% block diagonal appending In I/O terms.[1 0]) 1 . u1 H1 + + y u H1 y1 u2 H2 H2 y2 y = H1 . using sys = [sys1 . 0 tf([1 –1]. sys2] % horizontal concatenation sys = [sys1 . horizontal and vertical concatenation have the following block-diagram interpretations (with H 1 and H 2 denoting the transfer matrices of sys1 and sys2). sys2] % vertical concatenation sys = append(sys1. H = [ tf(1. For example.[1 1]) ] specifies 1 -s 0 1 s–1 ----------s+1 H(s) = 3-17 .

Feedback and Other Interconnection Functions The following LTI model interconnection functions are useful for specifying closed. • lft performs the Redheffer star product on two LTI models. 3-18 .sys2) to specify the block-decoupled LTI model interconnection.and open-loop model configurations: • feedback puts two LTI models with compatible dimensions in a feedback configuration. • parallel connects two LTI models in parallel. • series connects two LTI models in series. u1 sys1 y1 sys1 0 0 sys2 u2 sys2 y2 Appended Models Transfer Function See append on page 11-12 for more information on this command.3 Operations on LTI Models Use append(sys1. • connect works with append to apply an arbitrary interconnection scheme to a set of LTI models.

3-19 . lft.Model Interconnection Functions For example. and connect. series. then the negative feedback configuration of these two LTI models + u – sys1 y sys2 is realized with feedback(sys1. “Reference. while sys2 has p inputs and m outputs.sys2) This specifies the LTI model with m inputs and p outputs whose I/O map is ( I + sys1 ⋅ sys2 ) – 1 sys1 See Chapter 11. if sys1 has m inputs and p outputs.” for more information on feedback. parallel.

specify the desired method as an extra string input: sysd = c2d(sysc.'foh'). u(t) u[ k ] ZOH H(s) y(t) y[k] Ts Hd ( z ) The ZOH device generates a continuous input signal u(t) by holding each sample value u[k] constant over one sample period. The zero-order-hold discretization H d ( z ) of a continuous-time LTI model H ( s ) is depicted in the following block diagram. Several discretization/interpolation methods are supported. including zero-order hold (ZOH). % use first-order hold sysc = d2c(sysd. To use alternative conversion schemes.3 Operations on LTI Models Continuous/Discrete Conversions of LTI Models The function c2d discretizes continuous-time TF. Zero-Order Hold Zero-order hold (ZOH) devices convert sampled signals to continuous-time signals for analyzing sampled continuous-time systems.Ts). Tustin approximation with or without frequency prewarping. Conversely. d2c converts discrete-time TF. and matched poles and zeros.'tustin'). or ZPK models to continuous time. The syntax sysd = c2d(sysc. SS. or ZPK models. % use Tustin approximation The conversion methods and their limitations are discussed next. first-order hold (FOH). sysc = d2c(sysd).Ts. 3-20 . SS. % Ts = sampling period in seconds performs ZOH conversions by default.

This inverse operation has the following limitations: • d2c cannot operate on LTI models with poles at z = 0 when the ZOH is used.5. given a discrete system H d ( z ) .Continuous/Discrete Conversions of LTI Models u( t ) = u[ k ] . kT s ≤ t ≤ ( k + 1 )T s The signal u ( t ) is then fed to the continuous system H ( s ) . Conversely. • Negative real poles in the z domain are mapped to pairs of complex poles in the s domain.1 Use d2c to convert this model to continuous-time hc = d2c(hd) and you get a second-order model.0. Consider the following discrete-time ZPK model.5) Sampling time: 0.86s + 1035) Discretize the model again c2d(hc. Zero/pole/gain: 4. and the resulting output y ( t ) is sampled every T s seconds to produce y [ k ] .1) 3-21 .1. hd = zpk([]. The next example illustrates the behavior of d2c with real negative poles. the d2c conversion of a discrete system with negative real poles produces a continuous system with higher order.621 (s+149.1) Zero/pole/gain: 1 ------(z+0.0. As a result.–0. the d2c conversion produces a continuous system H ( s ) whose ZOH discretization coincides with H d ( z ) .3) --------------------(s^2 + 13.

FOH uses linear interpolation between samples. Tustin Approximation The Tustin or bilinear approximation uses the approximation z = e sT s 1 + sT s ⁄ 2 ≈ ------------------------1 – sT s ⁄ 2 to relate s-domain and z-domain transfer functions.5): Zero/pole/gain: (z+0. It is also known as ramp-invariant approximation because it is distortion-free for ramp inputs. and not d2c conversions. 151).5)^2 Sampling time: 0.1 First-Order Hold First-order hold (FOH) differs from ZOH by the underlying hold mechanism. p.5) --------(z+0. the discretization H d ( z ) of a continuous transfer function H ( s ) is derived by 3-22 . To turn the input samples u [ k ] into a continuous input u ( t ) .3 Operations on LTI Models and you get back the original discrete-time system (up to canceling the pole/zero pair at z=–0. t – kT s u ( t ) = u [ k ] + ----------------. Ts kT s ≤ t ≤ ( k + 1 )T s This method is generally more accurate than ZOH for systems driven by smooth inputs. In c2d conversions.( u [ k + 1 ] – u [ k ] ) . Note: This FOH method differs from standard causal FOH and is more appropriately called triangle approximation (see [2]. this option is only available for c2d conversions. Due to causality constraints.

----------Ts z + 1 Similarly. where 1 + sT s ⁄ 2 z' = ------------------------1 – sT s ⁄ 2 Tustin with Frequency Prewarping This variation of the Tustin approximation uses the correspondence H d ( z ) = H ( s' ) . 3-23 . the d2c conversion relies on the inverse correspondence H ( s ) = H d ( z' ).Continuous/Discrete Conversions of LTI Models H d ( z ) = H ( s' ) . The continuous and discretized systems have matching DC gains and their poles and zeros correspond in the transformation z = e sT s See [2]. p. where 2 z–1 s' = ----.----------tan ( ωT s ⁄ 2 ) z + 1 This change of variable ensures the matching of the continuous.and discrete-time frequency responses at the frequency ω . ω z–1 s' = -------------------------------. H ( jω ) = H d ( e jωT s ) Matched Poles and Zeros The matched pole-zero method applies only to SISO systems. 147 for more details.

type h = tf(10.5 times the sampling period of 0. • The residual fractional delay tau – k*Ts is absorbed into the coefficients of the discretized model (for the zero-order-hold and first-order-hold methods only).0.25).1) This produces the discrete-time transfer function Transfer function: 0.009721 z^(–2) * ---------------------------------z^3 – 1. and a 10 Hz sampling rate. to discretize the transfer function H(s) = e – 0.1 seconds. 3-24 .inputdelay.01187 z^2 + 0. as confirmed by the value of hd.'inputdelay'.7408 z Sampling time: 0. For example.3 Operations on LTI Models Discretization of Systems with Delays You can also use c2d to discretize SISO or MIMO continuous-time models with time delays.655 z^2 + 0. The residual half-period delay is factored into the coefficients of hd by the discretization algorithm. hd = c2d(h.1 Here the input delay in H ( s ) amounts to 2. Accordingly.0.25s 10 -----------------------------2 s + 3s + 10 using zero-order hold on the input.06408 z + 0. where k = fix(tau/Ts).[1 3 10]. If Ts is the sampling period used for discretization: • A delay of tau seconds in the continuous-time model is mapped to a delay of k sampling periods in the discretized model. the discretized model hd inherits an input delay of two sampling periods.

all or part of the I/O delay matrix of the resulting model is absorbed into the input and output delay 3-25 .'--'.Continuous/Discrete Conversions of LTI Models The step responses of the continuous and discretized models are compared in the figure below. Delays and Continuous/Discrete Model Conversions When you apply c2d and d2c to state-space models.'-') Note: The Tustin and matched pole/zero methods are accurate only for delays that are integer multiples of the sampling period. It is therefore preferable to use the zoh and foh discretization methods for models with delays. This plot was produced by the command step(h.hd.

3-26 .3 Operations on LTI Models vectors when it is possible to reduce the total number of I/O delays. The resulting model has a minimum number of such delays.

4].1).Ts) The new sampling period Ts does not have to be an integer multiple of the original sampling period. For example. 3-27 . SS.'--'. typing h1 = tf([1 0. h2 = d2d(h1.1 seconds.[1 –0.0.0. resamples h1 at the sampling period of 0. rather than 0.25).Resampling of Discrete-Time Models Resampling of Discrete-Time Models You can resample a discrete-time TF.25 seconds.h2.7]. or ZPK model sys1 by typing sys2 = d2d(sys1.'-') The resulting plot is shown on the figure below (h1 is the dashed line). You can compare the step responses of h1 and h2 by typing step(h1.

K. Addison-Wesley.D.3 Operations on LTI Models References [1] Åström. 1990.J. and M. pp. Powell. Prentice-Hall. Computer-Controlled Systems: Theory and Design. G.L. 48–52. 3-28 . 1990. and B. Digital Control of Dynamic Systems. [2] Franklin. Wittenmark.. Second Edition.F. Workman. J.

. . . . . . . . . . . . . . . . . . . . . . . . . . .4 Arrays of LTI Models Introduction . . . . . . . Accessing Particular Models in an LTI Array Extracting LTI Arrays of Subsystems . . . . Building LTI Arrays Using the stack Function Building LTI Arrays Using tf. . . . . . . . . . . . Example: Addition of Two LTI Arrays . . . . . . . . Special Cases for Operations on LTI Arrays Other Operations on LTI Arrays . . . . . . . . . . . . . . . . . . . . Reassigning Parts of an LTI Array . . . . . . . 4-12 4-12 4-12 4-15 4-17 4-20 4-20 4-21 4-22 4-23 4-25 4-26 4-27 4-27 4-30 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . When to Collect a Set of Models in an LTI Array . . . zpk. . . . . . . . . . . . . Deleting Parts of an LTI Array . . . . . . . . . . . . . Operations on LTI Arrays . . . . . . . . . . . . . . . . . . . . . . and Shape of an LTI Array . Generating LTI Arrays Using rss . . . . . . . ss. . . . 4-9 reshape . . . . . . 4-11 Building LTI Arrays . . . . . . . . . . . . . . . . . . Restrictions for LTI Models Collected in an Array Where to Find Information on LTI Arrays . . . . and frd Indexing Into LTI Arrays . . 4-7 size and ndims . . 4-2 4-2 4-2 4-3 The Concept of an LTI Array . . . . Building LTI Arrays Using for Loops . . . . . . . . . Size. . . . . . . . . . . . . . . . . . . . 4-6 Dimensions. . . . . Dimension Requirements . . . . . . . . . . . . . . . . . 4-4 Higher Dimensional Arrays of LTI Models . . . . . . .

for discrete-time models • The I/O names and I/O groups Note: You cannot specify Simulink LTI blocks with LTI arrays. it is useful to keep in mind the matrix interpretation of LTI models developed in “Viewing LTI Systems As Matrices” on page 2-5. when you think about LTI arrays. When to Collect a Set of Models in an LTI Array You can use LTI arrays to represent: • A set of LTI models arising from the linearization of a nonlinear system at several operating points • A collection of transfer functions that depend on one or more parameters • A set of LTI models arising from several system identification experiments applied to one plant • A set of gain-scheduled LTI controllers • A list of LTI models you want to collect together under the same name Restrictions for LTI Models Collected in an Array For each model in an LTI array. You then use this variable to manipulate or analyze the entire collection of models in a vectorized fashion. “Multidimensional Arrays” in Using MATLAB). 4-2 . Additionally. LTI arrays extend the concept of single LTI models in a similar way to how multidimensional arrays extend two-dimensional matrices in MATLAB (see Chapter 12. the following properties must be the same: • The number of inputs and outputs • The sample time.4 Arrays of LTI Models Introduction You can use LTI arrays to collect a set of LTI models into a single MATLAB variable. You access the individual models in the collection through indexing rather than by individual model names.

see Chapter 6. You can also apply the analysis functions in the Control System Toolbox to LTI arrays. For information. “The LTI Viewer. To read about how to build an LTI array. “Model Analysis Tools. its dimensions.” 4-3 . and size. The remainder of the chapter is devoted to indexing and operations on LTI Arrays. go to “Building LTI Arrays” on page 4-12. See Chapter 5.Introduction Where to Find Information on LTI Arrays The next two sections give examples that illustrate the concept of an LTI array. You can also view response plots of LTI arrays with the LTI Viewer.” for more information on these functions.

consider the set of five transfer function models shown below. each model has two inputs and two outputs.6 1.2 0 0 1 ---------------s + 5.4 1.2 1.8 1.00 ---------------s + 1.4 Arrays of LTI Models The Concept of an LTI Array To visualize the concept of an LTI array.3 ---------------s + 1. In this example.1s + 1. Figure 4-2: An LTI Array Containing These Five Models 4-4 . They differ by parameter variations in the individual model components.15 ---------------s + 1.3 0 ---------------s + 5.4 0 0 1 ---------------s + 5.1 ----------s+1 0 0 1 ----------s+5 1.09 ---------------s + 1.4 ----------.4 1. 1.2 s + 5.15 ---------------0 1 s + 1.6 1.3 1 ---------------00 ---------------1.11 1 ---------------.0 1 s+1 0 ---------------s + 5.3 0 0 1 ---------------s + 5.8 Figure 4-1: Five LTI Models to be Collected in an LTI Array This LTI array embodies a 1.11 ---------------s + 1.2 1 Each element of the 0 ----------s+5 LTI array is a model.1 s + 5. s + 1.09 ---------------0 1-by-5 list of models.1 0 0 1 ---------------s + 5.

Figure 4-3: Using Indices to Select Models and Their Components See “Indexing Into LTI Arrays” on page 4-20 for more information on indexing.15 1. For example.Inputs. sys.3).11 ---------------s + 1.4 s+ ---------------0 s 1. say.Models) The first index selects the output channels. 1.00 ---------------s + 1.2 0 0 1 ---------------s + 5.09 ---------------0 1. The general form for the syntax you use to access data in an LTI array is sys(Outputs.2 1 + 5.1 + 1.1 -------------------------. The remaining indices select particular models in the LTI array by their array coordinates. sys(2.2. Individual models in the LTI array sys are accessed via indexing.3) selects the third model in the array.2) entry of the third model in the array.3 ---------------0 ---------------0 1s + 5.2 0 ----------s+5 1.3) selects the (2. The second index selects the input channels. Each element of the LTI array is an LTI model. The following illustrates how you can use indexing to select models or their components from sys. you can access the third model in sys with sys(:.4 sys(:. 4-5 .0 0 s + 5.8 s 1. you can collect this set of five transfer function models as a list in an LTI array under one variable name.3 1 ---------------.11+ 1.6 s 1.:.The Concept of an LTI Array Just as you might collect a set of two-by-two matrices in a multidimensional array.:.4 s+1 1 ---------------0 1 s + 5.

84 7. two-output.1) m2d(:.32 Figure 4-4: m2d: A 2-by-3 Array of Two-Output.86 7.4 Arrays of LTI Models Higher Dimensional Arrays of LTI Models You can also collect a set of models in a two-dimensional array. you can organize models into a 3-D or higher-dimensional array.2.:.:.3) position of the array.:.36 ---------------s + 2.3) m2d(:.2) m2d(:.1) m2d(:. “Multidimensional Arrays” in Using MATLAB). One-Input Models More generally.:. m2d(:.45 ------------------s + 2.9 7.:.27 3.:. Each entry in this 2-by-3 array of models is a two-output.3) extracts the model in the (1. in much the same way you arrange numerical data into multidimensional arrays (see Chapter 12. 3.23 3.2.:.42 ------------------s + 2.:. The following diagram illustrates a 2-by-3 array of six.81 7.29 m2d(:.2.2 ) m2d(:.1. 4-6 .1.1. one-input models called m2d.3) m2d(:.1.3) 3.1.4 ------------------s + 2. one-input transfer function.

and shape. and Shape of an LTI Array Dimensions.Dimensions. An array of LTI models has additional quantities that determine its dimensions. Size. and Shape of an LTI Array The dimensions and size of a single LTI model are determined by the output and input channels. There are two sets of dimensions associated with LTI arrays: • The I/O dimensions—the output dimension and input dimension common to all models in the LTI array • The array dimensions—the dimensions of the array of models itself The size of the LTI array is determined by: • The lengths of the I/O dimensions—the number of outputs (or inputs) common to all models in the LTI array • The length of each array dimension—the number of models along that array dimension 4-7 . size. Size.

32 m2d(:.86 7.81 7.36 ---------------s + 2. 4-8 . According to the matrix analogy in “Viewing LTI Systems As Matrices” on page 2-5.3) 3.2. . t ar r ay di m ens m2d(:.:.:.1) ion is 2 m2d(:.2) m2d(:.81 7.:. an LTI Array You can load this sample LTI array into your workspace by typing load LTIexamples size(m2d) 2x3 array of continuous-time transfer functions Each transfer function has 2 outputs and 1 input.3) gt h of th e fi rs T he le n m2d(:.2 ) m2d(:.3) Output dimension (length 2) 3. two-output transfer function models.4 ------------------s + 2.1) m2d(:.2.4 Arrays of LTI Models The next figure illustrates the concepts of dimension and size for the LTI array m2d.1.1.:.32 Input dimension (length 1) Figure 4-5: Dimensions and Size of m2d.23 3.2.45 ------------------s + 2. The length of the second array dimension is 3. The two I/O dimensions are both of length 1 for SISO models.:.:.1. a 2-by-3 array of one-input. For MIMO models the lengths of these dimensions are given by the number of outputs and inputs of the model.27 3.9 7.:.45 ------------------s + 2.2. the I/O dimensions correspond to the row and column dimensions of the transfer matrix.

: • The length of the output dimension. . is 2. the number of array dimensions • S 1 S 2 …S K. the number of array dimensions. the first I/O dimension. is 1. the list of lengths of the array dimensions . and Shape of an LTI Array Five related quantities are pertinent to understanding the array dimensions: • N. • K. since there are two output channels in each model... 4-9 .The configuration determines the shape of the array.Dimensions. • The length of the input dimension. the second I/O dimension. since there is only one input channel in each model. is 2. • S 1 – by – S 2 – by – … – by – S K . size and ndims You can access the dimensions and shape of an LTI array using: • size to determine the lengths of each of the dimensions associated with an LTI array • ndims to determine the total number of dimensions in an LTI array When applied to an LTI array.The product of these integers S 1 × S 2 × … × S K is N. Size. In the example model m2d. Sk are the lengths of the array dimensions of a k-dimensional array of models. • The array dimension lengths are [2 3]. • Nu is the number of inputs common to all models in the LTI array.. • The array configuration is 2-by-3.. the number of models in the LTI array • K. the number of models in the LTI array.S i is the number of models along the i th dimension. Sk] where • Ny is the number of outputs common to all models in the LTI array. • N. the configuration of the models in the array . size returns [Ny Nu S1 S2 . • S1 S2 . is 6. Si is the number of models along the ith array dimension.

where p (greater than 2) is the number of array dimensions Note that ndims (sys) = length(size(sys)) To see how these work on the sample 2-by-3 LTI array m2d of two-output. For single LTI models. size returns only the I/O dimensions [Ny Nu]. • You can use the syntax size(sys. size returns [Ny Nu 2 3] for a 2-by-3-by-1-by-1 LTI array of models with Ny outputs and Nu inputs.'order') to determine the number of states in an LTI array. size always returns at least two array dimensions. For example. one-input models. for LTI arrays. For example.4 Arrays of LTI Models Note: • By convention. The function ndims returns the total number of dimensions in an LTI array: • 2. type load LTIexamples s = size(m2d) s = 2 1 2 3 4-10 . • For LTI arrays. A multidimensional array is returned if sys is an SS model such that the numbers of states in each model in sys are not the same. sys. a single LTI model is treated as a 1-by-1 array of models. the size of a 2-by-1 LTI array in [Ny Nu 2 1] • size ignores trailing singleton dimensions beyond the second array dimension. for single LTI models • 2 + p.

For example.1). and Shape of an LTI Array Notice that size returns a vector whose entries correspond to the length of each of the four dimensions of m2d: two outputs and one input in a 2-by-3 array of models. Size. Type ndims(m2d) ans = 4 to see that there are indeed four dimensions attributed to this LTI array.6.. type load LTIexamples sys = reshape(m2d..w1.. the number of models in sys. to arrange the models in an LTI Array sys as a w 1 × … × w p array...Dimensions. s = size(sys) s = 2 1 6 1 4-11 . a 6-by-1.. or a 1-by-6 array using reshape. type reshape(sys. You can reshape the LTI array m2d into a 3-by-2.wp) where w1.. reshape Use reshape to reorganize the arrangement (array configuration) of the models of an existing LTI array. size(sys) 6x1 array of continuous-time transfer functions Each transfer function has 2 outputs and 1 inputs.wp are any set of integers whose product is N. For example..

zpk..4 Arrays of LTI Models Building LTI Arrays There are several ways to build LTI arrays: • Using a for loop to assign each model in the array • Using stack to concatenate LTI models into an LTI array • Using tf. to create a 4-by-2 array of random state-space models with three states. one output. The syntax is rss(N. or frd In addition. • sdim1.4. Building LTI Arrays Using for Loops Consider the following second-order SISO transfer function that depends on two parameters.sdim1. ζ and ω ω2 .sdimk are the lengths of the array dimensions.2). H ( s ) = -------------------------------------2 + 2ζωs + ω 2 s 4-12 . 1 input.. ss. you can use the command rss to generate LTI arrays of random state-space models. type sys = rss(3. • M is the number of inputs of each model in the LTI array.. • P is the number of outputs of each model in the LTI array.. size(sys) 4x2 array of continuous-time state-space models Each model has 2 outputs..M. For example.1.P.sdimk) where • N is the number of states of each model in the LTI array. and one input.... and 3 states.2. Generating LTI Arrays Using rss A convenient way to generate arrays of state-space models with the same number of states in each model is to use rss.

All of the possible combinations of the confidence limits for these model parameter values give rise to a set of four SISO models. ω and ζ.i. H(:.1. ω1 ζ1 ω2 Each entry of this 2-by-2 array is a SISO transfer function model.:.ω 2] .:. 4-13 .2.ζ 2] for each of the parameters.:.2. H(:.1. ω1 ω2 2 2 ω1 ω1 ζ 1 H 11 ( s ) = -------------------------------------------. for i. you estimate confidence intervals [ω 1. 2 } .Building LTI Arrays Suppose.:.1) H(:.1) H(:.j ∈ { 1.H ( s ) = -------------------------------------------12 2 2 s 2 + 2ζ 1 ω 1 s + ω 1 s 2 + 2ζ 2 ω 1 s + ω 1 2 2 ω2 ω2 ζ 2 H ( s ) = -------------------------------------------. based on measured input and output data.:.2) ζ2 H(:.2) Figure 4-7: The LTI Array H Here.j) represents the transfer function ω2 j -----------------------------------------------2 + 2ζ ω s + ω 2 s i j j corresponding to the parameter values ζ = ζ i and ω = ω j . and [ζ 1.H ( s ) = -------------------------------------------22 21 2 2 s 2 + 2ζ 2 ω 2 s + ω 2 s 2 + 2ζ 1 ω 2 s + ω 2 Figure 4-6: Four LTI Models Depending on Two Parameters You can arrange these four models in a 2-by-2 array of SISO transfer functions called H.

2) Transfer function: 2. Enter these at the command line. it’s convenient to use two nested for loops to construct the LTI array.0.2) position of the array.25 ------------------s^2 + 1. end end H now contains the four models in a 2-by-2 array. Since the four models have the same parametric structure.76] and [1. For example.5].1. for i = 1:2 for j = 1:2 H(:.2.:.98 s + 2.5].2. while the fourth index is for the second array dimension (ω).66. w = [1. zeta = [0.25 4-14 .0. respectively.66. The third index of H refers to the first array dimension ( ζ).j) = tf(w(j)^2.4 Arrays of LTI Models The first two colon indices ( : ) select all I/O channels from the I/O dimensions of H. to display the transfer function in the (1.:.i. Suppose the limits of the ranges of values for ζ and ω are [0.1.75]. type H(:.[1 2*zeta(i)*w(j) w(j)^2]).1.

SK)) The number of frequency vectors in the FRD The maximum number of states in any model in the LTI array To initialize H in the above example to zero..S1..SK)) sys = zpk(zeros(Ny.S1.2.Nf.1. The general syntax for stack is stack(Arraydim... you can initialize an LTI array to zero. and then reassign the entire array to the values you want to specify..S1.. • sys1.Nu..S1.Nu.sys2.SK)) sys = ss(zeros(Ny.2))...Nx)) sys = frd(zeros(Ny. . are the LTI models or LTI arrays to be concatenated.sys1.. 4-15 . before you implement the nested for loops... It concatenates a list of LTI arrays or single LTI models only along the array dimension. sys2. Building LTI Arrays Using the stack Function Another way to build LTI arrays is using the function stack.. type H = tf(zeros(1. The general syntax for zero assignment of LTI arrays is Lengths of the output/input dimensions Lengths of the array dimensions sys = tf(zeros(Ny..Nu.... This function operates on single LTI models as well as LTI arrays..Building LTI Arrays For the purposes of efficient computation.SK...Nu.) where • Arraydim is the array dimension along which to concatenate the LTI models or arrays.

75]. sys = stack(1. such as in stack(j.. % Set up the parameter vectors. w(1)^2]).sys2) concatenates them into a 2-by-1 array of models..4 Arrays of LTI Models When you concatenate several models or LTI arrays along the jth array dimension.[1 individual models with those parameters.[1 H22 = tf(w(2)^2.1.[1 H12 = tf(w(2)^2..66.. w = [1.sysn) • The lengths of the I/O dimensions of sys1... • To concatenate LTI models or LTI arrays along an input or output dimension..sys1.sysn must all match. if two TF models sys1 and sys2 have the same number of inputs and outputs.sysn must match.sys1. w(2)^2]).5]. w(2)^2]). use the bracket notation ([. Note: • stack only concatenates along an array dimension. 2*zeta(1)*w(1) 2*zeta(1)*w(2) 2*zeta(2)*w(1) 2*zeta(2)*w(2) w(1)^2]).sys2.. % Specify the four % H11 = tf(w(1)^2.]).] [.0. not an I/O dimension.. For example. See “Model Interconnection Functions” on page 3-16 for more information on the use of bracket notation to concatenate models.[1 H21 = tf(w(1)^2. 4-16 ... • The lengths of all but the jth array dimension of sys1..2. See also “Special Cases for Operations on LTI Arrays” on page 4-27 for some examples of this type of concatenation of LTI arrays. Here’s an example of how to build the LTI array H using the function stack. zeta = [0.

.H21).. % The first column of the 2-by-2 array COL2 = stack(1. and frd You can also build LTI arrays using the tf..nK). ss.H22]. zpk.. Specifying Arrays of ZPK Models Using zpk For ZPK models.n1.. • num(i.. zpk. Specifying Arrays of TF models tf For TF models. Building LTI Arrays Using tf..nK) is the (i.nK) is a row vector representing the numerator polynomial of sys(i. use sys = tf(num. ….. You do this by using multidimensional arrays in the input arguments for these functions. use sys = zpk(zeros..H12.. COL1.nK) is a row vector representing denominator polynomial of sys(i.. COL1 = stack(1..H21..j.j.n1.n1. % Concatenate the two columns of models. • den(i. n K ) position of the array.j.j.. Notice that this result is very different from the single MIMO LTI model returned by H = [H11.den) where • Both num and den are multidimensional cell arrays the same size as sys (see “size and ndims” on page 4-9).. • sys(i. j) entry of the transfer matrix for the model located in the ( n 1.gains) 4-17 .Building LTI Arrays % Set up the LTI array using stack. and frd constructors.j.poles.n1.H11.. COL2). See “MIMO Transfer Function Models” on page 2-10 for related information on the specification of single TF models...H22).H12.n1. % The second column of the 2-by-2 array H = stack(2..nK).. ss.

c. Use stack to build such LTI arrays. Note: You cannot use the ss constructor to build an array of state-space models with different numbers of states. sys. determine those of the LTI array. Specifying Arrays of SS Models Using ss To specify arrays of SS models. poles. • gains is a multidimensional array containing the scalar gains for each I/O pair of each model in the array.b. and gains. and d are real-valued multidimensional arrays of appropriate dimensions. use sys = ss(a. outputs. c. and inputs. The Size of LTI Array Data for SS Models The size of the model data for arrays of state-space models is summarized in the following table. Data a b c d Size (Data) N s N s S 1S 2 …S K N s N u S 1 S 2 …S K Ny Ns S 1 S 2 … SK N y N u S 1 S 2 …S K 4-18 . b.4 Arrays of LTI Models where • Both zeros and poles are multidimensional cell arrays whose cell entries contain the vectors of zeros and poles for each I/O pair of each model in the LTI array. • The dimensions (and their lengths) of zeros.d) where a. All models in the resulting array of SS models have the same number of states.

• S 1. Note that for specifying an LTI array of SISO FRD models. S 2.Building LTI Arrays where • N s is the maximum of the number of states in each model in the array.S K complex-valued multidimensional array. S K are the lengths of the array dimensions. ….units) where • frequency is a real vector of n frequency data points common to all FRD models in the LTI array. • N u is the number of inputs in each model. …. use sys = frd(response. 4-19 .frequency. m-input FRD models for which S 1. S K are the lengths of the array dimensions. Specifying Arrays of FRD Models Using frd To specify a K-dimensional array of p-output. • units is the optional string specifying 'rad/s' or 'Hz'. response can also be a multidimensional array of 1-by-n matrices whose remaining dimensions determine the array dimensions of the FRD. S 2. • response is a p-by-m-by-n-by. • N y is the number of outputs in each model.S 1 -by.…-by.

.. n K ) where • Outputs are indices that select output channels. • The remaining indices specify the model coordinates within the array. nK are indices into the array dimensions that select one model or a subset of models in the LTI array.:) for the first two indices to select all I/O channels. • Inputs are indices that select input channels. inputs. the array indices can be followed by the keyword 'frequency' and some expression selecting a subset of the frequency points as in sys (outputs..4 Arrays of LTI Models Indexing Into LTI Arrays You can index into LTI arrays in much the same way as you would for multidimensional arrays to: • Access models • Extract subsystems • Reassign parts of an LTI array • Delete parts of an LTI array When you index into an LTI array sys.. Note on Indexing into LTI Arrays of FRD models: For FRD models. 'frequency'. SelectedFreqs) See “Referencing FRD Models Through Frequencies” on page 3-7 for details on frequency point selection in FRD models. 4-20 . the indices should be organized according to the following format sys(Outputs. Inputs. Accessing Particular Models in an LTI Array To access any given model in an LTI array: • Use colon arguments (:. …. • n 1. …. n1.nk. n 1.

For more information on single index referencing. in the 5-by-2 LTI array sys above. you can simply type sys(:.1.2) position by typing sys(:.1) position by typing sys(:.5.3. “M-File Programming” in Using MATLAB.:.4. [1 2]) or equivalently.0) To access all frequencies of this model in the array.5].:. then you can access the response data corresponding to the middle frequency (3 rad/s). use the syntax described in “Extracting and Modifying Subsystems” on page 3-5.3.3.3.8) since this model is in the eighth position if you were to list the 10 models in the array by successively scanning through its entries along each of its columns.2). 2-input FRD models. of the model in the (3. A = sys(1. For example.3.3. sys = rss(4.2.:) 4-21 .2.'frequency'.[1 2]. A = sys(1.1) Single Index Referencing of Array Dimensions You can also access models using single index referencing of the array dimensions.Indexing Into LTI Arrays For example.2). if sys is a 5-by-2 array of state-space models defined by sys = rss(4. Extracting LTI Arrays of Subsystems To select a particular subset of I/O channels from all the models in an LTI array.2) If sys is a 5-by-2 array of 3-output.:.2) position of the array sys by typing sys(:.3. see the “Advanced Indexing” section of Chapter 10.:.5. For example. you can access (and display) the model located in the (3.2.:. with frequency vector [1. you can also access the model located in the (3.

j) = H(:. and the first output channel in each model of the LTI array A. This is because I/O selection applies to all models in the array when the array indices are omitted.3.2) To access the subsystem from all inputs to the first two output channels of this same array entry. You can also combine model selection with I/O selection within an LTI array. for k = 1:5 for j = 1:2 sys(1. and returns the resulting 5-by-2 array of one-output. for all models in the LTI array sys.:.2. to access both: • The state-space model in the (3. end end Notice that you don’t have to use the array dimensions with this assignment. This one-line assignment command is equivalent to the following 10-step nested for loop. type sys(1:2.2. 4-22 .2) = H reassigns the subsystem from input two to output one. For example.j).1.2).2) Reassigning Parts of an LTI Array You can reassign entire models or portions of models in an LTI array.k. % 5X2 array of SISO models sys(1. % 5X2 array of state-space models H = rss(4. For example.4 Arrays of LTI Models selects the first two input channels.2) array position • Only the portion of that model relating the second input to the first output type sys(1.k. sys = rss(4. This SISO subsystem of each model in the LTI array is replaced with the LTI array H of SISO models.2).1.3.5.3.5. two-input subsystems.:.2.

Indexing Into LTI Arrays

**Similarly, the commands
**

sys(:,:,3,2) = sys(:,:,4,1); sys(1,2,3,2) = 0;

reassign the entire model in the (3,2) position of the LTI array sys and the (1,2) subsystem of this model, respectively.

**LTI Arrays of SS Models with Differing Numbers of States
**

You must use an entire LTI model for reassignment if you have an LTI array sys of state-space models for which: • The numbers of states in each model in sys is not constant. • You want to change the dimensions of the a, b, and c matrices in one model as you reassign its a, b, and c properties. For example, if

sys = ss(stack(1,tf(1,[1 2 1]),tf(1,[1 1])));

then the model sys(:,:,1) is of order 2, while sys(:,:,2) is of order 1. To reassign the a, b, and c properties of sys(:,:,1) so that the state dimension of the new model is not 2, you must make the entire model assignment at once. You can do this as follows.

sys(:,:,1) = sys2

where sys2 represents an LTI model for which size(sys2,'order') is not 2.

**Deleting Parts of an LTI Array
**

You can use indexing to delete any part of an LTI array by reassigning it to be empty ([]). For instance,

sys = rss(4,3,2,5,2); sys(1,:) = []; size(sys) 5x2 array of continuous-time state-space models Each model has 2 outputs, 2 inputs, and 4 states.

deletes the first output channel from every model of this LTI array.

4-23

4

Arrays of LTI Models

Similarly,

sys(:,:,[3 4],:) = []

deletes the third and fourth rows of this two-dimensional array of models.

4-24

Operations on LTI Arrays

**Operations on LTI Arrays
**

Using LTI arrays, you can apply almost all of the basic model operations that work on single LTI models to entire sets of models at once. These basic operations, discussed in Chapter 3, “Operations on LTI Models,” include: • The arithmetic operations: +, –, *, /,\,',.' • The model interconnection functions: concatenation along I/O dimensions ([,], [;]), feedback, append, series, parallel, and lft When you apply any of these operations to two (or more) LTI arrays (for example, sys1 and sys2), the operation is implemented on a model-by-model basis. Therefore, the kth model of the resulting LTI array is derived from the application of the given operation to the kth model of sys1 and the kth model of sys2. For example, if sys1 and sys2 are two LTI arrays and

sys = op(sys1,sys2)

then the kth model in the resulting LTI array sys is obtained by adding the kth models in sys1 to the kth model in sys2

sys(:,:,k) = sys1(:,:,k) + sys2(:,:,k)

You can also apply any of the response plotting functions such as step, bode, and nyquist described in Chapter 5, “Model Analysis Tools,” to LTI arrays. These plotting functions are also applied on a model by model basis. See “The Right-Click Menu for LTI Arrays” on page 6-28 for information on using the model selector for LTI arrays on response plots.

4-25

4

Arrays of LTI Models

**Example: Addition of Two LTI Arrays
**

The following diagram illustrates the addition of two 3-by-1 LTI arrays

sys1+sys2.

sys1(:,:,3) sys2(:,:,3) sys(:,:,3)

1 ----------s+2

+

1 ---------------s + 4.5

=

2s + 6.5 -------------------------------2 s + 6.5s + 9

sys1(:,:,2)

sys2(:,:,2)

sys(:,:,2)

1 ---------------s + 2.5

+

2.1 ----------s+4

=

3.15 + 9.25 ----------------------------------2 s + 6.5s + 10

sys1(:,:,1)

sys2(:,:,1)

sys(:,:,1)

1 ---------------s + 2.9

+

1.5 ---------------s + 3.9

=

2.5s + 8.25 ------------------------------------------2 s + 6.8s + 11.31

sys1

+

sys2

=

sys

Figure 4-8: The Addition of Two LTI Arrays

**The summation of these LTI arrays
**

sys = sys1+sys2

**is equivalent to the following model-by-model summation.
**

for k = 1:3 sys(:,:,k)=sys1(:,:,k) + sys2(:,:,k) end

4-26

Operations on LTI Arrays

Note that: • Each model in sys1 and sys2 must have the same number of inputs and outputs. This is required for the addition of two LTI arrays. • The lengths of the array dimensions of sys1 and sys2 must match.

Dimension Requirements

In general, when you apply any of these basic operations to two or more LTI arrays: • The I/O dimensions of each of the LTI arrays must be compatible with the requirements of the operation. • The lengths of array dimensions must match. The I/O dimensions of each model in the resulting LTI array are determined by the operation being performed. See Chapter 3, “Operations on LTI Models,” for requirements on the I/O dimensions for the various operations. For example, if sys1 and sys2 are both 1-by-3 arrays of LTI models with two inputs and two outputs, and sys3 is a 1-by-3 array of LTI models with two outputs and 1 input, then

sys1 + sys2

**is an LTI array with the same dimensions as sys1 and sys2.
**

sys1 * sys3

**is a 1-by-3 array of LTI models with two outputs and one input, and
**

[sys1,sys3]

is a 1-by-3 array of LTI models with two outputs and three inputs.

**Special Cases for Operations on LTI Arrays
**

There are some special cases in applying operations to LTI arrays. Consider applying any binary operation called op (such as +, –, or *) to an LTI array sys1

sys = op(sys1,sys2)

4-27

4

Arrays of LTI Models

where sys, the result of the operation, is an LTI array with the same array dimensions as sys1. You can use shortcuts for coding sys = op(sys1,sys2) in the following cases: • For operations that apply to LTI arrays, sys2 does not have to be an array. It can be a single LTI model (or a gain matrix) whose I/O dimensions satisfy the compatibility requirements for op (with those of each of the models in sys1). In this case, op applies sys2 to each model in sys1, and the kth model in sys satisfies

sys(:,:,k) = op(sys1(:,:,k),sys2)

• For arithmetic operations, such as +, *, /, and \, sys2 can be either a single SISO model, or an LTI array of SISO models, even when sys1 is an LTI array of MIMO models. This special case relies on MATLAB’s scalar expansion capabilities for arithmetic operations. - When sys2 is a single SISO LTI model (or a scalar gain), op applies sys2 to sys1 on an entry-by-entry basis. The ijth entry in the kth model in sys satisfies

sys(i,j,k) = op(sys1(i,j,k),sys2)

- When sys2 is an LTI array of SISO models (or a multidimensional array of scalar gains), op applies sys2 to sys1 on an entry-by-entry basis for each model in sys.

sys(i,j,k) = op(sys1(i,j,k),sys2(:,:,k))

**Examples of Operations on LTI Arrays with Single LTI Models
**

Suppose you want to create an LTI array containing three models, where, for τ in the set { 1.1, 1.2, 1.3 } , each model H τ ( s ) has the form 1 ---------s+τ –1 0 1 -s

Hτ( s ) =

4-28

Operations on LTI Arrays

You can do this efficiently by first setting up an LTI array h containing the SISO models 1 ⁄ ( s + τ ) and then using concatenation to form the LTI array H of MIMO LTI models H τ ( s ), τ ∈ { 1.1, 1.2, 1.3 }. To do this, type

tau = [1.1 1.2 1.3]; for i=1:3 % Form LTI array h of SISO models. h(:,:,i)=tf(1,[1 tau]); end H = [h 0; –1 tf(1,[1 0])]; %Concatenation: array h & single models size(H) 3x1 array of continuous-time transfer functions Each transfer function has 2 output(s) and 2 input(s).

Similarly, you can use append to perform the diagonal appending of each model in the SISO LTI array h with a fixed single (SISO or MIMO) LTI model.

S = append(h,tf(1,[1 3])); % Append a single model to h.

specifies an LTI array S in which each model has the form 1 ---------s+τ 0 0 1 ----------s+3

Sτ ( s ) =

You can also combine an LTI array of MIMO models and a single MIMO LTI model using arithmetic operations. For example, if h is the LTI array of three SISO models defined above,

[h,h] + [tf(1,[1 0]);tf(1,[1 5])]

adds the single one-output, two-input LTI model [1/s 1/(s + 5)] to every model in the 3-by-1 LTI array of one-output, two-input models [h,h]. The result is a new 3-by-2 array of models.

**Examples: Arithmetic Operations on LTI Arrays and SISO Models
**

Using the LTI array of one-output, two-input state-space models [h,h], defined in the previous example,

tf(1,[1 3]) + [h,h]

4-29

4

Arrays of LTI Models

adds a single SISO transfer function model to each entry in each model of the LTI array of MIMO models [h,h]. Finally,

G = rand(1,1,3,1); sys = G + [h,h]

adds the array of scalars to each entry of each MIMO model in the LTI array [h,h] on a model-by-model basis. This last command is equivalent to the following for loop.

hh = [h,h]; for k = 1:3 sys(:,:,k) = G(1,1,k) + hh(:,:,k); end

**Other Operations on LTI Arrays
**

You can also apply the analysis functions, such as bode, nyquist, and step, to LTI arrays. See Chapter 5, “Model Analysis Tools,” for more information on these functions.

4-30

5

Model Analysis Tools

General Model Characteristics . . . . . . . . . . . 5-2 Model Dynamics . . . . . . . . . . . . . . . . . . 5-4 State-Space Realizations . . . . . . . . . . . . . . 5-7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-9 5-9 5-11 5-13 5-17

Time and Frequency Response . . . Time Responses . . . . . . . . . . . Frequency Response . . . . . . . . . Plotting and Comparing Multiple Systems Customizing the Plot Display . . . . . .

Model Order Reduction . . . . . . . . . . . . . . . 5-20

5

Model Analysis Tools

**General Model Characteristics
**

General model characteristics include the model type, I/O dimensions, and continuous or discrete nature. Related commands are listed in the table below. These commands operate on continuous- or discrete-time LTI models or arrays of LTI models of any type.

General Model Characteristics Commands class hasdelay isa isct isdt isempty isproper issiso ndims reshape size

Display model type ('tf', 'zpk', 'ss', or 'frd'). Test true if LTI model has any type of delay. Test true if LTI model is of specified class. Test true for continuous-time models. Test true for discrete-time models. Test true for empty LTI models. Test true for proper LTI models. Test true for SISO models. Display the number of model/array dimensions. Change the shape of an LTI array. Output/input/array dimensions. Used with special syntax, size also returns the number of state dimensions for state-space models, and the number of frequencies in an FRD model.

5-2

General Model Characteristics

This example illustrates the use of some of these commands. See the related reference pages for more details.

H = tf({1 [1 –1]},{[1 0.1] [1 2 10]}) Transfer function from input 1 to output: 1 ------s + 0.1 Transfer function from input 2 to output: s – 1 -------------s^2 + 2 s + 10

class(H) ans = tf size(H) Transfer function with 2 input(s) and 1 output(s). [ny,nu] = size(H)% Note: ny = number of outputs ny = 1 nu = 2 isct(H)% Is this system continuous? ans = 1 isdt(H)% Is this system discrete? ans = 0

5-3

5

Model Analysis Tools

Model Dynamics

The Control System Toolbox offers commands to determine the system poles, zeros, DC gain, norms, etc. You can apply these commands to single LTI models or LTI arrays. The following table gives an overview of these commands.

Model Dynamics covar damp dcgain dsort esort norm pole, eig pzmap zero

Covariance of response to white noise. Natural frequency and damping of system poles. Low-frequency (DC) gain. Sort discrete-time poles by magnitude. Sort continuous-time poles by real part. Norms of LTI systems ( H 2 and L ∞ ). System poles. Pole/zero map. System transmission zeros.

With the exception of L ∞ norm, these commands are not supported for FRD models.

5-4

7971 –1.inf)% peak gain of freq.7039i 2.0000 dcgain(h) ans = 1 [ninf.2137i 2.12 s^3 + 17.4 30.4 30.[1 4.7039i zero(h) ans = –0. h = tf([4 8.8537 % peak gain % frequency where gain peaks 5-5 .Model Dynamics Here is an example of model analysis using some of these commands.7382i –0.8 60]. response ninf = 1.0500 – 2.4 s^2 + 30.8 s + 60 pole(h) ans = –1.2629 + – + – 2.7382i –2.0500 + 2.3402 fpeak = 1.12 17.2629 –0.7971 –0.8 s + 60 --------------------------------------s^4 + 4.2137i 2.4 s^2 + 30.8 60]) Transfer function: 4 s^3 + 8.fpeak] = norm(h.

:.056 s + 0.3.2011 ans(:.6337 -2.:.4282 s^2 + 0.905 --------------------s^2 + 5. the poles of a three dimensional LTI array sysarray are obtained as follows.2452 5-6 .2. pole(sysarray) ans(:.:.672 s + 7.:.1) ======================= Transfer function: 0.3) = -1.942 s + 2. sysarray = tf(rss(2.1.621 s + 0.3706 s + 0.1) = -3.1) ======================= Transfer function: 0.1) ======================= Transfer function: -0.5 Model Analysis Tools These functions also operate on LTI arrays and return arrays.113 3x1 array of continuous-time transfer functions.04264 ------------------------------s^2 + 1.1. For example.:.405 Model sysarray(:.1.8549 -0.2) = -0.6201 s .7567 --------------------s^2 + 2.:.1.0379 ans(:.3)) Model sysarray(:.6968 -1.1719 Model sysarray(:.

State-Space Realizations canon ctrb ctrbf gram obsv obsvf ss2ss ssbal Canonical state-space realizations. perform state coordinate transformations on. Observability staircase form. or obsvf are often badly scaled. CT ) to balance the state-space data the norm of the matrix. and poorly suited for 5-7 . C ) . and derive canonical state-space realizations for single state-space LTI models or LTI arrays of state-space models. State coordinate transformation. This is accomplished by reducing T B 0 –1 Such balancing usually improves the numerical conditioning of subsequent state-space computations. Diagonal balancing of state-space realizations. T B. the canonical realizations produced by canon. The function ssbal uses a simple diagonal similarity transformation ( A. C ) → ( T AT. Controllability staircase form. Observability matrix. sensitive to perturbations of the data. B. Controllability and observability gramians. Note that conversions to state-space using ss produce balanced realizations of transfer functions and zero-pole-gain models. T AT CT –1 –1 –1 ( A. By contrast.State-Space Realizations State-Space Realizations The following functions are useful to analyze. B. ctrbf. Controllability matrix.

5-8 . it is wise to use them only for analysis purposes and not in control design algorithms. Consequently.5 Model Analysis Tools state-space computations.

overshoot. SISO or MIMO). Initial condition response. Note that you can simulate the response to white noise inputs using lsim and the function rand (see Using MATLAB to generate random input vectors. settling time. or ZPK models or arrays of these types of models. ZPK. Step response. Time Responses Time responses investigate the time-domain transient behavior of LTI models for particular classes of inputs and disturbances. You can only apply the frequency domain analysis tools FRDs. impulse. Simulation of response to arbitrary inputs. The LTI Viewer provides an integrated graphical user interface (GUI) to analyze and compare LTI models (see Chapter 6. continuous or discrete. The Control System Toolbox provides functions for step response.Time and Frequency Response Time and Frequency Response The Control System Toolbox contains a set of commands that provide the basic time and frequency domain analysis tools required for control system engineering. “The LTI Viewer” for details). SS.x0) % x0 = initial state vector 5-9 . and steady-state error from the time response. Input signal generator. Their syntax is step(sys) impulse(sys) initial(sys. You can apply these functions to single TF. These commands apply to any kind of LTI model (TF. impulse response. The functions step. You can determine such system characteristics as rise time. and general linear simulations. initial condition response. or SS. and initial automatically generate an appropriate simulation horizon for the time response plots. Time Response impulse initial gensig lsim step Impulse response.

For example.01:10 % time samples spaced every 0.10) % simulates from 0 to 10 seconds or a vector of evenly spaced time samples. h = [tf(10. The simulation horizon is automatically determined based on the model dynamics.[1 1])] step(h) produces the following plot. t = 0:0. these commands produce an array of plots with one plot per I/O channel (or per output for initial and lsim).5 Model Analysis Tools where sys is any continuous or discrete LTI model or LTI array.01 second step(sys.t) 5-10 . For MIMO models. tf(1. You can override this automatic mode by specifying a final time step(sys.[1 2 10]) .

Time and Frequency Response Note: When specifying a time vector t = [0:dt:tf]. dt should match the system sample time. • Continuous systems are first discretized using zero-order hold and dt as sampling period. remember the following constraints on the spacing dt between time samples: • For discrete systems. Finally. you should pick dt small enough to capture the main features of the continuous transient response. For example. As a result. the function lsim simulates the response to more general classes of inputs. Note: You can also implement several plotting options by using the right-click menus accessible from the (white) plot region of all time and frequency plots. see “The Right-Click Menus” on page 6-18 Frequency Response The Control System Toolbox provides response-plotting functions for the following frequency domain analysis tools: • Bode plots • Nichols charts • Nyquist plots • Singular value plots 5-11 . and step simulates the resulting discrete system. These options are listed on the menu. The syntax step(sys) automatically takes these issues into account.u.01:10 u = sin(t) lsim(sys. To learn more about the right-click menus on plots.t) simulates the zero-initial condition response of the LTI system sys to a sine wave for a duration of 10 seconds. t = 0:0.

These functions can be applied to single LTI models or LTI arrays. Table 5-1: Frequency Response Function Name bode evalfr Description Computes the Bode plot. Phase is plotted in degrees. Computes gain and phase margins. Computes the Nyquist plot. Computes the frequency response for a set of frequencies. To set the frequency range explicitly to some interval [wmin. The frequency grid used to evaluate the response is automatically selected based on the system poles and zeros. Computes the Nichols plot. the function margin determines the gain and phase margins for a given SISO open-loop model. and an array of plots in the MIMO case.{wmin . Computes the frequency response at a single complex frequency (not for FRD models). Applies grid lines to a Nichols plot. wmax}) % Note the curly braces 5-12 . use the syntax bode(sys.wmax].5 Model Analysis Tools In addition. The Bode plot produced by bode plots the magnitude of the frequency response in decibels (dB). Computes the singular value plot. as 20*log10(abs(response)). the commands bode(sys) nichols(sys) nyquist(sys) sigma(sys) handle both continuous and discrete models. These functions produce a frequency response plot for SISO LTI models. freqresp margin ngrid nichols nyquist sigma As for time response functions.

1 rad/s and ending at 10 = 100 rad/s. Plotting and Comparing Multiple Systems The LTI Viewer provides one method of plotting various responses for multiple models. The upper half of the unit circle is parametrized by z=e jωT s . See the reference page for linspace for linearly spaced frequency vectors. Note: In discrete time.{0.100) bode(sys. “The LTI Viewer” for more information. 100}) draws the Bode plot between 0. You can also use the command line response-plotting functions to plot the response of 5-13 . We use this “equivalent frequency” as an x -axis variable in all discrete-time frequency response plots. You can also specify a particular vector of frequency points as in w = logspace(–1. the frequency response is evaluated on the unit circle and the notion of “frequency” should be understood as follows. the frequency response is plotted only up to the Nyquist frequency ω N because it is periodic with period 2ω N (a phenomenon known as aliasing). bode(sys.1 and 100 radians/second. See Chapter 6. π 0 ≤ ω ≤ ω N = ----Ts where T s is the system sample time and ω N is called the Nyquist frequency. The variable ω plays the role of continuous-time frequency.Time and Frequency Response For example. “The LTI Viewer” to see how to accomplish this. Note: An easy way to implement these response-plotting functions is through the LTI Viewer.w) The logspace command generates a vector w of logarithmically spaced –1 2 frequencies starting at 10 = 0. See Chapter 6.1 . In addition.2.

’gx’) plots sys1 with solid red lines.’r’..sysN) ...sys2. step(sys1.sys2.. invoke the corresponding command line function using the list sys1.. bode(sys1. sys2 with yellow dashed lines.... sysN of models as the inputs.’y--’.sys3.sysN) nichols(sys1...sys2..sys2... 5-14 . bode(sys1...sys2.sysN) impulse(sys1.. To differentiate the plots easily.... You can plot responses of multiple models on the same plot.. These models need not be all continuous-time or all discrete-time.. you can also specify a distinctive color/linestyle/ marker for each system just as you would with the plot command.5 Model Analysis Tools several LTI models on a single plot.... To do so. All models in the argument lists of any of the response plotting functions (except for sigma) must have the same number of inputs and outputs.sysN) . and sys3 with green x markers. For example.

2 second step(sysc.sysd.0. sysc = tf(1000.'--'.'-') % compare step responses 5-15 .[1 10 1000]) sysd = c2d(sysc.Time and Frequency Response The following example compares a continuous model with its zero-order-hold discretization.2) % ZOH sampled at 0.

sysd. there are hidden oscillations in the discretized time response and aliasing conceals the continuous-time resonance near 300 rad/sec.'-') % compare Bode responses A comparison of the continuous and discretized responses reveals a drastic undersampling of the continuous system.5 Model Analysis Tools bode(sysc. 5-16 . Specifically.'--'.

as well as your own data.im. • Use the subplot and hold commands to plot several sets of data in a single figure window. and bode with output arguments [y. see “Viewer Configuration Window” on page 6-39. There are several ways you can customize how you display plots: • Store the time or frequency response data in MATLAB arrays by invoking response analysis functions such as step.t] = step(sys) [mag. For more information.w] = nyquist(sys) and use the plot command to display the result. • Use the plot configuration menu in the LTI Viewer for time and frequency responses of LTI models.Time and Frequency Response Customizing the Plot Display You can plot data generated by several response analysis functions applied to one or several LTI models. 5-17 .phase.w] = bode(sys) [re.

4 30.[1 4.8 60]). and some additional data in a single figure window. subplot (121) bode(h) subplot(222) bode(h) subplot(224) bode(h) 5-18 . the following sequence of commands displays the Bode plot.4 30.8 60].12 17. pole/zero map. h = tf([4 8. step response.5 Model Analysis Tools For example.

and pzmap) has its own right-click menu (similar to those in the LTI viewer. 100)) % any data can go here title('Some noise') Note: Each of the plots generated by response analysis functions in these figures (here. step. 5-19 . For more information.Time and Frequency Response Another example is subplot(221) bode(h) subplot(222) step(h) subplot(223) pzmap(h) subplot(224) plot(rand(1. see “The Right-Click Menus” on page 6-18. bode.

5 Model Analysis Tools Model Order Reduction You can derive reduced-order models with the following commands. State deletion in I/O balanced realization. Structurally minimal realization Use minreal to delete uncontrollable or unobservable state dynamics in state-space models. 5-20 . or cancel pole/zero pairs in transfer functions or zero-pole-gain models. Use sminreal to remove any states from a model that don’t affect the I/O response. See the corresponding Reference pages for details. Model Order Reduction balreal minreal modred sminreal Input/output balancing. you can further reduce the model order using a combination of balreal and modred. For already minimal models. Minimal realization or pole/zero cancellation.

. . . . . 6-4 The LTI Viewer Menus . . . . . . . . . . 6-48 .6 The LTI Viewer Introduction . . . . . . . . . . . . . . 6-15 The Right-Click Menus . . . . . . . . . 6-18 The LTI Viewer Tools Menu . . . 6-39 Simulink LTI Viewer . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2 Getting Started Using the LTI Viewer: An Example . . . . . . . . . . . . .

6 The LTI Viewer Introduction The LTI Viewer is a graphical user interface for viewing and manipulating the response plots of LTI models. or ZPK models) • Bode plot • Nyquist plot • Nichols chart • Singular values of the frequency response • Poles and zeros (only for TF. SS. The operation of the Simulink LTI Viewer is discussed at the end of this chapter in “Simulink LTI Viewer” on page 6-48. such as settling time for a step response plot 6-2 . or ZPK models) • Initial state LTI response (only for SS models) The LTI Viewer displays up to six of these different response analysis plot types simultaneously. Functionality of the LTI Viewer The basic function of the LTI Viewer is to display the plots of LTI model responses. or ZPK models) • Impulse response (only for TF. or ZPK models) • LTI model response to a general input (only for TF. SS. Several menus are included for operations such as importing models into the LTI Viewer or printing response plots. However. SS. SS. you can manipulate the LTI Viewer response plots in several ways. A special version of the LTI Viewer can also be used to analyze Simulink models. you must display them in separate LTI Viewers. You can display the following plot types for LTI models using the LTI Viewer: • Step response (only for TF. including: • Change the type of plot being displayed in each plot region of the LTI Viewer • Toggle on and off the response plots of individual LTI models loaded in the LTI Viewer • Display response plot characteristics for a given plot type. In addition to these data operations. in order to analyze models with different numbers of inputs and outputs. You can also analyze the response plots of several LTI models at once.

. Bode plot and step response) simultaneously • Control of the number of response plot regions that appear (one to six regions) in the LTI Viewer Many of these features are accessed and controlled through plot-specific right-click menus.g. select how the LTI Viewer displays the I/O channels for MIMO models • Select which models of an LTI array you want displayed in the LTI Viewer by indexing into dimensions or model characteristics • Control plot characteristics such as the ranges for time and frequency used in various types of plots • Control linestyle preferences such as the color and marker for each model response plotted • Initialize the LTI Viewer from the command line to display multiple plot types (e.Introduction • Zoom in on or out from the individual displayed plots • Toggle the grid on or off on a plot • Select which I/O channels the LTI Viewer displays for MIMO models in each plot • For a given plot type. 6-3 .

and you want to compare the closed-loop step responses and Bode plots.The settling time on the step responses . Gcl1. Suppose you have a set of compensators you’ve designed to control a system. You can do this with the LTI Viewer.4 s^2 + 30.6 The LTI Viewer Getting Started Using the LTI Viewer: An Example This section contains a brief introduction to the LTI Viewer through an example that leads you through the following steps: 1 Load two LTI models into the LTI Viewer.The peak magnitude response on the Bode plots 3 Use the mouse to display the values of these response characteristics on the plots. initialized with the step responses and Bode plots of both models. Gcl3 Transfer function: 4 s^3 + 8. you analyze the response plots of these three transfer function models.mat. 5 Use the right-click menu to zoom in on a plot. Gcl2.8 s + 60 --------------------------------------s^4 + 4.12 s^3 + 17. 2 Use the right-click menu to display markers for .8 s + 60 6-4 . Type load LTIexamples In this example.4 s^2 + 30. 4 Import a third LTI model to the LTI Viewer for comparison. A sample set of closed-loop transfer function models are included (along with some other models) in the MAT-file LTIexamples.

.1 s + 7.12 s^3 + 10.1 s + 7.5 Initializing the LTI Viewer with Multiple Plots For a given LTI model.1 s + 7. The plot type names can be any of the following.sysn) where: • {'type1'...'type2'. .sys1.32 s^3 + 10.. sysn is a list of the MATLAB workspace variable names for the systems whose responses you want to initially display in the LTI Viewer... Plot Type bode impulse initial lsim nichols nyquist Description Bode plot Impulse response Initial state response for SS models LTI model response to general input Nichols chart Nyquist plot 6-5 . The general syntax for initializing the LTI Viewer to plot up to six plot types is ltiview({'type1'.12 s^2 + 9...2 s^3 + 1..Getting Started Using the LTI Viewer: An Example Transfer function: 2 s^3 + 1. You can also initialize the LTI Viewer to display the plots of several different models at once.12 s^2 + 9. you can use the LTI Viewer to simultaneously display multiple response plot types.2 s^2 + 15... • sys1.'typek'}.5 ---------------------------------------s^4 + 2...5 Transfer function: 1. such as the Bode plot and the step response.5 ---------------------------------------s^4 + 1.'typek'} is a cell array listing up to six strings for the names of the plot types ( k ≤ 6 )..2 s^2 + 15.1 s + 7..'type2'.

'bode'}.6 The LTI Viewer Plot Type pzmap sigma step Description Plot of poles and zeros Singular values of the frequency response Step response Note: When you initialize the LTI Viewer with lsim or initial. these plot types require some extra arguments. To load the two models Gcl1.Gcl1. For more information on the syntax for calling ltiview.Gcl2) This opens the following LTI Viewer. see ltiview on page 11-133. 6-6 . and Gcl2 into the LTI Viewer so that it displays the step responses and Bode plots of both models. type ltiview({'step'.

Plot region for the Bode plot Status bar provides useful information. depending on if the LTI Viewer is displaying the response plots of SISO models. Right-Click Menus: Setting Response Characteristics To access the individual response plot controls. Some of the menu items are also plot type dependent. Two response curves are plotted on each of the two plot regions. suppose you want to mark the settling time on the step responses. MIMO models. These right-click menus vary. For example.Getting Started Using the LTI Viewer: An Example Plot region for the step response The File menu has several items. To do this: 6-7 . and the peak magnitude response on the Bode plots. including ones that allow you to import models and print plots. The Tools menu items allow you to reconfigure the plot arrangement and set general plot and linestyle preferences for this open LTI Viewer. or LTI arrays. use the right-click menus available from any of the plot regions displayed. Right-click on either plot region to see the response plot menus.

4 Place your mouse pointer on the Characteristics menu item. The submenu items of the Characteristics menu for the Bode plot are different than those of the Characteristics menu for the step response right-click menu.6 The LTI Viewer 1 Right-click anywhere in the plot region of the step response plots. Figure 6-3: Bode Plot Characteristics Submenu 5 Select Peak Response with your left mouse button. Figure 6-1: The Right-Click Menu for SISO Models 2 Place your mouse pointer on the Characteristics menu item. 6-8 . Figure 6-2: The Step Response Characteristics Submenu 3 Right-click anywhere in the plot region of the Bode plots to open a right-click menu. This opens the following menu list in the plot region. and select Settling Time with your left mouse button.

Notice that there is one settling time or peak magnitude marker for each LTI model displayed in the LTI Viewer.Getting Started Using the LTI Viewer: An Example Your LTI Viewer should now look like this. 6-9 . Displaying Response Characteristics on a Plot To display the values of any plot characteristic marked on a plot: 1 Click on the marker 2 Hold the left or right mouse button down to read the values off the plot.

6-10 . • Left-click anywhere on a particular plot line to see the response values of that plot at that point. Note that you can: • Use either the right or the left mouse button when you select a marker on a plot.6 The LTI Viewer Hold the mouse button down on the marker to display the values. • Right-click anywhere on a plot line to see I/O and model information.

6-11 . To deselect any selected models. 2 Select Gcl3 from the list of models in the workspace browser. The LTI Viewer now shows the step response of Gcl3 in addition to those of Gcl1 and Gcl2. hold down the control key while you click on the highlighted model names. 3 Select OK.Getting Started Using the LTI Viewer: An Example Importing Models If the closed-loop models Gcl1 and Gcl2 do not meet your specifications. LTI model variable names have to be in the LTI Viewer workspace before you can analyze the response plots of these models using the LTI Viewer. To multiselect a list of several models in a row. This opens a browser listing all of the LTI models currently available in the MATLAB workspace. and import the resulting closed-loop model Gcl3 for comparison: 1 Select Import from the File menu. you may want to design another compensator at the command line. select one model and hold down the Control key while selecting additional models. To multiselect individual models. select the first model and hold down the Shift key while selecting the last model you want in the list. This browser allows you to copy LTI models from the MATLAB workspace into the LTI Viewer workspace.

2 Move your mouse pointer over the Zoom menu. 4 Use your mouse to create the rectangular rubberband that indicates the zoom region: 6-12 . For example.5 seconds on the time axis. See “Opening a New LTI Viewer” on page 6-16 for more information. you may want to zoom in on one region of a given plot. in order to inspect the response behavior in that region more closely. Select In-X and a horizontal rubber band is available to select the zoom region. 3 Select X-Y to zoom in both the horizontal and vertical directions. Select X-Y and a rectangular rubber band is available to select the zoom region. use the Zoom menu item available from the right-click menu: 1 Right-click on a plot region (in this case. let’s zoom in on the step responses of these three models in the vicinity of 4.6 The LTI Viewer Note: A given LTI Viewer can only be used to analyze models with the same number of inputs and outputs. Select In-Y and a vertical rubber band is available to select the zoom region. To zoom in on a region on any of the plots. Zooming With three models loaded into the LTI Viewer. the step response) to open the right-click menu. If you want to analyze models with different numbers of inputs or outputs. you must import these into separate LTI Viewers. Your menu looks like this.

Getting Started Using the LTI Viewer: An Example a Point your mouse to any corner of the rectangle of the region you want to zoom in on. Your step response plot looks like this as you select the zoom region. d Release your mouse. c Drag the mouse pointer until the rectangle covers the region you want to zoom in on. 6-13 . and hold the mouse button down.5 seconds on the step response plot. For this example. b Left-Click there. zoom in around the region near 4.

Note: To zoom out. the LTI Viewer looks like this. i. to revert back to the original coordinate limits that were in place before you zoomed. only this time select Out from the Zoom menu. 6-14 . the Bode plot remains unchanged.e.. follow the steps for zooming again.6 The LTI Viewer After releasing the mouse on the zoom region. Notice that you’ve only zoomed on the step response plot.

• Close Viewer—Close an open LTI Viewer. There are two ways of loading models into the LTI Viewer workspace: • Load them into the LTI Viewer workspace when you open the LTI Viewer. • Delete Systems—Delete some or all of the LTI models in the LTI Viewer workspace. • Print—Generate a hardcopy of the LTI model response. Details on some of these menu items are described below. • Import them into an open LTI Viewer using the browser that is opened when you select the Import menu item under the File menu. The File and Help menus are covered in this section. You can read about the Tools menu items in “The LTI Viewer Tools Menu” on page 6-39. The Tools menu allows you to control certain features common to all of the plots. • Print to Figure—Send the LTI Viewer plots to a MATLAB figure window. The Help provides help on the LTI Viewer features. 6-15 . • Refresh Systems—Update the LTI Viewer with any changes you made at the MATLAB command line to models in the LTI Viewer workspace.The LTI Viewer Menus The LTI Viewer Menus The LTI Viewer has three main menus: • File • Tools • Help The File menu provides features pertinent to bringing data in and out of the LTI Viewer. • Import—Bring in new models into the LTI Viewer workspace. • Export—Export models to the MATLAB workspace or to a disk. Importing a New Model into the LTI Viewer Workspace LTI models in the MATLAB workspace can only be viewed by the LTI Viewer if they are in the LTI Viewer workspace. The File Menu The File menu gives you th following options: • New Viewer—Open a new LTI Viewer.

For directions for importing models into the workspace of an open LTI Viewer. Opening a New LTI Viewer The New Viewer option in the File menu enables you to initialize a new LTI Viewer. The Print to Figure option allows you to use the Plot Tools feature of MATLAB figure windows to edit the plots before printing them. Static Help The Help menu contains three submenus: • Overview • Response Preferences • Linestyle Preferences 6-16 . see “Initializing the LTI Viewer with Multiple Plots” on page 6-5. The Print option allows you to print the plots. This is the same as typing ltiview at the MATLAB prompt. go to the File menu: • Choose the Print option to obtain a hardcopy. Refreshing Systems in the LTI Viewer Workspace If you modify the characteristics of an LTI model in the MATLAB workspace. see “Importing Models” on page 6-11.6 The LTI Viewer For directions for loading LTI models into the LTI Viewer workspace when you open it. Getting Help You can obtain instructions on how to use the LTI Viewer directly from the Help menu. select Refresh Systems in the File menu to update the models in the LTI Viewer workspace with the changes you made. You can use this feature to compare response plots of LTI models that don’t have the same numbers of inputs and outputs. exactly as you see them displayed in the LTI Viewer. • Choose the Print to Figure option to send the plots to a MATLAB figure window. Printing Response Plots To print your response plots.

The remaining help menu items pertain to LTI Viewer controls you access from the Tools menu: the Response Preferences and Linestyle Preferences windows. opens the help text describing how to use the LTI Viewer menus and right-click menus that control the LTI Viewer. See the “Response Preferences” on page 6-40” and the “Linestyle Preferences” on page 6-44” sections for more information on the Response Preferences and Linestyle Preferences windows. Interactive Help The status bar at the bottom of the LTI Viewer provides you with instructions. you can consult the status bar to learn: • If you have tried to perform an unsupported function • If a function has successfully been completed • If additional information on the use of an LTI Viewer control is available 6-17 .The LTI Viewer Menus The first submenu. and error messages as you proceed through your analysis. hints. These windows provide additional tools for manipulating the system responses. In general. Overview.

You can’t access the right-click menu for the LTI Viewer plots until at least one response plot is displayed in the LTI Viewer. The Right-Click Menu for SISO Models If you have not already done so. right-click on the plot region of the step response plot. depending on the model dimensions and plot type: • The menu items that appear on the plot regions of the responses for SISO models are the basic right-click menu items. Figure 6-4: The Right-Click Menu for SISO Models 6-18 . Each arrow next to a menu item opens a submenu list when you select the menu item.'bode'}. load the three SISO LTI models into the LTI Viewer workspace.Gcl2. The following menu appears in the plot region. • Additional menu items appear when you are displaying the plots of MIMO LTI models or LTI arrays. You can do this by typing load LTIexamples ltiview({'step'. There is one right-click menu per plot region displayed on the LTI Viewer. These menus vary slightly.Gcl3) Once you have loaded models into the LTI Viewer.Gcl1.6 The LTI Viewer The Right-Click Menus You can access most of the controls for the individual response plots displayed by the LTI Viewer through the right-click menus located in any plot region.

Figure 6-6: The Systems Submenu for Three Models . You can choose to display or hide the plots of LTI models in the LTI Viewer workspace from this menu item: LTI model name The color (in parentheses) is a legend item that indicates the style in which each model’s response plot is displayed.Check marks appear next to the names of models whose plots are displayed. For information on how to modify these preferences. The check mark next to a model name indicates that the model’s response is displayed on the plot that brought up this menu. You can select from any of the items on this list. Names of models that do not have a check mark next to them 6-19 . . marker types.The Right-Click Menus This is the right-click menu for SISO models. or color preferences) is indicated next to the name of each model. The check mark next to the plot type indicates your selection for the type of plot displayed. see “Linestyle Preferences” on page 6-44. These menu items control the LTI Viewer plots for all models: • Plot Type—You can choose which plot type you want displayed from this list of nine plot types. Figure 6-5: Plot Type Submenu • Systems—The Systems submenu lists the models in the LTI Viewer workspace.The legend for the individual response curves (described as linestyle.

You can select any model in the list with your mouse to toggle on (or off) the visibility of its response curve in the selected plot region. For more information. b For exclusive menus such as Plot Type. A check mark indicates that the characteristic is displayed on the plot. 2 Click on any (sub)menu item you want to select: a For options menus such as Characteristics and Systems: If the menu item does not have a check next to it. one menu item must be checked. • Grid—You can toggle a grid on and off by selecting this menu item. by re-opening the right-click menu. but their responses are not displayed on the plot associated with the open menu. • Characteristics—You can toggle on and off the option to display a marker for various response characteristics for each plot type. selecting the menu item will produce a check next to that item. and its submenu (if it has one) is displayed. see “Displaying Response Characteristics on a Plot” on page 6-9. and selecting a plot type other than the one checked changes the plot type according to your selection. Selecting a Menu Item To select any menu item on the right-click menu: 1 Move your mouse over the menu item until it becomes highlighted. For more information. Figure 6-7: The Characteristics Submenu for the Step Response • Zoom—You can zoom in or out of a given plot using the four submenu items in the Zoom menu. . see “Zooming” on page 6-12. 6-20 . Selecting a checked item unchecks that menu selection (deselects that menu option).6 The LTI Viewer are in the LTI Viewer workspace. You can multiselect these submenu items one at a time.

The InputNames have been assigned as Elevator and Flaperon. you can load it into an LTI Viewer workspace. you much have a MIMO model loaded in the LTI Viewer workspace. These additional menu items are: • Axes Grouping for grouping I/O channels • Select I/Os for hiding the plots from some I/O channels To see these menu items. the right-click menu has a few more options than the right-click menu for SISO models does.The Right-Click Menus Note: To multiselect submenu items (such as in the Characteristics or the Systems menus). This model has two inputs and two outputs.ssF8) 6-21 . load this model into the MATLAB workspace by typing load LTIexamples Now that ssF8 is in the MATLAB workspace. and the OutputNames have been assigned as Acceleration and FlightPath. If you haven’t already done so. The model ssF8 in the file LTIexamples.mat is a MIMO state-space model for an F-8 aircraft. type ltiview('nyquist'. To open a new LTI Viewer that displays the four nyquist plots for each of the I/O channels of this model. re-open the right-click menu for each submenu item selection. The Right-Click Menu for MIMO Models When you load a MIMO model into the LTI Viewer.

Each of the four plots displayed represents the I/O response from a single input to a single output. This plot region is displayed as a grid of four distinct plots: one for each I/O response of ssF8.6 The LTI Viewer Your LTI Viewer looks like this. 6-22 . Figure 6-8: Nyquist Plots of the Four I/O Responses in ssF8 Notice that the I/O names for this model appear on the Nyquist plot.

if you have two inputs and three outputs. the LTI Viewer initially displays a three-by-two grid of six separate plots. it displays each I/O response curve in a separate portion of the plot region. Default Axes Grouping setting: Each I/O response is displayed individually. This initial (default) Axes Grouping setting is indicated by (checked) submenu item.The Right-Click Menus Right-click on any part of the plot region (anywhere on the grid of plots). When you first load a MIMO model into the LTI Viewer. 6-23 . For example. In this example. This opens the following menu. The right-click menu for MIMO models has two extra menu items: Axes Grouping and Select I/Os. a two-by-two grid of four separate plots is displayed in the plot region. Figure 6-9: The Right-Click Menu for MIMO Models The Axes Grouping Submenu The Axes Grouping submenu is as follows. None.

There are as many separate portions of the plot region displayed as there are outputs.6 The LTI Viewer You can use the Axes Grouping submenu to reconfigure the grouping of these I/O response curves with the following submenu items. The plot region is divided into two portions: one for each output. Figure 6-10: Axes Grouping: Inputs 6-24 . • Inputs: The response curves from all of the inputs to a given output are plotted in the same portion of the plot region.

The plot region is divided into two portions: one for each input. Figure 6-11: Axes Grouping: Outputs 6-25 .The Right-Click Menus • Outputs: The response curves from a given input to all of the outputs are plotted in the same portion of the plot region. There are as many separate portions of the plot region displayed as there are inputs.

The r