You are on page 1of 274

Computation

Visualization
Programming
User s Guide
Lennart Ljung
Syst em Ident ificat ion
Toolbox
For Use wi th MA TLAB

How to Conta ct The Ma thW orks:


508-647-7000 Phone
508-647-7001 Fax
The Mat hWor ks, Inc. Mail
24 Pr ime Par k Wa y
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 a t 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, pa sscodes
info@mathworks.com Sales, pr icing, and gener al infor mat ion
S yst em Ident ificat ion Toolbox Users Guide
COPYRIGHT 1988 - 1997 by The Mat hWor ks, Inc. All Right s Reser ved.
The soft wa r e descr ibed in t his document is fur nished under a license agr eement . The soft wa r e may be used
or copied only under t he t er ms of t he license a gr 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 hWorks, Inc.
U.S. GOVERNMENT: If Licensee is acquir ing t he Pr ogr ams on beha lf of a ny unit or a gency of t he U.S.
Gover nment , t he following sha ll apply: (a ) For unit s of t he Depar t ment of Defense: t he Gover nment shall
ha ve 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 a ined, a s set for t h in subpar a gr aph (a) of t he Right s in Commercial
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 a gency: NOTICE: Not wit hst anding a ny
ot her lease or license agr eement t hat ma y per t ain t o, or accompa ny t he deliver y of, t he comput er soft war e
a nd accompanying document a t ion, t he r ight s of t he Gover nment r egar ding it s use, repr oduct ion, and disclo-
sur e ar e a s set for t h in Clause 52.227-19 (c)(2) of t he FAR.
MATLAB, Simulink, Ha ndle Gr aphics, and Real-Time Wor kshop ar e r egist er ed t ra demar ks and St at eflow
a nd Tar get La nguage Compiler ar e t r ademar ks of The Mat hWor ks, Inc.
Ot her pr oduct or br a nd na mes a re t r adema r ks or r egist er ed t r adema r ks of t heir r espect ive holders.
Pr int ing Hist or y: Apr il 1988 First print ing
J uly 1991 Second pr int ing
May 1995 Thir d pr int ing
August 1995 Repr int

FAX
u
@
i v
Contents
1
The System Identi fi cati on Problem
What is Syst em Ident ifica t ion? . . . . . . . . . . . . . . . . . . . . . . . 1-2
How is t hat done? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
How do you know if t he model is any good? . . . . . . . . . . . . . . 1-2
Can t he qualit y of t he model be t est ed in ot her ways? . . . . . 1-2
What models ar e most common? . . . . . . . . . . . . . . . . . . . . . . 1-2
Do you have t o assume a model of a par t icular t ype? . . . . . . 1-2
What does t he Syst em Ident ificat ion Toolbox cont ain? . . . . 1-2
Isnt it a big limit at ion t o wor k only wit h linear models? . . . 1-3
How do I get st a r t ed? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
Is t his r ea lly all t her e is t o Syst em Ident ificat ion? . . . . . . . . 1-3
The Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5
The Ba sic Dynamic Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6
Var iant s of Model Descr ipt ions . . . . . . . . . . . . . . . . . . . . . . . . . 1-6
How t o Int er pr et t he Noise Sour ce . . . . . . . . . . . . . . . . . . . . . . . 1-7
Ter ms t o Char a ct er ize t he Model Pr oper t ies . . . . . . . . . . . . . . . 1-9
Impulse Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9
St ep Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9
Fr equency Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9
Zer os and Poles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9
Model Unst able . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13
Feedback in Dat a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13
Noise Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13
Model Or der . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-14
Addit ional Input s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-14
Nonlinea r Effect s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-14
St ill Pr oblems? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-14
Fit Bet ween Simula t ed and Mea sur ed Out put . . . . . . . . . . 1-15
Residua l Analysis Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-15
Pole Zer o Cancellat ions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-15
What Model St r uct ur es Should be Test ed? . . . . . . . . . . . . . 1-15
Mult ivar iable Syst ems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-16
Available Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-16
Wor king wit h Subset s of t he Input Out put Cha nnels . . . . 1-17
Some Pr a ct ical Advice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-17
v Contents
Readi ng More About Sys t e m Ide nti fi cat i on . . . . . . . . . . . . . . . 1-19
2
The Graphi cal User Inte rface
The Model and Dat a Boar ds . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
The Wor king Dat a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3
The Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3
The Validat ion Dat a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
The Wor k Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
Management Aspect s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
Wor kspace Var iables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
Help Text s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
Dat a Repr esent at ion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7
Get t ing Dat a int o t he GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8
Ta king a Look at t he Dat a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10
Pr epr ocessing Dat a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10
Det r ending . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10
Select ing Dat a Ra nges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11
Pr efilt er ing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11
Resampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11
Quickst ar t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12
Checklist for Dat a Ha ndling . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12
Simulat ing Dat a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12
The Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-14
Dir ect Est ima t ion of t he Impulse Response . . . . . . . . . . . . . . . 2-14
Dir ect Est ima t ion of t he Fr equency Response . . . . . . . . . . . . . 2-15
Est imat ion of Par amet r ic Models . . . . . . . . . . . . . . . . . . . . . . . 2-17
Est imat ion Met hod . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-18
Result ing Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-19
How t o Know Which St r uct ur e and Met hod t o Use . . . . . . . 2-19
ARX Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-20
The St r uct ur e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-20
Ent er ing t he Or der Par amet er s . . . . . . . . . . . . . . . . . . . . . . 2-20
Est imat ing Ma ny Models Simult aneously . . . . . . . . . . . . . . 2-20
Est imat ion Met hods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-21
Mult i-Out put Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-21
vi
ARMAX, Out put -Er r or and Box-J enkins Models . . . . . . . . . . . 2-22
The Gener al St r uct ur e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-22
The Special Cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-22
Ent er ing t he Model St r uct ur e . . . . . . . . . . . . . . . . . . . . . . . . 2-23
Est imat ion Met hod . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-23
St at e-Space Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-24
The Model St r uct ur e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-24
Ent er ing Bla ck-Box St at e-Space Model St r uct ur es . . . . . . . 2-24
Est imat ing Ma ny Models Simult aneously . . . . . . . . . . . . . . 2-24
Est imat ion Met hods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-25
User Defined Model St r uct ur es . . . . . . . . . . . . . . . . . . . . . . . . . 2-25
St at e-Space St r uct ur es . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-25
Any Model St r uct ur e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-26
Views and Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-27
The Plot Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-28
File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-28
Opt ions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-28
St yle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-29
Channel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-29
Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-29
Fr equency Response and Dist ur bance Spect r a . . . . . . . . . . . . 2-29
Tr ansient Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-29
Poles and Zer os . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-30
Compa r e Measur ed and Model Out put . . . . . . . . . . . . . . . . . . . 2-30
Residual Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-31
Text Infor mat ion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-32
Pr esent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-32
Modify . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-32
Fur t her Ana lysis in t he MATLAB Wor kspace . . . . . . . . . . . . . 2-32
Mouse But t ons and Hot keys . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-34
The Main ident Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-34
Plot Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-34
Tr oubleshoot ing in Plot s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-35
Layout Quest ions and idpr efs.mat . . . . . . . . . . . . . . . . . . . . . . 2-35
Cust omized Plot s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-36
Impor t fr om a nd Expor t t o Wor kspace . . . . . . . . . . . . . . . . . . . 2-36
What Cannot be Done Using t he GUI . . . . . . . . . . . . . . . . . . . 2-37
vi i Contents
3
Tutori al
Impulse Responses, Fr equency Funct ions, and Spect r a . . . . . . 3-8
Polynomial Repr esent at ion of Tr ansfer Funct ions . . . . . . . . . 3-10
St at e-Space Repr esent at ion of Tr ansfer Funct ions . . . . . . . . . 3-13
Cont inuous-Time St a t e-Space Models . . . . . . . . . . . . . . . . . . . 3-14
Est imat ing Impulse Responses . . . . . . . . . . . . . . . . . . . . . . . . . 3-15
Est imat ing Spect r a and Fr equency Funct ions . . . . . . . . . . . . . 3-16
Est imat ing Par amet r ic Models . . . . . . . . . . . . . . . . . . . . . . . . . 3-17
Subspace Met hods for Est imat ing St at e-Space Models . . . . . . 3-18
Dat a Repr esent at ion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-19
Cor r ela t ion Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20
Spect r al Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20
ARX Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-22
AR Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-23
Gener al Polynomial Black-Box Models . . . . . . . . . . . . . . . . . . . 3-23
St at e-Space Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-25
Opt ional Va r iables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-26
Polynomial Black-Box Models . . . . . . . . . . . . . . . . . . . . . . . . . . 3-29
Mult ivar iable ARX Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-30
St at e-Space Models wit h Fr ee Par amet er s . . . . . . . . . . . . . . . 3-33
Discr et e-Time Innova t ions For m . . . . . . . . . . . . . . . . . . . . . 3-33
Syst em Dynamics Expr essed in Cont inuous Time . . . . . . . 3-33
The Bla ck-Box, Discr et e-Time Case . . . . . . . . . . . . . . . . . . . 3-34
St at e-Space Models wit h Coupled Par amet er s . . . . . . . . . . . . 3-36
St at e-Space St r uct ur es: Init ia l Values and
Numer ical Der ivat ives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-37
Some Examples of User -Defined Model St r uct ur es . . . . . . . . . 3-38
Thet a For mat : t h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-40
Fr equency Funct ion For ma t : ff . . . . . . . . . . . . . . . . . . . . . . . . . 3-41
Zer o-Pole For mat : zp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-43
St at e-Space For ma t : ss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-43
Tr ansfer Funct ion For mat : t f . . . . . . . . . . . . . . . . . . . . . . . . . . 3-44
Polynomial For mat : poly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-45
The ARX For ma t : ar x . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-45
Tr ansfor mat ions Bet ween Discr et e and Cont inuous Models . 3-46
Cont inuous-Time Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-46
Discr et e-Time Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-46
Tr ansfor mat ions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-47
Simulat ion and Pr edict ion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-47
vi i i
Compa r ing Differ ent St r uct ur es . . . . . . . . . . . . . . . . . . . . . . . . 3-49
Checking Pole-Zer o Cancella t ions . . . . . . . . . . . . . . . . . . . . . . . 3-51
Residual Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-52
Noise-Fr ee Simulat ions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-53
Assessing t he Model Uncer t aint y . . . . . . . . . . . . . . . . . . . . . . . 3-53
Compa r ing Differ ent Models . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-54
Condit ioning of t he Pr edict ion Er r or Gr adient . . . . . . . . . . . . 3-55
Select ing Model St r uct ur es for Mult iva r iable Syst ems . . . . . . 3-55
Offset Levels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-58
Out lier s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-58
Filt er ing Dat a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-58
Feedback in Dat a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-59
Delays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-59
The Basic Algor it hm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-61
Choosing an Adapt at ion Mecha nism and Ga in . . . . . . . . . . . . 3-62
Availa ble Algor it hms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-65
Segment at ion of Dat a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-67
Time Ser ies Modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-68
The Sa mpling Int er va l . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-70
Out of Memor y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-71
Memor y-Speed Tr ade-Offs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-72
Regula r izat ion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-72
Local Minima . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-73
Init ia l Par amet er Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-73
Linear Regr ession Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-74
Spect r um Nor malizat ion and t he Sampling Int er val . . . . . . . 3-75
Int er pr et at ion of t he Loss Funct ion . . . . . . . . . . . . . . . . . . . . . 3-77
Enumer at ion of Est imat ed Par amet er s . . . . . . . . . . . . . . . . . . 3-78
Complex-Valued Dat a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-79
St r ange Result s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-79
4
Command Reference
i x Contents

1
The Syst em Ident ificat ion
Pr oblem
Bas i c Que st i ons About Sys te m Ident i fi cat i on . . . . . . . . . . . 1-2
Common Te rms Us e d i n Sys te m Ide nt i fi cat i on . . . . . . . . . . 1-4
Bas i c Informat i on About Dynami c Mode l s . . . . . . . . . . . . . . 1-5
The Basi c Ste ps of Syst e m Ide nt i fi cat i on . . . . . . . . . . . . . . 1-10
A Start up Ide nt i fi cat i on Proce dure . . . . . . . . . . . . . . . . . . . 1-12
Re adi ng More About Sys te m Ide nt i fi cat i on . . . . . . . . . . . . . 1-18
1 Th e S y ste m Id e n ti f i c a ti o n Pr o b l e m
1-2
1. Basic Questions About System Identification
What is System Identification?
Syst em Ident ificat ion allows you t o build ma t hemat ical models of a dynamic
syst em based on measur ed dat a.
How is tha t done?
Essent ia lly by adjust ing pa r amet er s wit hin a given model unt il it s out put
coincides as well as possible wit h t he measur ed out put .
How do you know if the model is a ny good?
A good t est is t o t ake a close look at t he models out put compar ed t o t he
measur ed one on a dat a set t ha t wasnt used for t he fit (Validat ion Dat a).
Can the qua lity of the model be tested in other w a ys?
It is also valuable t o look at what t he model couldnt r epr oduce in t he dat a (t he
r esiduals). This should not be cor r elat ed wit h ot her a vailable infor mat ion,
such a s t he syst em's input .
What models are most common?
The t echniques apply t o ver y gener al models. Most common models ar e
differ ence equat ions descr ipt ions, such as ARX and ARMAX models, as well as
all t ypes of linear st at e-space models.
Do you have to assume a model of a par ticular type?
For par amet r ic models, you have t o specify t he st r uct ur e. However , if you just
assume t ha t t he syst em is linear , you can dir ect ly est imat e it s impulse or st ep
r esponse using Cor r elat ion Ana lysis or it s fr equency r esponse using Spect r al
Analysis. This allows useful compar isons wit h ot her est imat ed models.
What does the System Identification Toolbox conta in?
It cont ains a ll t he common t echniques t o adjust par a met er s in all kinds of
linear models. It also allows you t o examine t he models pr oper t ies, a nd t o
check if t hey ar e any good, as well as t o pr epr ocess and polish t he measur ed
dat a .
1-3
Isnt it a big limitation to w ork only w ith linear models?
No, act ually not . Most common model nonlinear it ies ar e such t hat t he
measur ed dat a should be nonlinear ly t r ansfor med (like squar ing a volt age
input if you t hink t hat it s t he power t hat is t he st imuli). Use physical insight
about t he syst em you ar e modeling and t r y out such t r a nsfor mat ions on models
t hat a r e linear in t he new var iables, a nd you will cover a lot !
How do I get started?
If you ar e a beginner , br owse t hr ough Cha pt er and t hen t r y out a couple of t he
dat a set s t hat come wit h t he t oolbox. Use t he gr aphical user int er face (GUI)
and check out t he built -in help funct ions t o under st a nd what you a r e doing.
Is this rea lly all there is to System Identification?
Act ually, t her e is a huge amount wr it t en on t he subject . Exper ience wit h r ea l
dat a is t he dr iving for ce t o under st and mor e. It is impor t ant t o r emember t hat
any est imat ed model, no mat t er how good it looks on your scr een, has only
picked up a simple r eflect ion of r ealit y. Sur pr isingly oft en, however , t his is
sufficient for r a t ional decision making.
1 Th e S y ste m Id e n ti f i c a ti o n Pr o b l e m
1-4
2. Common Terms Used in System Identification
This sect ion defines some of t he t er ms t hat ar e fr equent ly used in Syst em
Ident ificat ion.
Es t i mat i on Dat a is t he dat a set t ha t is used t o fit a model t o dat a. In t he
GUI t his is t he same as t he Worki ng Dat a.
Vali dat i on Dat a is t he da t a set t hat is used for model validat ion pur poses.
This includes simulat ing t he model for t hese dat a and comput ing t he
r esiduals fr om t he model when applied t o t hese dat a.
Mode l Vi e ws ar e var ious ways of inspect ing t he pr oper t ies of a model. They
include looking at zer os and poles, t r a nsient a nd fr equency r esponse, and
simila r t hings.
Dat a Vi e ws a r e var ious ways of inspect ing pr oper t ies of dat a set s. A most
common and useful t hing is just t o plot t he dat a and scr ut inize it .
So-called out liers could be det ect ed t hen. These ar e unr elia ble
measur ement s, per ha ps ar ising fr om fa ilur es in t he measur ement
equipment . The fr equency cont ent s of t he da t a signals, in t er ms of
per iodogr a ms or spect r al est imat es, is a lso most r evealing t o st udy.
Mode l Se t s or Mode l St ruct ure s ar e families of models wit h adjust able
par amet er s. Parame t e r Es t i mati on a mount s t o finding t he best values
of t hese par amet er s. The Syst em Ident ificat ion pr oblem amount s t o finding
bot h a good model st r uct ur e and good numer ical va lues of it s par amet er s.
Parame t ri c Ide nt i fi cat i on Me thods ar e t echniques t o est imat e
par amet er s in given model st r uct ur es. Basically it is a mat t er of finding (by
numer ical sear ch) t hose numer ical values of t he pa r amet er s t hat give t he
best agr eement bet ween t he models (simulat ed or pr edict ed) out put and t he
measur ed one.
Nonparame tri c Ide nt i fi cati on Met hods ar e t echniques t o est imat e
model beha vior wit hout necessar ily using a given par amet r ized model set .
Typica l nonpar a met r ic met hods include Corre l at i on anal ys i s , which
est imat es a syst ems impulse r esponse, and Spe ct ral anal ys i s , which
est imat es a syst ems fr equency r esponse.
Mode l Val i dati on is t he pr ocess of gaining confidence in a model.
Essent ially t his is achieved by t wist ing and t ur ning t he model t o scr ut inize
all aspect s of it . Of par t icular impor t a nce is t he models abilit y t o r epr oduce
t he behavior of t he Validat ion Dat a set s. Thus it is impor t ant t o inspect t he
pr oper t ies of t he r esiduals fr om t he model when a pplied t o t he Validat ion
Dat a .
1-5
3. Basic Information About Dynamic Models
Syst em Ident ificat ion is about building Dynami c Mode l s. Some knowledge
about such models is t her efor e necessar y for successful use of t he t oolbox.The
t opic is t r ea t ed in sever al places in t he Chapt er and t her e is a wide r ange of
t ext books availa ble for int r oduct or y and in-dept h st udies. For basic use of t he
t oolbox, it is sufficient t o have quit e super ficial insight s about dynamic models.
This sect ion descr ibes such a basic level of knowledge.
The Signals
Models descr ibe r elat ionships bet ween measur ed signals. It is convenient t o
dist inguish bet ween i nput signals and out put signals. The out put s ar e t hen
par t ly det er mined by t he input s. Think for example of a n air pla ne wher e t he
input s would be t he differ ent cont r ol sur faces, ailer ons, elevat or s, and t he like,
while t he out put s would be t he air planes or ient at ion and posit ion. In most
ca ses, t he out put s ar e also affect ed by mor e signals t han t he mea sur ed input s.
In t he air plane example it would be wind gust s a nd t ur bulence effect s. Such
unmeasur ed input s will be called di s t urbance signa ls or noi se . If we denot e
input s, out put s, and dist ur bances by u, y, a nd e , r espect ively, t he r elat ionship
ca n be depict ed in t he following figur e.
Figure 1-1: Input Signals u, Output Signals y, and Disturbances e
All t hese signals ar e funct ions of t ime, and t he value of t he input at t ime t will
be denot ed by u(t). Oft en, in t he ident ifica t ion cont ext , only discr et e-t ime point s
ar e consider ed, since t he measur ement equipment t ypically r ecor ds t he signals
just at discr et e-t ime inst a nt s, oft en equally spr ead in t ime wit h a
s ampl i ng i nt e rval of T t ime unit s. The modeling pr oblem is t hen t o descr ibe
how t he t hr ee signals r elat e t o ea ch ot her .
y
e
u
1 Th e S y ste m Id e n ti f i c a ti o n Pr o b l e m
1-6
The Basic Dynamic Model
The basic r elat ionship is t he li ne ar di ffe re nce e quat i on. An example of such
an equat ion is t he following one.
y ( t ) - 1. 5 y ( t - T ) +0 . 7 y (t -2 T ) =0 . 9 u ( t - 2 T ) +0 . 5 u ( t - 3 T )+e(t ) (AR X)
Such a r elat ionship t ells us, for example, how t o comput e t he out put y(t) if t he
input is known and t he dist ur bance can be ignor ed:
y ( t ) =1 . 5 y (t -T )- 0 . 7 y (t -2 T ) +0 . 9 u ( t - 2 T ) +0 . 5 u ( t - 3 T )
The out put at t ime t is t hus comput ed as a linea r combina t ion of past out put s
and past input s. It follows, for example, t hat t he out put at t ime t depends on
t he input signal at many pr evious t ime inst ant s. This is what t he wor d
dynami c r efer s t o. The ident ificat ion pr oblem is t hen t o use measur ement s of
u and y t o figur e out
The coefficient s in t his equa t ion (i.e., -1.5, 0.7, et c.)
How many delayed out put s t o use in t he descr ipt ion (t wo in t he example:
y ( t - T ) a n d y ( t - 2 T ) )
The t i me de lay in t he syst em is (2T in t he exa mple: you see fr om t he second
equat ion t hat it t akes 2T t ime unit s befor e a change in u will affect y) and
How many delayed input s t o use (t wo in t he exa mple: u(t -2T) and u(t -3T))
Variants of Model Descriptions
The model given above is called an ARX mode l. Ther e ar e a handful of
va r iant s of t his model known a s Out put -Error (OE) models, ARMAX models,
FIR models, and Box-J enki ns (BJ ) models. These ar e descr ibed lat er on in
t he manual. At a ba sic level it is sufficient t o t hink of t hem a s var iant s of t he
ARX model a llowing also a char act er izat ion of t he pr oper t ies of t he
dist ur bances e.
Ge ne ral li ne ar mode ls can be descr ibed symbolically by
y =Gu +He
which says t hat t he measur ed out put y(t) is a sum of one cont r ibut ion t hat
comes fr om t he measur ed input u(t) and one cont r ibut ion t ha t comes fr om t he
noise He. The symbol G t hen denot es t he dynamic pr oper t ies of t he syst em, t hat
is, how t he out put is for med fr om t he input . For linea r syst ems it is called t he
t r ansfer funct ion fr om input t o out put . The symbol H r efer s t o t he noise
1-7
pr oper t ies, and is called t he noise model. It descr ibes how t he dist ur bances at
t he out put ar e for med fr om some st anda r dized noise sour ce e(t).
Stat e-s pac e mode l s ar e common r epr esent at ions of dyna mical models. They
descr ibe t he sa me t ype of linear differ ence r elat ionship bet ween t he input s and
t he out put s as in t he ARX model, but t hey ar e r ear r anged so t hat only one
delay is used in t he expr essions. To achieve t his, some ext r a va r iables, t he
s tat e vari able s , a r e int r oduced. They ar e not measur ed, but can be
r econst r uct ed fr om t he measur ed input -out put dat a. This is especia lly useful
when t her e ar e sever a l out put signals, i.e., when y(t ) is a vect or . Chapt er gives
mor e det a ils about t his. For basic use of t he t oolbox it is sufficient t o know t hat
t he orde r of t he st at e-spa ce model r ela t es t o t he number of delayed input s and
out put s used in t he cor r esponding linea r differ ence equat ion. The st at e-space
r epr esent at ion looks like
x ( t +1 ) =A x ( t ) +B u (t ) +Ke( t )
y ( t ) =Cx ( t ) +Du ( t ) +e( t )
Her e x(t ) is t he vect or of st at e var iables. The mat r ix K det er mines t he noise
pr oper t ies. Not ice t hat if K = 0, t hen t he noise sour ce e(t ) affect s only t he
out put , a nd no specific model of t he noise pr oper t ies is built . This cor r esponds
t o H = 1 in t he gener a l descr ipt ion a bove, and is usually r efer r ed t o a s a n
Output-Error model. Not ice also t hat D = 0 means t hat t her e is no dir ect
influence fr om u(t ) t o y(t ). Thus t he effect of t he input on t he out put all passes
via x(t ) and will t hus be delayed at least one sample. The fir st value of t he st at e
var iable vect or x(0) r eflect s t he init ial condit ions for t he syst em at t he
beginning of t he dat a r ecor d. When dealing wit h models in st at e-space for m, a
t ypical opt ion is whet her t o est imat e D, K, and x(0) or t o let t hem be zer o.
How to Interpret the Noise Source
In many cases of syst em ident ificat ion, t he effect s of t he noise on t he out put ar e
insignificant compar ed t o t hose of t he input . Wit h good signal-t o-noise r at ios
(SNR), it is less impor t ant t o have an accur at e noise model. Never t heless it is
impor t a nt t o under st and t he r ole of t he noise and t he noise sour ce e(t ), whet her
it appear s in t he ARX model or in t he gener al descr ipt ions given above.
Ther e ar e t hr ee aspect s of t he noise t hat should be st r essed:
under st anding whit e noise
int er pr et ing t he noise sour ce
using t he noise sour ce when wor king wit h t he model
1 Th e S y ste m Id e n ti f i c a ti o n Pr o b l e m
1-8
These aspect s ar e discussed one by one.
How can we under st and whit e noise? Fr om a for mal point of view, t he noise
sour ce e(t ) will nor mally be r egar ded as white noise. This means t hat it is
ent ir ely unpr edict able. In ot her wor ds, it is impossible t o guess t he va lue of e(t )
no mat t er how accur at ely we have measur ed past dat a up t o t ime t -1.
How can we int er pr et t he noise sour ce? The act ual noise cont r ibut ion t o t he
out put , H e(t ), has r ea l significance. It cont ains a ll t he influences on t he
measur ed y, known and unknown, t hat ar e not cont ained in t he input u. It
explains and capt ur es t he fact t ha t even if an exper iment is r epeat ed wit h t he
sa me input , t he out put signal will t ypica lly be somewhat differ ent . However ,
t he noise sour ce e(t) need not have a physical significance. In t he air pla ne
example ment ioned ear lier , t he noise effect s ar e wind gust s and t ur bulence.
Descr ibing t hese a s ar ising fr om a whit e noise sour ce via a t r ansfer funct ion H,
is just a convenient way of ca pt ur ing t heir char a ct er .
How can we deal wit h t he noise sour ce when using t he model? If t he model is
used just for simulat ion, i.e., t he r esponses t o var ious input s ar e t o be st udied,
t hen t he noise model plays no immediat e r ole. Since t he noise sour ce e(t) for
new dat a will be unknown, it is t aken as zer o in t he simula t ions, so as t o st udy
t he effect of t he input alone (a noise-fr ee simulat ion). Ma king anot her
simulat ion wit h e(t) being ar bit r ar y whit e noise will r eveal how r elia ble t he
r esult of t he simulat ion is, but it will not give a mor e a ccur a t e simulat ion r esult
for t he act ual syst ems r esponse.
The need and use of t he noise model can be summar ized as follows:
It is, in most cases, r equir ed t o obt a in a bet t er est imat e for t he dynamics, G.
It indicat es how r elia ble noise-fr ee simulat ions ar e.
It is r equir ed for r eliable pr edict ions and st ochast ic cont r ol design.
1-9
Terms to Characterize the Model Properties
The pr oper t ies of an input -out put r elat ionship like t he ARX model follow fr om
t he numer ical values of t he coefficient s, and t he number of delays used. This is
however a fair ly implicit way of t alking about t he model pr oper t ies. Inst ead a
number of differ ent t er ms ar e used in pr act ice:
Impulse Response
The impulse r esponse of a dynamical model is t he out put signal t hat r esult s
when t he input is an impulse, i.e., u(t ) is zer o for a ll values of t except t =0,
wher e u(0)=1. It can be comput ed as in t he equat ion following (ARX), by let t ing
t be equal t o 0, 1, 2, ... and t aking y(-T)=y(-2T)=0 and u(0)=1.
Step Response
The st ep r esponse is t he out put signal t hat r esult s fr om a st ep input , i.e., u(t )
is zer o for negat ive values of t a nd equal t o one for posit ive va lues of t . The
impulse and st ep r esponses t oget her ar e called t he models t rans i e nt
re s pons e .
Frequency Response
The fr equency r esponse of a linear dynamic model descr ibes how t he model
r eact s t o sinusoidal input s. If we let t he input u(t ) be a sinusoid of a cer t ain
fr equency, t hen t he out put y(t) will also be a sinusoid of t his fr equency. The
amplit ude and t he phase (r elat ive t o t he input ) will however be differ ent . This
fr equency r esponse is most oft en depict ed by t wo plot s; one t hat shows t he
amplit ude change a s a funct ion of t he sinusoids fr equency and one t hat shows
t he phase shift as funct ion of fr equency. This is known as a Bode plot .
Zeros and Poles
The zer os and t he poles ar e equivalent ways of descr ibing t he coefficient s of a
linea r differ ence equat ion like t he ARX model. The poles r ela t e t o t he
out put -side and t he zer os r ela t e t o t he input -side of t his equat ion. The
number of poles (zer os) is equal t o number of sampling int er vals bet ween t he
most and least delayed out put (input ). In t he ARX example in t he beginning of
t his sect ion, t her e ar e consequent ly t wo poles and one zer o.
1 Th e S y ste m Id e n ti f i c a ti o n Pr o b l e m
1-10
4. The Basic Steps of System Identification
The Syst em Ident ificat ion pr oblem is t o est imat e a model of a syst em based on
obser ved input -out put dat a. Sever al wa ys t o descr ibe a syst em and t o est ima t e
such descr ipt ions exist . This sect ion gives a br ief account of t he most impor t ant
appr oa ches.
The pr ocedur e t o det er mine a model of a dynamical syst em fr om obser ved
input -out put dat a involves t hr ee basic ingr edient s:
The input -out put dat a
A set of candidat e models (t he model st r uct ur e)
A cr it er ion t o select a par t icular model in t he set , based on t he infor mat ion
in t he dat a (t he ident ificat ion met hod)
The ident ificat ion pr ocess amount s t o r epea t edly select ing a model st r uct ur e,
comput ing t he best model in t he st r uct ur e, and eva luat ing t his models
pr oper t ies t o see if t hey ar e sat isfact or y. The cycle can be it emized as follows:
1 Design a n exper iment and collect input -out put da t a fr om t he pr ocess t o be
ident ified.
2 Examine t he dat a. Polish it so as t o r emove t r ends and out lier s, select useful
por t ions of t he or iginal dat a, and apply filt er ing t o enhance impor t ant
fr equency r a nges.
3 Select and define a model st r uct ur e (a set of candidat e syst em descr ipt ions)
wit hin which a model is t o be found.
4 Comput e t he best model in t he model st r uct ur e accor ding t o t he
input -out put dat a and a given cr it er ion of fit .
5 Examine t he obt ained models pr oper t ies
6 If t he model is good enough, t hen st op; ot her wise go back t o St ep 3 t o t r y
a not her model set . Possibly also t r y ot her est imat ion met hods (St ep 4) or
wor k fur t her on t he input -out put dat a (St eps 1 and 2).
The Syst em Ident ificat ion Toolbox offer s sever a l funct ions for each of t hese
st eps.
1-11
For St ep 2 t her e a r e r out ines t o plot dat a, filt er dat a, and r emove t r ends in
dat a.
For St ep 3 t he Syst em Ident ificat ion Toolbox offer s a var iet y of nonpar a met r ic
models, a s well as all t he most common black-box input -out put and st at e-spa ce
st r uct ur es, and also gener al t ailor -made linear st a t e-space models in discr et e
and cont inuous t ime.
For St ep 4 gener al pr edict ion er r or (maximum likelihood) met hods as well as
inst r ument a l var iable met hods and sub-space met hods a r e offer ed for
par a met r ic models, while basic cor r elat ion and spect r al a nalysis met hods ar e
used for nonpar amet r ic model st r uct ur es.
To examine models in St ep 5, many funct ions a llow t he comput at ion and
pr esent at ion of fr equency funct ions and poles and zer os, as well as simula t ion
and pr edict ion using t he model. Funct ions ar e also included for
t r ansfor mat ions bet ween cont inuous-t ime and discr et e-t ime model
descr ipt ions and t o for mat s t ha t ar e used in ot her MATLAB t oolboxes, like t he
Cont r ol Syst em Toolbox a nd t he Signal Pr ocessing Toolbox.
1 Th e S y ste m Id e n ti f i c a ti o n Pr o b l e m
1-12
5. A Startup Identification Procedure
Ther e ar e no st a ndar d and secur e r out es t o good models in Syst em
Ident ificat ion. Given t he number of possibilit ies, it is easy t o get confused about
what t o do, what model st r uct ur es t o t est , and so on. This sect ion descr ibes one
r out e t hat oft en wor ks well, but t her e a r e no guar ant ees. The st eps r efer t o
funct ions wit hin t he GUI, but you ca6n also go t hr ough t hem in command
mode. See Chapt er for t he basic commands.
Step 1 Looking at the Data
Plot t he dat a. Look at t hem ca r efully. Tr y t o see t he dynamics wit h your own
eyes. Can you see t he effect s in t he out put s of t he changes in t he input ? Can
you see nonlinear effect s, like differ ent r esponses at differ ent levels, or
differ ent r esponses t o a st ep up and a st ep down? Ar e t her e por t ions of t he dat a
t hat appea r t o be messy or car r y no infor mat ion. Use t his insight t o select
por t ions of t he dat a for est imat ion and valida t ion pur poses.
Do physical levels play a r ole in your model? If not , det r end t he dat a by
r emoving t heir mean values. The models will t hen descr ibe how changes in t he
input give changes in out put , but not explain t he act ual levels of t he signals.
This is t he nor mal sit uat ion.
The default sit uat ion, wit h good dat a, is t hat you det r end by r emoving means,
and t hen select t he fir st half or so of t he dat a r ecor d for est ima t ion pur poses,
and use t he r emaining dat a for valida t ion. This is what happens when you
apply Qui cks tart under t he pop-up menu Pre proce s s in t he main i de nt
window.
Step 2 Getting a Feel for the Difficulties
Apply Qui ckst art under pop-up menu Es t i mat e in t he main i de nt window.
This will comput e and displa y t he spect r al analysis est ima t e and t he
cor r ela t ion analysis est imat e, as well as a four t h or der ARX model wit h a delay
1-13
est imat ed fr om t he cor r elat ion analysis and a default or der st at e-spa ce model
comput ed by n4sid. This gives t hr ee plot s. Look at t he agr eement bet ween t he
Spect r al Analysis est imat e and t he ARX and st at e-space models fr equency
funct ions
Cor r elat ion Analysis est ima t e and t he ARX a nd st at e-space models
t r ansient r esponses
Measur ed Va lidat ion Da t a out put and t he ARX and st at e-space models
simula t ed out put s
If t hese a gr eement s a r e r easona ble, t he pr oblem is not so difficult , and a
r elat ively simple linea r model will do a good job. Some fine t uning of model
or der s, and noise models have t o be made and you can pr oceed t o St ep 4.
Ot her wise go t o St ep 3.
Step 3 Ex amining the Difficulties
Ther e may be sever al r easons why t he compar isons in St ep 2 did not look good.
This sect ion discusses t he most common ones, and how t hey can be ha ndled:
Model Unstable
The ARX or st at e-space model ma y t ur n out t o be unst able, but could st ill be
useful for cont r ol pur poses. Change t o a 5- or 10-st ep ahea d pr edict ion inst ead
of simulat ion in t he Mode l Out put Vi e w.
Feedback in Data
If t her e is feedback fr om t he out put t o t he input , due t o some r egulat or , t hen
t he spect r a l and cor r ela t ions analysis est imat es ar e not r elia ble. Discr epancies
bet ween t hese est imat es and t he ARX a nd st at e-spa ce models can t her efor e be
disr egar ded in t his case. In t he Mode l Re s i duals Vi e w of t he par amet r ic
models, feedback in dat a can also be visible a s cor r elat ion bet ween r esiduals
and input for negat ive la gs.
Noise Model
If t he st at e-space model is clear ly bet t er t ha n t he ARX model at r epr oducing
t he measur ed out put , t his is an indica t ion t ha t t he dist ur bances have a
subst ant ial influence, and it will be necessar y t o model t hem car efully.
1 Th e S y ste m Id e n ti f i c a ti o n Pr o b l e m
1-14
Model Order
If a four t h or der model does not give a good Mode l Out put plot , t r y eight h
or der . If t he fit clea r ly impr oves, it follows t hat higher or der models will be
r equir ed, but t hat linear models could be sufficient .
Additional Inputs
If t he Mode l Out put fit has not significant ly impr oved by t he t est s so far ,
t hink over t he physics of t he applicat ion. Ar e t her e mor e signa ls t hat have
been, or could be, measur ed t hat might influence t he out put ? If so, include
t hese among t he input s and t r y a gain a four t h or der ARX model fr om all t he
input s. (Not e t hat t he input s need not at all be cont r ol signals, a nyt hing
measur a ble, including dist ur ba nces, should be t r ea t ed as input s).
Nonlinear Effects
If t he fit bet ween measur ed and model out put is st ill ba d, consider t he physics
of t he applicat ion. Ar e t her e nonlinear effect s in t he syst em? In t ha t case, for m
t he nonlinear it ies fr om t he measur ed da t a. This could be a s simple as for ming
t he pr oduct of volt age and cur r ent measur ement s, if you r ealize t hat it is t he
elect r ical power t hat is t he dr iving st imulus in, say, a heat ing pr ocess, and
t emper a t ur e is t he out put . This is of cour se a pplicat ion dependent . It does not
t ake ver y much wor k, however , t o for m a number of a ddit ional input s by
r ea sonable nonlinear t r ansfor mat ions of t he measur ed ones, and just t est if
inclusion of t hem impr oves t he fit .
Still Problems?
If none of t hese t est s leads t o a model t ha t is able t o r epr oduce t he Validat ion
Dat a r easonably well, t he conclusion might be t hat a sufficient ly good model
cannot be pr oduced fr om t he dat a. Ther e may be many r easons for t his. The
most impor t ant one is t hat t he dat a simply do not cont ain sufficient
infor mat ion, e.g., due t o bad signal t o noise r at ios, lar ge and nonst at ionar y
dist ur bances, var ying syst em pr oper t ies, et c. The r eason may also be t hat t he
syst em has some quit e complicat ed nonlinear it ies, which cannot be r ealized on
physical gr ounds. In such cases, nonlinear , black box models could be a
solut ion. Among t he most used models of t his char act er ar e t he Ar t ificial
Neur al Net wor ks (ANN).
Ot her wise, use t he insight s of which input s t o use and which model or der s t o
expect and pr oceed t o St ep 4.
1-15
Step 4 Fine Tuning Orders and Noise Structures
For r eal dat a t her e is no such t hing as a cor r ect model st r uct ur e. However ,
differ ent st r uct ur es can give quit e differ ent model qualit y. The only way t o find
t his out is t o t r y out a number of differ ent st r uct ur es and compar e t he
pr oper t ies of t he obt ained models. Ther e ar e a few t hings t o look for in t hese
compar isons:
Fit Betw een Simula ted a nd Measured Output
Keep t he Model Out put Vi e w open and look at t he fit bet ween t he models
simulat ed out put and t he measur ed one for t he Valida t ion Dat a. For mally, you
could pick t hat model, for which t his number is t he lowest . In pr a ct ice, it is
bet t er t o be mor e pr agmat ic, a nd also t a ke int o account t he model complexit y,
and whet her t he impor t ant feat ur es of t he out put r esponse ar e capt ur ed.
Residual Ana lysis Test
You should r equir e of a good model, t hat t he cr oss cor r elat ion funct ion bet ween
r esiduals and input does not go significant ly out side t he confidence r egion. A
clear peak at lag k shows t hat t he effect fr om input u(t -k ) on y(t) is not pr oper ly
descr ibed. A r ule of t humb is t hat a slowly var ying cr oss cor r elat ion funct ion
out side t he confidence r egion is an indicat ion of t oo few poles, while shar per
peaks indica t e t oo few zer os or wr ong delays.
Pole Zero Ca ncellations
If t he pole-zer o plot (including confidence int er va ls) indica t es pole-zer o
ca ncellat ions in t he dynamics, t his suggest s t hat lower or der models ca n be
used. In pa r t icula r , if it t ur ns out t hat t he or der s of ARX models ha ve t o be
incr eased t o get a good fit , but t hat pole-zer o cancellat ions a r e indicat ed, t hen
t he ext r a poles a r e just int r oduced t o descr ibe t he noise. Then t r y ARMAX, OE,
or BJ model st r uct ur es wit h an A or F polynomial of an or der equal t o t hat of
t he number of nonca nceled poles.
What Model Structures Should be Tested?
Well, you can spend any amount of t ime t o check out a ver y lar ge number of
st r uct ur es. It oft en t akes just a few seconds t o comput e and eva luat e a model
in a cer t ain st r uct ur e, so t ha t you should have a gener ous at t it ude t o t he
t est ing. However , exper ience shows t hat when t he basic pr oper t ies of t he
syst ems behavior have been picked up, it is not much use t o fine t une or der s
in absur dum just t o pr ess t he fit by fr act ions of per cent s.
1 Th e S y ste m Id e n ti f i c a ti o n Pr o b l e m
1-16
Many ARX mode l s: Ther e is a ver y cheap way of t est ing ma ny ARX st r uct ur es
simult aneously. Ent er in t he Orde rs t ext field many combinat ions of or der s,
using t he colon (:) not a t ion. When you select Est i mat e , models for all
combinat ions (ea sily sever al hundr eds) ar e comput ed and t heir (pr edict ion
er r or ) fit t o Valida t ion Dat a is shown in a special plot . By clicking in t his plot
t he best models wit h a ny chosen number of par amet er s will be inser t ed int o t he
Model Boar d, and evaluat ed as desir ed.
Many St at e -s pace mode l s : A similar feat ur e is also available for bla ck-box
st at e-space models, est imat ed using n4sid. When a good or der has been found,
t r y t he PEM est imat ion met hod, which oft en impr oves on t he accur acy.
ARMAX, OE, and BJ model s : Once you ha ve a feel for suit able delays and
dynamics or der s, if is oft en useful t o t r y out ARMAX, OE, and/or BJ wit h t hese
or der s and t est some differ ent or der s for t he noise t r ansfer funct ions (C and D).
Especially for poor ly damped syst ems, t he OE st r uct ur e is suit able.
Ther e is a quit e ext ensive lit er at ur e on or der and st r uct ur e select ion, and
anyone who would like t o know mor e should consult t he r efer ences.
Multivariable Systems
Syst ems wit h many input signals and/or many out put signals ar e called
mult ivariable. Such syst ems ar e oft en mor e challenging t o model. In par t icular
syst ems wit h sever a l out put s could be difficult . A basic r eason for t he
difficult ies is t hat t he couplings bet ween sever al input s and out put s lead t o
mor e complex models. The st r uct ur es involved ar e r icher and mor e par amet er s
will be r equir ed t o obt ain a good fit .
Ava ilable Models
The Syst em Ident ificat ion Toolbox as well as t he GUI ha ndles gener al, linear
mult iva r iable models. All ear lier ment ioned models ar e suppor t ed in t he single
out put , mult iple input ca se. For mult iple out put s ARX models and st a t e-space
models ar e cover ed. Mult i-out put ARMAX and OE models a r e cover ed via
st at e-space r epr esent at ions: ARMAX cor r esponds t o est imat ing t he K-mat r ix,
while OE cor r esponds t o fixing K t o zer o. (These ar e pop-up opt ions in t he GUI
model or der edit or .)
Gener ally spea king, it is pr efer able t o wor k wit h st at e-space models in t he
mult iva r iable case, since t he model st r uct ur e complexit y is ea sier t o deal wit h.
It is essent ially just a mat t er of choosing t he model or der .
1-17
Working w ith Subsets of the Input Output Channels
In t he pr ocess of ident ifying good models of a syst em, it is oft en useful t o select
subset s of t he input and out put channels. Par t ial models of t he syst ems
behavior will t hen be const r uct ed. It might not , for example, be clear if all
measur ed input s have a significant influence on t he out put s. Tha t is most
easily t est ed by r emoving a n input channel fr om t he dat a, building a model for
how t he out put (s) depends on t he r emaining input channels, and checking if
t her e is a significant det er ior at ion in t he model out put s fit t o t he measur ed
one. See also t he discussion under St ep 3 above.
Gener ally speaking, t he fit get s bet t er when mor e input s ar e included and
wor se when mor e out put s ar e included. To under st and t he lat t er fa ct , you
should r ealize t hat a model t hat has t o explain t he behavior of sever al out put s
has a t ougher job t han one t hat just must account for a single out put . If you
have difficult ies obt a ining good models for a mult i-out put syst em, it might be
wise t o model one out put at a t ime, t o find out which ar e t he difficult ones t o
handle.
Models t hat ar e just t o be used for simulat ions could ver y well be built up fr om
single-out put models, for one out put at a t ime. However , models for pr edict ion
and cont r ol will be a ble t o pr oduce bet t er r esult s if const r uct ed for all out put s
simult aneously. This follows fr om t he fact t hat knowing t he set of all pr evious
out put channels gives a bet t er basis for pr edict ion, t han just knowing t he past
out put s in one channel.
Some Practical Advice
The GUI is par t icular ly suit ed for dealing wit h mult iva r iable syst ems since it
will do useful bookkeeping for you, handling differ ent cha nnels. You could
follow t he st eps of t his agenda:
Impor t da t a a nd cr eat e a dat a set wit h a ll input and out put channels of
int er est . Do t he necessar y pr epr ocessing of t his set in t er ms of det r ending,
pr efilt er ing, et c., and t hen select a Validat ion Da t a set wit h all channels.
Then select a Wor king Dat a set wit h all channels, and est imat e st at e-space
models of differ ent or der s using n4sid for t hese dat a. Examine t he r esult ing
model pr imar ily using t he Mode l Out put view.
If it is difficult t o get a good fit in all out put channels or you would like t o
invest igat e how impor t ant t he differ ent input channels ar e, const r uct new
da t a set s using subset s of t he or igina l input /out put channels. Use t he pop-up
menu Pre proce s s > Sel e ct Channe l s for t his. Dont change t he Va lidat ion
1 Th e S y ste m Id e n ti f i c a ti o n Pr o b l e m
1-18
Dat a . The GUI will keep t r ack of t he input and out put channel number s. It
will do t he r ight t hing when evaluat ing t he channel-r est r ict ed models
using t he Valida t ion Dat a . It might also be appr opr iat e t o see if
impr ovement s in t he fit ar e obt ained for var ious model t ypes, built for one
out put at a t ime.
If you decide for a mult i-out put model, it is oft en easiest t o use st at e-space
models. Use n4sid as a pr imar y t ool and t r y out pem when a good or der has
been found. Not e t hat n4sid does not pr ovide confidence int er vals for t he
model views.
Re a d i n g M o r e A b o u t Sy ste m Id e n ti f i c a ti o n
1-19
Reading More About System Identification
Ther e is subst ant ial lit er at ur e on Syst em Ident ificat ion. The following
t ext book deals wit h ident ificat ion met hods fr om a similar per spect ive as t his
t oolbox, and a lso descr ibes met hods for physical modeling.
Ljung L. a nd T. Glad. Modeling of Dynamic Systems, Pr ent ice Hall, Englewood
Cliffs, N.J . 1994.
For mor e det ails a bout t he algor it hms a nd t heor ies of ident ifica t ion:
Ljung L.. System Identification - Theory for the User, Pr ent ice Ha ll, Englewood
Cliffs, N.J . 1987.
Sder st r m T. and P. St oica. System Identification, Pr ent ice Hall Int er nat ional,
London. 1989.
For mor e about syst em and signa ls:
Oppenheim J . a nd A.S. Willsky. Signals and Systems, Pr ent ice Hall, Englewood
Cliffs, N.J . 1985.
The following t ext book deals wit h t he under lying numer ica l t echniques for
par a met er est imat ion.
Dennis, J .E. J r . and R.B. Schna bel. Numerical Methods for Unconstrained
Optimization and Nonlinear Equations, Pr ent ice Hall, Englewood Cliffs, N.J .
1983.
1 Th e S y ste m Id e n ti f i c a ti o n Pr o b l e m
1-20

2
The Gr aphical User
Int er face
The Bi g Pi ct ure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Handl i ng Dat a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7
Es ti mat i ng Mode l s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-14
Exami ni ng Mode l s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-27
Some Furthe r GUI Topi cs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-34
2 Th e G r a p h i c a l U se r In te rf a c e
2-2
1. The Big Picture
The Syst em Ident ificat ion Toolbox pr ovides a gr aphical user int er fa ce (GUI) .
The GUI cover s most of t he t oolboxs funct ions and gives ea sy access t o all
va r iables t hat ar e cr eat ed dur ing a session. It is st ar t ed by t yping
ident
in t he MATLAB command window.
Figure 2-1: The Main ident Information Window
The Model and Data Boards
Syst em Ident ificat ion is about dat a and models and cr eat ing models fr om dat a .
The main infor mat ion and communicat ion window i de nt, is t her efor e
domina t ed by t wo t a bles:
A t able over a vaila ble dat a set s, each r epr esent ed by an icon.
A t able over cr eat ed models, each r epr esent ed by an icon.
2-3
These t a bles will be r efer r ed t o as t he Model Boar d and t he Dat a Boar d in
t his cha pt er . You ent er dat a set s int o t he Da t a Boa r d by
Opening ea r lier sa ved sessions.
Impor t ing t hem fr om t he MATLAB wor kspace.
Cr eat ing t hem by det r ending, filt er ing, select ing subset s, et c., of anot her
da t a set in t he Dat a Boar d.
Impor t s ar e handled under t he pop-up menu Dat a while cr eat ion of new dat a
set s is handled under t he pop-up menu Pre proce s s . Handling Dat a on pa ge
2-7 dea ls wit h t his in mor e det ail.
The models ar e ent er ed int o t he summar y boar d by
Opening ea r lier sa ved sessions.
Impor t ing t hem fr om t he MATLAB wor kspace.
Est imat ing t hem fr om dat a.
Impor t s ar e handled under t he pop-up menu Mode l s, while all t he differ ent
est imat ion schemes ar e r eached under t he pop-up menu Es t i mat e . Mor e about
t his in Est imat ing Models on page 2-14.
The Dat a and Model Boar ds ca n be r ea r r anged by dr agging and dr opping.
Mor e boar ds open aut omat ica lly when necessar y or when asked for (under
menu Opti ons ).
The Working Data
All dat a set s and models ar e cr ea t ed fr om t he Wor king Dat a set . This is t he
dat a t hat is given in t he cent er of t he i de nt window. To change t he Wor king
Dat a set dr ag and dr op any dat a set fr om t he Dat a Boar d on t he Wor king Dat a
icon.
The View s
Below t he Dat a and Model Boar ds ar e but t ons for differ ent views. These
cont r ol what aspect s of t he dat a set s and models you would like t o examine, and
ar e descr ibed in mor e det ail in Handling Dat a on page 2-7 a nd in Examining
Models on page 2-27. To select a dat a set or a model, so t hat it s pr oper t ies ar e
displayed, click on it s icon. A select ed object is mar ked by a t hicker line in t he
icon. To deselect , click aga in. An ar bit r ar y number of dat a/model object s can be
examined simult aneously. To have mor e infor mat ion about an object ,
double-click on it s icon.
2 Th e G r a p h i c a l U se r In te rf a c e
2-4
The Validation Data
The t wo model views Mode l Out put and Mode l Re s i dual s illust r at e model
pr oper t ies when applied t o t he Va lidat ion Da t a set . This is t he set mar ked in
t he box below t hese t wo views. To cha nge t he Validat ion Dat a, dr ag and dr op
any dat a set fr om t he Dat a Boar d on t he Validat ion Dat a icon.
It is good and common pr act ice in ident ificat ion t o evaluat e an est imat ed
models pr oper t ies using a fr esh da t a set , t hat is, one t ha t was not used for
t he est imat ion. It is t hus good advice t o let t he Validat ion Dat a be differ ent
fr om t he Wor king Dat a, but t hey should of cour se be compat ible wit h t hese.
The Work Flow
You st ar t by impor t ing dat a (under pop-up menu Dat a); you exa mine t he dat a
set using t he Dat a Vi e ws . You pr obably r emove t he means fr om t he dat a and
select subset s of dat a for est imat ion and va lidat ion pur poses using t he it ems in
t he pop-up menu Pre proc es s . You t hen cont inue t o est imat e models, using t he
possibilit ies under t he pop-up menu Es t i mate , per haps fir st doing a
quickst ar t . You examine t he obt ained models wit h r espect t o your favor it e
aspect s using t he differ ent Mode l Vi e ws . The basic idea is t ha t any checked
view shows t he pr oper t ies of all select ed models at a ny t ime. This funct ion is
live so models and views can be checked in and out at will in an online
fashion. You select /deselect a model by clicking on it s icon.
Inspir ed by t he infor mat ion you ga in fr om t he plot s, you cont inue t o t r y out
differ ent model st r uct ur es (model or der s) unt il you find a model you ar e
sa t isfied wit h.
Management Aspects
Di ary: It is ea sy t o for get wha t you have been doing. By double-clicking on a
dat a /model icon, a complet e diar y will be given of how t his object was cr eat ed,
along wit h ot her key infor ma t ion. At t his point you can a lso add comment s a nd
change t he name of t he object and it s color .
Layout : To have a good over view of t he cr eat ed models and dat a set s, it is good
pr act ice t o t r y r ear r anging t he icons by dr agging and dr opping. In t his wa y
models cor r esponding t o a par t icular da t a set ca n be gr ouped t oget her , et c. You
can also open new boar ds (Opt i ons menu Ext ra mode l /data boards ) t o
fur t her r ear r ange t he icons. These can be dr agged acr oss t he scr een bet ween
differ ent windows. The ext r a boar ds ar e also equipped wit h not epads for your
comment s.
2-5
Se ss i ons: The Model and Dat a Boar ds wit h all models a nd dat a set s t oget her
wit h t heir diar ies can be saved (under menu it em Fi l e ) at any point , and
r eloaded lat er . This is t he count er par t of save/load wor kspa ce in t he
command-dr iven MATLAB. The four most r ecent sessions ar e list ed under Fi l e
for immediat e open.
Cl e anli ne s s : The boar ds will hold an ar bit r ar y number of models and dat a
set s (by cr eat ing clones of t he boar d when necessa r y). It is however advisable
t o clear (delet e) models and dat a set s t ha t no longer ar e of int er est . Do t hat by
dr agging t he object t o t he Tras h Can. (Double-clicking on t he t r ash can will
open it up, and it s cont ent s can be r et r ieved.)
Wi ndow Cult ure : Dialog and plot windows ar e best managed by t he GUIs
close funct ion (submenu it em under Fi le menu, or select Cl os e , or check/
uncheck t he cor r esponding View box). They may also bequit t ed by t he specific
window syst ems quit /close funct ion. This does no ha r m, but quit will not be
pr oper ly acknowledged by t he GUI, a nd t he window will have t o be r e-cr eat ed
next t ime it is t o be used.
It is gener ally not suit able t o iconify t he windows t he GUIs handling and
window management syst em is usually a bet t er alt er nat ive.
Workspace Variables
The models and da t a set s cr eat ed wit hin t he GUI ar e nor mally not availa ble in
t he MATLAB wor kspa ce. Indeed, t he wor kspace is not at all lit t er ed wit h
var iables dur ing t he sessions wit h t he GUI. The var ia bles can however be
expor t ed at any t ime t o t he wor kspace, by dr a gging and dr opping t he object
icon on t he To Works pac e box. They will t hen car r y t he name in t he
wor kspa ce t ha t mar ked t he object icon at t he t ime of expor t . You can wor k wit h
t he var iables in t he wor kspace, using any MATLAB commands, and t hen
per haps impor t modified ver sions back int o t he GUI. Not e t hat models have a
specific int er nal st r uct ur e a nd should be dealt wit h using t he MATLAB
commands present, th2ff, th2ss, et c. See Model Conver sions on page 4-5 of
t he "Command Refer ence" chapt er .
The GUIs names of dat a set s a nd models ar e suggest ed by default pr ocedur es.
Nor mally, you ca n ent er a ny ot her na me of your choice at t he t ime of cr eat ion
of t he var iable. Names can be cha nged (aft er double-clicking on t he icon) at any
t ime. Unlike t he wor kspace sit uat ion, t wo GUI object s can car r y t he same
name (i.e., t he sa me st r ing in t heir icons).
2 Th e G r a p h i c a l U se r In te rf a c e
2-6
The GUI pr oduces a handful of global wor kspace var ia bles for management
pur poses. They all st ar t wit h t he pr efix XID.
NOTE: Do not clear all or clear global dur ing a GUI session! This would
mean t hat you lose cont r ol over t he object s t hat you have cr eat ed. The same
disa st er occur s if you do clg or quit t he main i de nt window. It is however
sa fe t o clear (wit hout adding all or global) t he wor kspace at any t ime.
Help Texts
The GUI cont a ins some 100 help t ext s t hat ar e accessible in a nest ed fashion,
when r equir ed. The main i de nt window cont a ins gener al help t opics under t he
He l p menu. This is a lso t he case for t he var ious plot windows. In addit ion,
ever y dialog box has a He l p push but t on for cur r ent help and advice.
2-7
2. Handling Data
Data Representation
In t he Syst em Ident ificat ion Toolbox (SITB), signals a nd obser ved dat a ar e
r epr esent ed a s column vect or s, e.g.,
The ent r y in r ow number k, i.e., u(k), will t hen be t he signals value at sampling
inst ant number k. It is gener ally assumed in t he t oolbox t hat da t a ar e sampled
at equidist ant sampling t imes, and t he sampling int er va l T is supplied a s a
specific ar gument .
We gener ally denot e t he input t o a syst em by t he let t er u a nd t he out put by y.
If t he syst em has sever al input channels, t he input dat a is r epr esent ed by a
mat r ix, wher e t he columns ar e t he input signals in t he differ ent channels:
The same holds for syst ems wit h sever al out put channels.
The obser ved input -out put dat a r ecor d is r epr esent ed in t he SITB by a mat r ix,
wher e t he fir st column(s) is t he out put , followed by t he input column(s):
z = [y u];
When you wor k wit h t he GUI, you only need t o t hink of t hese r epr esent at ion
issues when you inser t t he dat a set int o t he summar y boar d. The GUI will t hen
handle t he dat a r epr esent at ion aut omat ically.
u
u 1 ( )
u 2 ( )

u N ( )
=
u u1 u2 um =
2 Th e G r a p h i c a l U se r In te rf a c e
2-8
Getting Data into the GUI
The infor mat ion about a dat a set t ha t should be supplied t o t he GUI is as
follows:
1 The input and out put signals
2 The na me you give t o t he dat a set
3 The st ar t ing t ime
4 The sampling int er va l
5 Dat a not es
NOTE: It ems 3 and 4 ar e used only t o ensur e cor r ect t ime and fr equency sca les
when you plot dat a and model char act er ist ics.
These a r e not es for your own infor mat ion and bookkeeping t hat will follow t he
dat a and all models cr eat ed fr om t hem.
2-9
As you select t he pop-up menu Dat a and choose t he it em Import..., a dialog
box will open, wher e you can ent er t he infor mat ion it ems 1 - 5, just list ed. This
box has six fields for you t o fill in:
Figure 2-2: The Dialog for Importing Data into the GUI
Input and Output: Ent er t he var iable names of t he input a nd out put
r espect ively. These should be var iables in your MATLAB wor kspa ce, so you
may ha ve t o load some disk files fir st .
Act ually, you can ent er a ny MATLAB expr essions in t hese fields, and t hey will
be evalua t ed t o comput e t he input and t he out put befor e inser t ing t he dat a int o
t he GUI.
Dat a name : Ent er t he name of t he dat a set t o be used by t he GUI. This name
ca n be changed la t er on.
Start i ng ti me and Sampl i ng i nt e rval: Fill t hese out for cor r ect t ime and
fr equency scales in t he plot s.
Not e t hat you can ent er a ny t ext you want t o accompany t he dat a for
bookkeeping pur poses.
2 Th e G r a p h i c a l U se r In te rf a c e
2-10
Fina lly, select Import t o inser t t he dat a int o t he GUI. When no mor e da t a set s
ar e t o be inser t ed, select Cl os e t o close t he dialog box. Re s e t will empt y all t he
fields of t he box.
Taking a Look at the Data
The fir st t hing t o do aft er having inser t ed t he dat a set int o t he Dat a Boar d is
t o examine it . By checking t he Dat a Vi e w it em Plot Dat a, a plot of t he input
and out put signals will be shown for t he dat a set s t hat ar e select ed. You select /
deselect t he dat a set s by clicking on t hem. For mult ivar iable dat a, t he differ ent
combinat ions of input and out put signals ar e chosen under menu it em
Channel in t he plot window. Using t he zoom funct ion (dr a wing r ect angles wit h
t he left mouse but t on down) differ ent por t ions of t he dat a can be examined in
mor e det ail.
To exa mine t he fr equency cont ent s of t he dat a, check t he Dat a Vi e w it em
Dat a Spe ct ra. The funct ion is a nalogous t o Plot Dat a, but t he signals spect r a
ar e shown inst ead. By default t he per iodogr a ms of t he dat a ar e shown, i.e., t he
absolut e squar e of t he Four ier t r ansfor ms of t he da t a. The plot can be changed
t o any chosen fr equency r ange a nd a number of differ ent ways of est imat ing
spect r a, by t he Opti ons menu it em in t he spect r a window.
The pur pose of exa mining t he dat a in t hese wa ys is t o find out if t her e ar e
por t ions of t he dat a t hat ar e not suit able for ident ifica t ion, if t he infor mat ion
cont ent s of t he da t a is suit able in t he int er est ing fr equency r egions, and if t he
dat a have t o be pr epr ocessed in some way, befor e using t hem for est imat ion.
Preprocessing Data
Detrending
Det r ending t he dat a involves r emoving t he mean values or linear t r ends fr om
t he signa ls (t he means and t he linea r t r ends ar e t hen comput ed and r emoved
fr om each signal individually). This funct ion is accessed under t he pop-up
menu Pre proc es s , by select ing it em Re move Me ans or Re move Tre nds .
Mor e advanced det r ending, such as r emoving piecewise linear t r ends or
seasonal var iat ions cannot be accessed wit hin t he GUI. It is gener a lly
r ecommended t hat you always r emove at least t he mean values of t he dat a
befor e t he est imat ion phase, unless physical insight involving act ual signal
levels is built int o t he models.
2-11
Selecting Data Ranges
It is oft en t he case t ha t t he whole dat a r ecor d is not suit able for ident ificat ion,
due t o var ious undesir ed feat ur es (missing or bad dat a , out bur st s of
dist ur ba nces, level cha nges et c.), so t ha t only por t ions of t he dat a can be used.
In any case, it is advisable t o select one por t ion of t he measur ed dat a for
est imat ion pur poses and anot her por t ion for validat ion pur poses. The pop-up
menu it em Pre proce ss > Se le ct Range ... opens a dia log box, which facilit at es
t he select ion of differ ent dat a por t ions, by t yping in t he r anges, or mar king
t hem by dr a wing r ect angles wit h t he mouse but t on down.
For mult ivar iable dat a it is oft en adva nt ageous t o st ar t by wor king wit h just
some of t he input a nd out put signals. The menu it em Pre proce s s > Se l e ct
Channe l s ... allows you t o select subset s of t he input s and out put s. This is done
in such a wa y t hat t he input /out put number ing r emains consist ent when you
evaluat e dat a and model pr oper t ies, for models cover ing differ ent subset s of t he
dat a.
Prefiltering
By filt er ing t he input and out put signa ls t hr ough a linea r filt er (t he same filt er
for all signa ls) you can focus t he models fit t o t he syst em t o specific fr equency
r a nges. This is done by select ing t he pop-up menu it em Pre proce s s > Fi l te r...
in t he main window. The dialog is quit e analogous t o t hat of select ing da t a
r a nges in t he t ime domain. You mar k wit h a r ect angle in t he spect r al plot s t he
int ended passband or st op ba nd of t he filt er , you select a but t on t o check if t he
filt er ing ha s t he desir ed effect , and t hen you inser t t he filt er ed dat a int o t he
GUIs Dat a Boar d.
Pr efilt er ing is a good way of r emoving high fr equency noise in t he dat a, and
also a good alt er nat ive t o det r ending (by cut t ing out low fr equencies fr om t he
pass band). Depending on t he int ended model use, you ca n a lso make sur e t hat
t he model concent r a t es on t he impor t ant fr equency r anges. For a model t hat
will be used for cont r ol design, for example, t he fr equency ba nd ar ound t he
int ended closed-loop bandwidt h is of special impor t ance.
Resampling
If t he dat a t ur n out t o be sampled t oo fast , t hey ca n be decimat ed, i.e., ever y
k-t h value is picked, aft er pr oper pr efilt er ing (ant ia lias filt er ing). This is
obt ained fr om menu it em Pre proce s s > Re sample .
2 Th e G r a p h i c a l U se r In te rf a c e
2-12
You can also r esample at a fast er sa mpling r at e by int er pola t ion, using t he
sa me comma nd, and giving a r esampling fact or less t han one.
Quickstart
The pop-up menu it em Pre proce s s > Qui ckst art per for ms t he following
sequence of act ions: It opens t he Time plot Dat a view, r emoves t he mea ns fr om
t he signals, and it split s t hese det r ended da t a int o t wo ha lves. The fir st one is
made Wor king Dat a and t he second one becomes Validat ion Da t a. All t he t hr ee
cr eat ed da t a set s ar e inser t ed int o t he Dat a Boar d.
Checklist for Data Handling
Inser t da t a int o t he GUIs Dat a Boar d.
Plot t he dat a and examine it car efully.
Typica lly det r end t he dat a by r emoving mean va lues.
Possibly pr efilt er t he dat a t o enhance and suppr ess var ious fr equency bands.
Select por t ions of t he dat a for Est imat ion and for Va lidat ion. Dr a g a nd dr op
t hese dat a set s t o t he cor r esponding boxes in t he GUI.
Simulating Data
The GUI is int ended pr ima r ily for wor king wit h r eal dat a set s, and does not
it self pr ovide funct ions for simulat ing synt het ic dat a. That has t o be done in
comma nd mode, and you can use your favor it e pr ocedur e in SIMULINK, t he
Signal Pr ocessing Toolbox, or any ot her t oolbox for simulat ion and t hen inser t
t he simulat ed dat a int o t he GUI as descr ibed a bove.
The Syst em Ident ificat ion Toolbox also has sever al commands for simulat ion.
You should check idinput, idsim, poly2th, modstruc, and ms2th in Cha pt er 4,
"Command Refer ence," for det ails. The following example shows how t he
ARMAX model
y (t )- 1 . 5 y (t -1 ) +0 . 7 y ( t - 2 ) =u (t -1 ) +0 . 5 u ( t - 2 )+e(t )- e( t - 1 )+0 . 2e(t -2 )
is simulat ed wit h a binar y r andom input u:
model1 = poly2th([1 -1.5 0.7],[0 1 0.5],[1 -1 0.2]);
u = idinput(400,rbs,[0 0.3]);
e = randn(400,1);
y = idsim([u e],model1);
2-13
The input , u, a nd t he out put , y, can now be impor t ed int o t he Gr aphical User
Int er face as dat a, and t he va r ious est imat ion r out ines can be applied t o t hem.
By also impor t ing t he simulat ion model, model1, int o t he GUI, it s pr oper t ies
ca n be compar ed t o t hose of t he differ ent est imat ed models.
To simulat e a cont inuous-t ime st at e-spa ce model:
y =Cx +e
wit h t he same input , and a sampling int er val of 0.1 seconds, do t he following
in t he Syst em Ident ifica t ion Toolbox:
A=[-1 1;-0.5 0]; B=[1; 0.5]; C=[1 0]; D=0; K=[0.5;0.5];
model2=ms2th(modstruc(A,B,C,D,K),'c');
model2=sett(model2,0.1);
y=idsim([u e],model2);
x

Ax Bu Ke + + =
2 Th e G r a p h i c a l U se r In te rf a c e
2-14
3. Estimating Models
The Basics
Est imat ing models fr om dat a is t he cent r a l act ivit y in t he Syst em
Ident ificat ion Toolbox. It is also t he one t ha t offer s t he most va r iet y of
possibilit ies and t hus is t he most demanding one for t he user .
All est ima t ion r out ines ar e accessed fr om t he pop-up menu Es t i mate in t he
i de nt window. The models a r e always est imat ed using t he dat a set t ha t is
cur r ent ly in t he Worki ng Dat a box.
One ca n dist inguish bet ween t wo differ ent t ypes of est imat ion met hods:
Dir ect est imat ion of t he Impulse or t he Fr equency Response of t he syst em.
These met hods ar e oft en also called nonpar amet r ic est imat ion met hods, and
do not impose any st r uct ur e assumpt ions about t he syst em, ot her t han t hat
it is linear .
Par amet r ic met hods. A specific model st r uct ur e is assumed, and t he
par amet er s in t his st r uct ur e ar e est imat ed using dat a. This opens up a lar ge
var iet y of possibilit ies, cor r esponding t o differ ent ways of descr ibing t he
syst em. Dominat ing ways ar e st at e-space and sever al var iant s of differ ence
equat ion descr ipt ions.
Direct Estimation of the Impulse Response
A linear syst em ca n be descr ibed by t he impulse r esponse g
t
, wit h t he pr oper t y
t hat
The name der ives fr om t he fa ct t ha t if t he input u(t) is a n impulse, i.e., u(t)=1
when t=0 a nd 0 when t >0 t hen t he out put y(t ) will be y(t)=g
t
. For a
mult iva r iable syst em, t he impulse r esponse g
k
will be a p by m mat r ix, wher e
p is t he number of out put s and m is t he number of input s. It s i-j element t hus
descr ibed t he behavior of t he i-t h out put aft er an impulse in t he j-t h input .
By choosing menu it em Es t i mate > Correl ati on Mode l and t hen select ing
Es ti mat e in t he dialog window t hat opens, impulse r esponse coefficient s ar e
est imat ed dir ect ly fr om t he input /out put dat a using so called correlat ion
y t ( ) g
k
u t k ( )
k 1 =

=
2-15
analysis. The a ct ual met hod is descr ibed under t he command cra in t he
Command Reference chapt er . An opt ion t hat det er mines t he or der of a
pr ewhit ening filt er can also be set in t he dia log window. It is not ver y sensit ive
in most cases, and t he default choice is oft en good enough. To obt ain t he defa ult
choice wit hout opening t he dialog window, you can also just t ype t he let t er c in
t he i de nt window. This is t he hot key for cor r elat ion a nalysis.
The r esult ing impulse r esponse est imat e is placed in t he Model Boar d, under
t he default na me cra_d. (The name can be changed by double-clicking on t he
model icon and t hen t yping in t he desir ed name in t he dia log box t hat opens.)
The best way t o examine t he r esult is t o select t he Mode l Vi e w Trans i e nt
Re s pons e . This gives a gr a ph of t he est imat ed r esponse. This view offer s a
choice bet ween displaying t he Impulse or t he St ep r esponse. For a
mult ivar iable syst em, t he differ ent channels, i.e., t he r esponses fr om a cer t ain
input t o a cer t ain out put , a r e select ed under menu it em Channe l.
The number of lags for which t he impulse r esponse is est imat ed, i.e., t he lengt h
of t he est imat ed r esponse, is det er mined as one of t he opt ions in t he Tr a nsient
Response View.
Direct Estimation of the Frequency Response
The fr equency r esponse of a linear syst em is t he Four ier t r ansfor m of it s
impulse r esponse. This descr ipt ion of t he syst em gives consider able
engineer ing insight int o it s pr oper t ies. The r elat ion bet ween input a nd out put
is oft en wr it t en
y ( t ) =G(z ) u ( t ) +v ( t )
wher e G is t he t r ansfer funct ion a nd v is t he addit ive dist ur bance. The funct ion
as a funct ion of (angular ) fr equency is t hen t he fr equency r esponse or
fr equency funct ion. T is t he sampling int er val. If you need mor e det a ils on t he
differ ent int er pr et a t ions of t he fr equency r esponse, consult See The Syst em
Ident ificat ion Pr oblem on page 3-8. in t he Tut orial or any t ext book on linear
syst ems.
The syst ems fr equency r esponse is dir ect ly est imat ed using S pect ral Analysis
by t he menu it em Es ti mat e > Spec tral Mode l , and t hen select ing t he
Es t i mat e but t on in t he dialog box t hat opens. The r esult is placed on t he Model
G e
iT
( )
2 Th e G r a p h i c a l U se r In te rf a c e
2-16
Boar d under t he defa ult na me spa_d. The best way t o examine it is t o plot it
using t he Mode l Vi e w Freque nc y Re s pons e . This view offer s a number of
differ ent opt ions on how t o gr aph t he cur ves. The fr equencies for which t o
est imat e t he r esponse can a lso be select ed as an opt ion under t he Opt i ons
menu in t his Vi e w window.
The Spect r al Analysis command also est imat es t he spect r um of t he addit ive
dist ur bance v(t) in t he syst em descr ipt ion. This est imat ed dist ur bance
spect r um is examined under t he Mode l Vi e w it em Noi s e Spe ct rum.
The Spect r a l Analysis est imat e is st or ed in t he SITBs freqfunc for mat . If you
need t o fur t her wor k wit h t he est imat es, you can expor t t he model t o t he
MATLAB wor kspace and r et r ieve t he r esponses by t he command getff. See
freqfunc and getff in Chapt er 4, "Command Refer ence," for mor e
infor mat ion. (A model is expor t ed by dr agging and dr opping it over t he To
Works pace icon.)
Two opt ions t hat a ffect t he spect r al analysis est ima t e can be set in t he dialog
box. The most impor t ant choice is a number , M, (t he size of t he lag window)
t hat affect s t he fr equency r esolut ion of t he est ima t es. Essent ially, t he
fr equency r esolut ion is about 2 /M r a dians/(sampling int er val). The choice of
M is a t r a de-off bet ween fr equency r esolut ion and var ia nce (fluct uat ions). A
lar ge value of M gives good r esolut ion but fluct ua t ing and less r eliable
est imat es. The defa ult choice of M is good for syst ems t hat do not have ver y
shar p r esonances and may have t o be adjust ed for mor e r esonant syst ems.
The opt ions also offer a choice bet ween t he Blackman-Tukey windowing
met hod spa (which is default ) and a met hod based on smoot hing dir ect Four ier
t r ansfor ms, etfe. etfe ha s a n a dvant age for highly r esonant syst ems, in t ha t
it is mor e efficient for lar ge values of M. It however has t he dr awbacks t hat it
r equir es linear ly spaced fr equency values, does not est ima t e t he dist ur bance
spect r um, and does not pr ovide confidence int er vals. The act ua l met hods ar e
descr ibed in mor e det ail in Chapt er 4, "Command Refer ence," under spa and
etfe. To obt ain t he spect r a l analysis model for t he cur r ent set t ings of t he
opt ions, you can just t ype t he hot key s in t he i de nt window.

2-17
Estimation of Parametric Models
The SITB suppor t s a wide r ange of model st r uct ur es for linear syst ems. They
ar e all accessed by t he menu it em Est i mat e > Parame t ri c Mode ls ... in t he
i de nt window. This opens up a dialog box Parame t ri c Mode ls , which
cont ains t he basic dialog for all par amet r ic est imat ion as shown on t he
following pa ge
Figure 2-3: The Dialog Box for Estimating Parametric Models
The basic funct ion of t his box is a s follows:
As you select Es t i mat e, a model is est imat ed fr om t he Wor king Dat a. The
st r uct ur e of t his model is defined by t he pop-up menu St ruct ure t oget her wit h
t he edit box Orde rs . It is given a name, which is wr it t en in t he edit box Name .
The GUI will always suggest a default model na me in t he Name box, but you
ca n change it t o any st r ing befor e select ing t he Es t i mate but t on. (If you int end
t o expor t t he model lat er , avoid spaces in t he name.)
2 Th e G r a p h i c a l U se r In te rf a c e
2-18
The int er pr et at ion of t he model st r uct ur e infor ma t ion (t ypically int eger s) in
t he Orde r box, depends on t he select ed St ruct ure in t he pop-up menu. This
cover s, t ypically, six choices:
ARX models
ARMAX model
Out put -Er r or (OE) models
Box-J enkins (BJ ) models
St at e-spa ce models
Model st r uct ur e defined by Init ial Model (User defined st r uct ur es)
These ar e dealt wit h one by one shor t ly.
You can fill out t he Orde r box your self at any t ime, but for assist ance you can
select Orde r Edi tor... This will open up anot her dialog box, depending on t he
chosen St ruct ure , in which t he desir ed model or der and st r uct ur e infor mat ion
can be ent er ed in a simpler fashion.
You can also ent er a na me of a MATLAB wor kspace var iable in t he or der edit
box. This var iable should t hen have a value t hat is consist ent wit h t he
necessar y or der s for t he chosen st r uct ur e.
NOTE: For t he st at e-spa ce st r uct ur e and t he ARX st r uct ur e, sever al or der s
and combinat ion of or der s ca n be ent er ed. Then all cor r esponding models will
be compar ed and displayed in a special dialog window for you t o select
suit able ones. This could be a useful t ool t o select good model or der s. This
opt ion is descr ibed in mor e det a il la t er in t his sect ion. When it is available, a
but t on Orde r se l e ct i on is visible.
Estimation Method
A common a nd gener al met hod of est imat ing t he par amet er s is t he predict ion
error approach, wher e simply t he pa r amet er s of t he model ar e chosen so t hat
t he differ ence bet ween t he models (pr edict ed) out put and t he measur ed out put
is minimized. This met hod is available for a ll model st r uct ur es. Except for t he
ARX case, t he est imat ion involves an it er at ive, numer ical sear ch for t he best
fit .
2-19
To obt ain infor mat ion fr om a nd int er act wit h t his sea r ch, select It e rati on
cont rol... This also gives access t o a number of opt ions t hat gover n t he sear ch
pr ocess. (See auxvar in t he Chapt er 4, "Command Refer ence,".)
For some model st r uct ur es (t he ARX model, and black-box st at e-space models)
met hods based on cor r elat ion ar e also available: Inst r ument al Var iable (IV)
and Sub-space (N4SID) met hods. The choice bet ween met hods is made in t he
Parame t ri c Mode l s dialog box.
Resulting Models
The est imat ed model is inser t ed int o t he GUIs Model Boar d. You can t hen
examine it s va r ious pr oper t ies a nd compar e t hem wit h ot her models pr oper t ies
using t he Mode l Vi e w plot s. Mor e about t hat in Examining Models on page
2-27.
To t ake a look at t he model it self, double-click on t he models icon (middle/r ight
mouse but t on or alt - double-click). The Dat a/Mode l Info window t hat t hen
opens gives you infor mat ion about how t he model was est imat ed. You can t hen
also select Pre se nt but t on, which will list t he model, and it s par a met er s wit h
est imat ed st a ndar d deviat ions in t he MATLAB comma nd window.
If you need t o wor k fur t her wit h t he model, you can expor t it by dr agging and
dr opping it over t he To Workspace icon, and t hen apply any MATLAB a nd
t oolbox commands t o it . (See, in par t icular , t he commands th2ss, th2tf,
th2par, and thd2thc in Cha pt er 4, "Command Refer ence,".)
How to Know Which Structure and Method to Use
Ther e is no simple way t o find out t he best model st r uct ur e; in fact , for r ea l
dat a, t her e is no such t hing as a best st r uct ur e. Some r out es t o find good and
accept able model ar e descr ibed in A St ar t up Ident ificat ion Pr ocedur e on page
1-12 in t he int r oduct or y chapt er . It is best t o be gener ous at t his point . It oft en
t akes just a few seconds t o est imat e a model, and by t he differ ent validat ion
t ools descr ibed in t he next sect ion, you can quickly find out if t he new model is
any bet t er t han t he ones you had befor e. Ther e is oft en a significant amount of
wor k behind t he dat a collect ion, and spending a few ext r a minut es t r ying out
sever al differ ent st r uct ur es is usually wor t h while.
2 Th e G r a p h i c a l U se r In te rf a c e
2-20
ARX Models
The Structure
The most used model st r uct ur e is t he simple linear differ ence equat ion
which r elat es t he cur r ent out put y(t ) t o a finit e number of past out put s y(t -k )
and input s u(t -k).
The st r uct ur e is t hus ent ir ely defined by t he t hr ee int eger s na, nb, and nk. na
is equal t o t he number of poles and nb1 is t he number of zer os, while nk is t he
pur e t ime-delay (t he dead-t ime) in t he syst em. For a syst em under
sa mpled-dat a cont r ol, t ypically nk is equal t o 1 if t her e is no dead-t ime.
For mult i-input syst ems nb and nk ar e r ow vect or s, wher e t he i-t h element
gives t he or der /delay associat ed wit h t he i-t h input .
Entering the Order Pa rameters
The or der s na, nb, and nk can eit her be dir ect ly ent er ed int o t he edit box
Orde rs in t he Paramet ri c Mode l s window, or select ed using t he pop-up
menus in t he Orde r Edi t or.
Estimating Many Models Simultaneously
By ent er ing any or all of t he st r uct ur e par amet er s as vect or s, using MATLABs
colon not at ion, like na=1:10, et c., you define many differ ent st r uct ur es t hat
cor r espond t o all combinat ions of or der s. When select ing Est i mat e , models
cor r esponding t o all of t hese st r uct ur es ar e comput ed. A special plot window
will t hen open t hat shows t he fit of t hese models t o Validat ion Dat a. By clicking
in t his plot , you can t hen ent er any models of your choice int o t he Model Boar d.
Mult i -i nput mode l s : For mult i-input models you ca n of cour se ent er each of
t he input or der s and delays as a vect or . The number of models r esult ing fr om
all combinat ions of or der s a nd delays can however be ver y la r ge. As an
alt er na t ive, you ma y ent er one vect or (like nb=1:10) for all input s a nd one
vect or for all delays. Then only such models a r e comput ed t hat have t he same
or der s and dela ys fr om all input s.
y t ( ) a
1
y t 1 ( ) a
na
y t na ( ) + + + b
1
u t nk ( ) b
nb
u t nk nb 1 + ( ) + + =
2-21
Estimation Methods
Ther e ar e t wo met hods t o est imat e t he coefficient s a and b in t he ARX model
st r uct ur e:
Le as t Square s : Minimizes t he sum of squa r es of t he r ight -hand side minus
t he left -hand side of t he expr ession above, wit h r espect t o a a nd b. This is
obt ained by select ing ARX as t he Met hod.
Ins trume nt al Vari abl e s : Det er mines a and b so t hat t he er r or bet ween t he
r ight - and left - hand sides becomes uncor r elat ed wit h cer t ain linear
combinat ions of t he input s. This is obt ained by select ing IV in t he Me t hod box.
The met hods ar e descr ibed in mor e det ail in Chapt er 4, "Command Refer ence,"
under arx and iv4.
Multi-Output Models
For a mult i-out put ARX st r uct ur e wit h NY out put s and NU input s, t he
differ ence equa t ion above is st ill valid. The only change is t ha t t he coefficient s
a a r e NY by NY mat r ices and t he coefficient s b ar e NY by NU mat r ices.
The or der s [NA NB NK] define t he model st r uct ur e as follows:
NA: an NY by NY mat r ix whose i-j ent r y is t he or der of t he polynomial (in t he
delay oper at or ) t hat r elat es t he j-t h out put t o t he i-t h out put
NB: an NY by NU mat r ix whose i-j ent r y is t he or der of t he polynomial t hat
r elat es t he j-t h input t o t he i-t h out put
NK: an NY by NU mat r ix whose i-j ent r y is t he delay fr om t he j-t h input t o t he
i-t h out put
The Order Edi t or dialog box allows t he choices
NA = naones(NY,NY)
NB = nbones(NY,NU)
NK = nkones(NY,NU)
wher e na, nb, and nk ar e chosen by t he pop-up menus.
For t ailor -made or der choices, const r uct a mat r ix [NA NB NK] in t he MATLAB
command window and ent er t he name of t his ma t r ix in t he Order edit box in
t he Parame t ri c Mode l s window.
Not e t hat t he possibilit y t o est imat e many models simult aneously is not
ava ilable for mult i-out put ARX models.
See Defining Model St r uct ur es on page 3-29 for mor e infor mat ion on
mult i-out put ARX models.
2 Th e G r a p h i c a l U se r In te rf a c e
2-22
ARMAX, Output-Error and Box -Jenkins Models
Ther e ar e sever al elabor at ions of t he ba sic ARX model, wher e differ ent noise
models ar e int r oduced. These include well known model t ypes, such as
ARMAX, Out put -Er r or , and Box-J enkins.
The General Structure
A gener al input -out put linear model for a single-out put syst em wit h input u
and out put y can be wr it t en:
Her e u
i
denot es input #i, and A, B
i
, C, D, a nd F
i
, ar e polynomials in t he shift
oper at or (z or q). (Dont get int imidat ed by t his: It is just a compa ct way of
wr it ing differ ence equa t ions; see below.)
The gener al st r uct ur e is defined by giving t he t ime-delays nk and t he or der s of
t hese polynomials (i.e., t he number of poles a nd zer os of t he dynamic model
fr om u t o y, as well as of t he noise model fr om e t o y).
The Special Cases
Most oft en t he choices ar e confined t o one of t he following special cases:
ARX: A(q) y(t ) = B(q) u(t -nk) + e(t )
ARMAX: A(q) y(t ) = B(q) u(t -nk) + C(q) e(t )
OE: y(t ) = [B(q)/F(q)] u(t -nk) + e(t ) (Out put -Er r or )
BJ : y(t ) = [B(q)/F(q)] u(t -nk) + [C(q)/D(q)] e(t ) (Box-J enkins)
The shift oper a t or polynomia ls ar e just compact ways of wr it ing differ ence
equat ions. For example t he ARMAX model in longhand would be:
y ( t ) +a
1
( t - 1 )+. . . +a
na
y ( t - n a )=b
1
u ( t - n k )+. . . b
nb
u (t -n k - n b +1 ) +e(t )
+c
1
e(t - 1)
+. . . +e
nc
e(t -n c)
Not e t hat A(q) cor r esponds t o poles t hat ar e common bet ween t he dynamic
model a nd t he noise model (useful if noise ent er s t he syst em close t o t he
input ). Likewise F(q) det er mines t he poles t hat ar e unique for t he dyna mics
fr om input # i, and D(q) t he poles t hat ar e unique for t he noise.
A q ( )y t ( ) B
i
q ( ) F
i
q ( ) ] u
i
t nk
1
( ) C q ( ) D q ( ) ] e t ( ) [ + [
i 1 =
nu

=
2-23
The mot ivat ion for int r oducing all t hese model var iant s is t o pr ovide for
flexibilit y in t he noise descr ipt ion and t o allow for common or differ ent poles
(dyna mics) for t he differ ent input s.
Entering the Model Structure
Use t he St ruct ure pop-up menu in t he Parame t ri c Mode l s dialog t o choose
bet ween t he ARX, ARMAX, Out put -Er r or , and Box-J enkins st r uct ur es. Not e
t hat if t he Wor king Dat a set has sever al out put s, only t he fir st choice is
ava ilable. For t ime ser ies (dat a wit h no input signa l) only AR and ARMA ar e
ava ilable a mong t hese choices. These ar e t he t ime ser ies count er par t s of ARX
and ARMAX.
The or der s of t he polynomials ar e select ed by t he pop-up menus in t he Orde r
Edi tor dialog window, or by dir ect ly ent er ing t hem in t he edit box Orde rs in
t he Parame t ri c Mode l s window. When t he or der edit or is open, t he default
or der s, ent er ed as you change t he model st r uct ur e, ar e based on pr eviously
used or der s.
Estimation Method
The coefficient s of t he polynomia ls a r e est imat ed using a pr edict ion er r or /
Maximum Likelihood met hod, by minimizing t he size of t he er r or t er m e in
t he expr ession above. Sever al opt ions gover n t he minimizat ion pr ocedur e.
These ar e accessed by act ivat ing It e rat i on Cont rol in t he Parame tri c
Mode l s window, and select ing Opt i on.
The algor it hms ar e fur t her descr ibed in Chapt er 4, "Command Refer ence,"
under armax, auxvar, bj, oe, and pem. See also Pa r amet r ic Model Est imat ion
on page 3-22 a nd Defining Model St r uct ur es on page 3-29.
NOTE: These model st r uct ur es ar e available only for t he scalar out put case.
For mult i-out put models, t he st at e-spa ce st r uct ur es offer t he same flexibilit y.
Also not e t hat it is not possible t o est imat e many differ ent st r uct ur es
simult aneously for t he input -out put models.
2 Th e G r a p h i c a l U se r In te rf a c e
2-24
State-Space Models
The Model Structure
The basic st at e-space model in innovat ions for m can be wr it t en
x ( t +1) = A x ( t ) + B u (t ) + K e(t )
y ( t ) = C x ( t ) + D u (t ) + e(t )
The SITB suppor t s t wo kinds of pa r amet r izat ions of st at e-space models:
bla ck-box, fr ee par amet r izat ions, and par amet r izat ions t ailor -made t o t he
applicat ion. The la t t er is discussed below under t he heading User Defined
Model St r uct ur es. Fir st we will discuss t he bla ck-box case.
Entering Bla ck-Box State-Space Model Structures
The most impor t ant st r uct ur e index is t he model or der , i.e., t he dimension of
t he st at e vect or x.
Use t he pop-up menu in t he Orde r Edi t or t o choose t he model or der , or ent er
it dir ect ly int o t he Orde rs edit box in t he Parame tri c Mode l s window. Using
t he ot her pop-up menus in t he Orde r Edi t or, you can fur t her affect t he chosen
model st r uct ur e:
Fixing K t o zer o gives an Out put -Er r or met hod, i.e., t he differ ence bet ween
t he models simulat ed out put and t he measur ed one is minimized. For mally,
t his cor r esponds t o an a ssumpt ion t ha t t he out put dist ur bance is whit e
noise.
Fixing D t o zer o means t ha t t her e is a delay of (at least ) one sa mple fr om t he
input t o t he out put . For physical syst ems t hat ar e dr iven by piece-wise
const ant input s, t his is a nat ur al assumpt ion.
Fixing t he init ial value x(0) t o zer o means t hat t he init ial st at e is not
est imat ed. Ot her wise t his init ial st at e is est imat ed fr om t he dat a. (Not e t hat
t he est imat ed value of x(0) is somet hing t hat r elat es t o t he Wor king Dat a ,
and is not necessar ily a good va lue of x(0) for t he Va lidat ion Da t a.)
Estimating Many Models Simultaneously
By ent er ing a vect or for t he model or der , using MATLABs colon not at ion, (such
as 1:10) all indicat ed or der s will be comput ed using a pr eliminar y met hod.
You ca n t hen ent er models of differ ent or der s int o t he Model Boar d by clicking
in a special gr aph t hat cont ains infor mat ion about t he models.
2-25
Estimation Methods
Ther e ar e t wo basic met hods for t he est imat ion:
PEM: Is a st andar d pr edict ion er r or /maximum likelihood met hod, based on
it er at ive minimizat ion of a cr it er ion. The it er a t ions ar e st a r t ed up at
par a met er values t hat ar e comput ed fr om n4sid. The par amet r izat ion of t he
mat r ices A, B, C, D, and K follows a default canonical for m. The sear ch for
minimum is cont r olled by a number of opt ions. These ar e accessed fr om t he
Opt i on but t on in t he Ite rat i on Control window.
N4SID: Is a subspa ce-based met hod t hat does not use it er at ive sear ch. The
qua lit y of t he r esult ing est imat es may significant ly depend on an auxiliar y
or der (like a pr edict ion hor izon). This auxiliar y or der can be given wit hin
par ent hesis aft er t he or der in t he edit box Orde rs (like 4 (9)). If t he auxiliar y
or der is not given, a default va lue is used.
If t he auxiliar y or der is given as a vect or (like 4 (5:17)), models for all t hese
auxiliar y or der s a r e comput ed and evaluat ed using t he Wor king Dat a set . The
model t hat gives t he best fit is chosen. A figur e is shown t ha t illust r at es t he fit
as a funct ion of auxiliar y or der . (The fit is a simulat ion er r or fit if K=0 is
chosen, ot her wise a one-st ep ahead pr edict ion er r or fit .)
See n4sid and pem in Chapt er 4, "Command Refer ence," for mor e infor mat ion.
User Defined Model Structures
Sta te-Space Structures
The SITB suppor t s user -defined linear st at e-space models of ar bit r ar y
st r uct ur e. Using t he command ms2th, known and unknown par amet er s in t he
A, B, C, D, K, and X0 mat r ices ca n be easily defined bot h for discr et e- and
cont inuous-t ime models. The command mf2th a llows you t o use a complet ely
ar bit r a r y st r uct ur e, defined by an M-file. fixpar and unfixpar can be used t o
manipulat e st r uct ur es. See Chapt er 4, "Command Refer ence," and Defining
Model St r uct ur es on page 3-29
To use t hese st r uct ur es in conjunct ion wit h t he GUI, just define t he
appr opr iat e st r uct ur e in t he MATLAB comma nd window. Then use t he
Structure pop-up menu t o select By Ini t i al Model and ent er t he var iable
name of t he st r uct ur e in t he edit box Ini t i al Mode l in t he Parame t ri c
Mode l s window and select Est i mat e .
2 Th e G r a p h i c a l U se r In te rf a c e
2-26
Any Model Structure
Ar bit r ar y model st r uct ur es can be defined using sever al commands in t he
Syst em Ident ificat ion Toolbox:
poly2th: Cr eat es Input -out put st r uct ur es for single-out put models
ms2th: Cr eat es Linear St at e-space models wit h ar bit r ar y, fr ee par a met er s
mf2th: Cr eat es complet ely a r bit r ar y par amet r izat ions of linea r syst ems
arx2th: Cr eat es mult ivar iable ARX st r uct ur es
fixpar/unfixpar: Modifies st r uct ur es by fixing or unfixing par amet er s
In addit ion, all est imat ion commands cr eat e model st r uct ur es in t er ms of t he
r esult ing models.
Ent er t he name of any model st r uct ur e in t he box Orde rs (or Ini t i al mode l )
in t he window Paramet ri c Mode l s a nd t hen select Es ti mat e . Then t he
par amet er s of t he model st r uct ur e ar e adjust ed t o t he chosen Wor king Dat a
set . The met hod is a st andar d pr edict ion er r or /ma ximum likelihood appr oach
t hat it er at ively sear ches for t he minimum of a cr it er ion. Opt ions t hat gover n
t his sear ch ar e accessed by t he Opt i on but t on in t he Ite rat i on Cont rol
window.
The name of t he init ial model must be a va r iable eit her in t he wor kspace or in
t he Model Boar d. In t he la t t er ca se you can just dr ag a nd dr op it over t he
Orde rs /Ini ti al mode l edit box.
2-27
4. Examining Models
Having est imat ed a model is just a fir st st ep. It must now be exa mined,
compar ed wit h ot her models, and t est ed wit h new dat a set s. This is pr imar ily
done using t he six Mode l Vi e w funct ions, a t t he bot t om of t he main i de nt
window:
Fr equency r esponse
Tr ansient r esponse
Zer os and poles
Noise spect r um
Model out put
Model r esiduals
In addit ion, you can double-click on t he models icon t o get Te xt Informat i on
about t he model. Finally, you ca n expor t t he model t o t he MATLAB wor kspa ce
and use any commands for fur t her a nalysis and model use.
View s and Models
The basic idea is t ha t if a cer t ain Vi e w window is open (checked), t hen all
models in t he Model Summar y Boar d t hat ar e select ed will be r epr esent ed in
t he window. The cur ves in t he Vi e w window can be clicked in and out by
select ing and deselect ing t he models in an online fashion. You select and
deselect a model by clicking on it s icon. An select ed model is mar ked wit h a
t hicker line in it s icon.
On color scr eens, t he cur ves ar e color coded along wit h t he model icons in t he
Model Boar d. Befor e pr int ing a plot it might be a good idea t o separ a t e t he line
st yles (menu it em under Style ). This could also be helpful on bla ck and whit e
scr eens.
Not e t hat models t hat ar e obt ained by spect r a l analysis only can be
r epr esent ed a s fr equency r esponse a nd noise spect r a, and t ha t models
est imat ed by cor r elat ion analysis only can be r epr esent ed as t r ansient
r esponse.
2 Th e G r a p h i c a l U se r In te rf a c e
2-28
The Plot Window s
The six views all give similar plot windows, wit h sever a l common feat ur es.
They have a common menu bar , which cover s some basic funct ions.
Fir st of all, not e t hat t her e is a zoom funct ion in t he plot window. By dr agging
wit h t he left mouse but t on down, you can dr aw r ect a ngles, which will be
enlar ged when t he mouse but t on is r eleased. By double-clicking, t he or igina l
axis scales ar e r est or ed. For plot s wit h t wo axes, t he x-axes scales ar e locked t o
each ot her . A single click on t he left mouse but t on zooms in by a fact or of t wo,
while t he middle but t on zooms out . The zoom funct ion can be dea ct ivat ed if
desir ed. J ust select t he menu it em Zoom under St yl e .
Second, by point ing t o any cur ve in t he plot , and pr essing t he r ight mouse
but t on, t he cur ve will be ident ified wit h model name and pr esent coor dinat es.
The common menu ba r cover s t he following funct ions:
File
File a llows you t o copy t he cur r ent figur e t o anot her , st a ndar d MATLAB figur e
window. This might be useful, e.g., when you int end t o pr int a cust omized plot .
Ot her Fi le it ems cover pr int ing t he cur r ent plot and closing t he plot window.
Options
Opt ions fir st of all cover s act ions for set t ing t he a xes sca ling. This menu it em
also gives a number of choices t hat a r e specific for t he plot window in quest ion,
like a choice bet ween st ep r esponse or impulse r esponse in t he Trans i e nt
re spons e window.
A most impor t ant opt ion is t he possibilit y t o show confidence int er vals. Each
model pr oper t y has some uncer t aint y. This ca n also be est imat ed fr om da t a. By
checking Show confi de nce i nt e rval s , a confidence r egion ar ound t he
nominal cur ve (model pr oper t y) will be mar ked (by dash-dot t ed lines). The level
of confidence can also be set under t his menu it em.
NOTE: Confidence int er vals ar e suppor t ed for most models and pr oper t ies,
except models est imat ed using n4sid a nd etfe, and t he k-st ep ahead
pr edict ion-pr oper t y.
2-29
Style
The st yle menu gives access t o var ious ways of affect ing t he plot . You can add
gr idlines, t ur n t he zoom on and off, and change t he linest yles. The menu also
cover s a number of ot her opt ions, like choice of unit s and scale for t he axis.
Channel
For mult ivar iat e syst ems, you ca n choose which input -out put channel t o
examine. The cur r ent choice is mar ked in t he figur e t it le.
Help
The He l p menu has a number of it ems, which explain t he plot and it s opt ions.
Frequency Response and Disturbance Spectra
All linear models t hat ar e est imat ed can be wr it t en in t he for m
y ( t ) =G(z ) u ( t ) +v ( t )
wher e G(z) is t he (discr et e-t ime) t r ansfer funct ion of t he syst em and v(t ) is an
addit ive dist ur bance. The fr equency r esponse or fr equency funct ion of t he
syst em is t he complex-valued funct ion G(e
iT
) viewed as a funct ion of angular
fr equency .
This funct ion is oft en gr aphed as a Bode diagr am, i.e., t he logar it hm of t he
amplit ude (t he absolut e value) G(e
iT
) a s well as t he phase ar g (t he ar gument )
G(e
iT
) ar e plot t ed a gainst t he logar it hm of fr equency in t wo sepa r at e plot s.
These plot s ar e obt a ined by checking t he Mode l Vi e w Fre que ncy Re s pons e
in t he main i dent window.
The est imat ed spect r um of t he dist ur bance v is plot t ed as a power spect r um by
choosing t he Mode l Vi e w Noi s e Spe ct rum.
If t he dat a is a t ime ser ies y (wit h no input u), t hen t he spect r um of y is plot t ed
under Noi s e Spe ct rum, and no fr equency funct ions ar e given.
Transient Response
Good a nd simple insight int o a models dynamic pr oper t ies is obt a ined by
looking at it s st ep r esponse or impulse r esponse. This is t he out put of t he model
when t he input is a st ep or an impulse. These r esponses ar e plot t ed when t he
Mode l Vi e w Trans i e nt Re s pons e is checked.
2 Th e G r a p h i c a l U se r In te rf a c e
2-30
It is quit e infor mat ive t o compar e t he t r ansient r esponse of a par amet r ic
model, wit h t he one t hat wa s est imat ed using cor r elat ion analysis. If t her e is
good agr eement bet ween t he t wo, you can be quit e confident t hat some
essent ially cor r ect feat ur es have been picked up. It is useful t o check t he
confidence int er va ls ar ound t he r esponses t o see what good agr eement could
mean quant it at ively.
Ma ny models pr ovide a descr ipt ion of t he addit ive dist ur bance v(t ):
v ( t ) =H( z )e(t )
Her e H(z) is a t r ansfer funct ion t hat descr ibes how t he dist ur bance v(t ) can be
t hought of as gener at ed by sending whit e noise e(t) t hr ough it . To displa y t he
pr oper t ies of H, you ca n choose channels (in t he Channe l menu) t ha t have
noise component s as input s.
Poles and Zeros
The poles of a syst em a r e t he r oot s of t he denominat or of t he t r ansfer funct ion
G(z), while t he zer os ar e t he r oot s of t he numer at or . In par t icular t he poles
have a dir ect influence on t he dynamic pr oper t ies of t he syst em.
The poles and zer os of G (and H ) ar e plot t ed by choosing t he Mode l Vi e w
Pol e s and Ze ros.
It is useful t o t ur n on t he confidence int er vals in t his case. They will clear ly
r eveal which poles a nd zer os could ca ncel (t heir confidence r egions over lap).
Tha t is an indicat ion t ha t a lower or der dynamic model could be used.
For mult ivar iable syst ems it is t he poles and zer os of t he individual input /
out put channels t hat ar e displa yed. To obt ain t he so called t r ansmission zer os,
you will have t o expor t t he model, ext r act a st at e-spa ce descr ipt ion by th2ss,
and t hen apply t he command tzero fr om t he Cont r ol Syst em Toolbox.
Compare Measured and Model Output
A ver y good way of obt aining insight int o t he qualit y of a model is t o simulat e
it wit h t he input fr om a fr esh dat a set , and compar e t he simulat ed out put wit h
t he measur ed one. This gives a good feel for which pr oper t ies of t he syst em
have been picked up by t he model, and which havent .
This t est is obt ained by checking t he Mode l Vi e w Mode l Out put. Then t he
dat a set cur r ent ly in t he Val i dat i on Dat a box will be used for t he compar ison.
2-31
The fit will also be displa yed. This is comput ed as t he r oot of t he mean squa r e
value of t he differ ence bet ween measur ed and simulat ed out put .
If t he model is unst able, or has int egr at ion or ver y slow t ime const ant s, t he
levels of t he simulat ed and t he measur ed out put may dr ift a par t , even for a
model t hat is quit e good (at lea st for cont r ol pur poses). It is t hen a good idea t o
evaluat e t he models pr edict ed out put r at her t han t he simula t ed one. Wit h a
prediction horizon of k, t he k-st ep ahead pr edict ed out put is t hen obt ained as
follows:
The pr edict ed value y(t ) is comput ed fr om all a vailable input s (used
accor ding t o t he model) and a ll available out put s up t o t ime t-k, .
The simula t ion case, wher e no past out put s at all ar e used, t hus for mally
cor r esponds t o k=. To check if t he model has picked up int er est ing dynamic
pr oper t ies, it is wise t o let t he pr edict ed t ime hor izon (kT, T being t he sampling
int er val) be lar ger t han t he impor t ant t ime const a nt s.
Not e her e t hat differ ent models use t he infor mat ion in past out put dat a in t heir
pr edict or s in differ ent ways. This depends on t he noise model. For example, so
ca lled Out put -Er r or models (obt ained by fixing K t o zer o for st at e-space models
and set t ing na=nc=nd=0 for input out put models, see t he pr evious sect ion) do
not use past out put s at all. The simulat ed and t he pr edict ed out put s, for a ny
value of k, t hus coincide.
Residual Analysis
In a model
t he noise sour ce e(t ) r epr esent s t hat par t of t he out put t hat t he model could not
r epr oduce. It gives t he left -over s or , in Lat in, t he residuals. For a good model,
t he r esiduals should be independent of t he input . Ot her wise, t her e would be
mor e in t he out put t hat or iginat es fr om t he input and t hat t he model has not
picked up.
To t est t his independence, t he cr oss-cor r ela t ion funct ion bet ween input and
r esiduals is comput ed by checking t he Mode l Vi e w Mode l Re s i duals . It is
wise t o also display t he confidence r egion for t his funct ion. For a n ideal model
t he cor r elat ion funct ion should lie ent ir ely bet ween t he confidence lines for
posit ive lags. If, for example, t her e is a peak out side t he confidence r egion for
lag k, t his means t hat t her e is somet hing in t he out put y(t ) t hat or iginat es fr om
u(t -k) and t hat has not been pr oper ly descr ibed by t he model. The t est is car r ied
u s ( ) s t ( )
y s ( ) s t k ( )
y t ( ) G z ( )u t ( ) H z ( )e t ( ) + =
2 Th e G r a p h i c a l U se r In te rf a c e
2-32
out using t he Validat ion Dat a . If t hese wer e not used t o est imat e t he model, t he
t est is quit e t ough. See also Model St r uct ur e Select ion and Validat ion on page
3-49.
For a model also t o give a cor r ect descr ipt ion of t he noise pr oper t ies (i.e., t he
t r ansfer funct ion H), t he r esiduals should be mut ually independent . This t est
is also car r ied out by t he view Mode l Re s i dual s, by displaying t he
aut o-cor r elat ion funct ion of t he r esiduals (excluding lag zer o, for which t his
funct ion by definit ion is one). For an ideal model, t he cor r elat ion funct ion
should be ent ir ely inside t he confidence r egion.
Tex t Information
By double-clicking (middle/r ight mouse but t on or alt -double-click) on t he model
icon, a Dat a/mode l Info dialog box opens, which cont ains some basic
infor mat ion about t he model. It also gives a diar y of how t he model was cr ea t ed,
along wit h t he not es t hat or igina lly wer e associat ed wit h t he est imat ion dat a
set . At t his point you can do a number of t hings:
Present
Select ing t he Pres e nt but t on displays det ails of t he model in t he MATLAB
comma nd window. The models pa r amet er s a long wit h est imat ed st andar d
deviat ions ar e displayed, as well as some ot her not es.
Modify
You can simply t ype in a ny t ext you want anywher e in t he Di ary and Not e s
edit able t ext field of t he dialog box. You can a lso cha nge t he name of t he model
just by edit ing t he t ext field wit h t he model name. The color , which t he model
is associat ed wit h in all plot s, can also be edit ed. Ent er RGB-values or a color
name (like 'y') in t he cor r esponding box.
Further Analysis in the MATLAB Workspace
Any model and dat a object can be expor t ed t o t he MATLAB wor kspace by
dr agging and dr opping it s icon over t he To Works pac e box in t he i de nt
window.
2-33
Once you have expor t ed t he model t o t he wor kspace, t her e ar e lot s of
commands by which you can fur t her t r ansfor m it , exa mine it , and conver t it t o
ot her for mat s for use in ot her t oolboxes. Some examples of such commands a r e
Also, if you need t o pr epa r e specialized plot s t hat ar e not cover ed by t he Vi e ws ,
all t he SITB commands for comput ing a nd ext r act ing simulat ions, fr equency
funct ions, zer os and poles, et c., ar e available. See Chapt er 3, "Tut or ia l," and
Cha pt er 4, "Command Refer ence,".
thd2thc Tr a nsfor m t o cont inuous t ime.
th2ss Conver t t o st at e-space r epr esent at ion.
th2tf Conver t t o t r ansfer funct ion for m.
th2poly Conver t t o polynomial input /out put for m.
2 Th e G r a p h i c a l U se r In te rf a c e
2-34
5. Some Further GUI Topics
This sect ion discusses a number of differ ent t opics.
Mouse Buttons and Hotkeys
The GUI uses t hr ee mouse but t ons. If you have fewer but t ons on your mouse,
t he act ions associa t ed wit h t he middle and r ight mouse but t ons ar e obt ained
by shift -click, alt -click or cont r ol-click, depending on t he comput er .
The Main ident Window
In t he main i de nt window t he mouse but t ons ar e used t o dr ag and dr op, t o
select /deselect models and dat a set s, and t o double-click t o get t ext infor mat ion
about t he object . You can use t he left mouse but t on for all of t his. A cer t ain
speed-up is obt ained if you use t he left but t on for dr a gging and dr opping, t he
r ight one for select ing models and dat a set s, a nd t he middle one for
double-clicking. On a slow machine a double-click fr om t he left but t on might
not be r ecognized.
The i de nt window a lso has a number of hot keys. By pr essing a keyboar d let t er
when it is t he cur r ent window, some funct ions can be quickly act ivat ed. These
ar e
s: Comput es Spec tral Analysi s Mode l using t he cur r ent opt ions set t ings.
(These can be cha nged in t he dialog window t hat opens when you choose
Spe ct ral Mode l in t he Es ti mat e pop-up menu.)
c: Comput es Corre l at i on Analys i s Mode l using t he cur r ent opt ions
set t ings. (These can be cha nged in t he dialog window t hat opens when you
choose Corre l at i on Mode l in t he Es t i mate pop-up menu.)
q: Comput es t he models associat ed wit h t he Qui c ks t art .
d: Opens a dialog window for impor t ing Data t hat ar e in t he SITB dat a
for mat .
Plot Window s
In t he var ious plot windows t he act ion of t he mouse but t ons depends on
whet her t he zoom is act ivat ed or not :
Zoom Act i ve : Then t he left and middle mouse but t ons a r e associa t ed wit h t he
zoom funct ions as in t he st andar d MATLAB zoom. Left but t on zooms in and t he
middle one zooms out . In a ddit ion, you can dr aw r ect angles wit h t he left
2-35
but t on, t o define t he ar ea t o be zoomed. Double-clicking r est or es t he or iginal
plot . The r ight mouse but t on is associat ed wit h special GUI a ct ions t hat depend
on t he window. In t he Vi e w plot s, t he r ight mouse but t on is used t o ident ify
t he cur ves. Point and click on a cur ve, and a box will display t he name of t he
model/dat a set t hat t he cur ve is associat ed wit h, and also t he cur r ent
coor dinat e va lues for t he cur ve. In t he Mode l Se le c ti on plot s t he r ight mouse
but t on is used t o inspect and select t he var ious models. In t he Pre fi lt e r and
Dat a Range plot s, r ect a ngles ar e dr awn wit h t his mouse but t on down, t o
define t he select ed r ange.
Zoom not act i ve : The special GUI funct ions just ment ioned ar e obt a ined by
any mouse but t on.
The zoom is a ct ivat ed and deact ivat ed under t he menu it em Styl e. The default
set t ing differ s bet ween t he plot s. Dont act ivat e t he zoom fr om t he command
line! That will dest r oy t he special GUI funct ions. (If you happen t o do so
anyway, quit t he window and open it again.)
Troubleshooting in Plots
The funct ion Aut o-range , which is found under t he menu it em Opti ons , set s
aut omat ic scales t o t he plot s. It is also a good funct ion t o invoke when you t hink
t hat you have lost cont r ol over t he cur ves in t he plot . (This may happen, for
example, if you ha ve zoom in a por t ion of a plot and t hen change t he dat a of t he
plot ).
If t he view plot s dont r espond t he way you expect t hem t o, you can always
quit t he window a nd open it again. By quit her e we mean using t he
under lying window syst ems own quit t ing mechanism, which is called differ ent
t hings in t he differ ent plat for ms. This act ion will not be acknowledged by t he
cor r esponding check box in t he i de nt window, so you will have t o fir st uncheck,
and t hen check it . The nor mal way t o close a window is t o use t he Cl ose
funct ion under t he menu it em Fi l e, or t o uncheck t he cor r esponding check box.
Layout Questions and idprefs. mat
The GUI comes wit h a number of pr eset default s. These include t he window
sizes and posit ions, t he color s of t he differ ent models, a nd t he default opt ions
in t he differ ent Vi e w windows.
The window sizes and posit ions, as well as t he opt ions in t he plot windows, can
of cour se be changed dur ing t he session in t he st andar d way. If you want t he
2 Th e G r a p h i c a l U se r In te rf a c e
2-36
GUI t o st ar t wit h your cur r ent window layout and cur r ent plot opt ions, select
menu it em
Options > Save preferences
in t he main i de nt window. This saves t he infor mat ion in a file idprefs.mat.
This file also st or es infor mat ion a bout t he four most r ecent sessions wit h
i de nt. This allows t he session Fi le menu t o be cor r ect ly init ialized. The session
infor mat ion is aut omat ically st or ed upon exit . The layout a nd pr efer ence
infor mat ion is only saved when t he indica t ed opt ion is select ed.
The file idprefs.mat is cr eat ed t he fir st t ime you open t he GUI. It is by default
st or ed in t he same dir ect or y as your startup.m file. If t his defa ult does not
wor k, a wa r ning is issued. This can be ignor ed, but t hen session and pr efer ence
infor mat ion cannot be st or ed.
To change or select a dir ect or y for idprefs.mat, use t he command midprefs.
See Chapt er 4, "Command Refer ence," for det a ils.
To change model color s a nd default opt ions t o your own cust omized choice,
make a copy of t he M-file idlayout.m t o your own dir ect or y (which should be
before t he basic ident dir ect or y in t he MATLABPATH), and edit it a ccor ding t o it s
inst r uct ions.
Customized Plots
If you need t o pr epar e har dcopies of your plot s wit h specia lized t ext s, t it les and
so on, make a copy of t he figur e fir st , using Copy Fi gure under t he Fi le menu
it em. This pr oduces a copy of t he cur r ent figur e in a st andar d MATLAB figur e
for mat .
For plot s t hat ar e not cover ed by t he Vi e w windows, (like, e.g., Nyquist plot s),
you have t o expor t t he model t o t he MATLAB wor kspace and const r uct t he plot s
t her e.
Import from and Ex port to Workspace
As you expor t a model or a dat a set t o t he MATLAB wor kspace by dr opping it s
icon over t he To Wor kspace icon, it will become a wor kspace va r iable wit h t he
sa me na me as in i de nt , say mymodel. At t he same t ime anot her wor kspace
va r iable will be cr eat ed wit h t he name mymodel_info. This cont ains all diar y
and not e infor mat ion. This will be quit e useful if you want t o manipulat e t he
2-37
model using MATLAB commands and t hen impor t it back int o ident . The use is
illust r at ed by t he following example:
Expor t model wit h name mymodel t o wor kspace. Execut e t he following at t he
MATLAB command line:
mymodelc=thd2thc(mymodel);
% converting the model to continuous time
mymodelc_info=str2mat(mymodel_info,...
'mymodelc=thd2thc(mymodel)');
% adding the info of how the new variable was created
Now select pop-up menu Mode l>Import , ent er t he var ia ble name mymodelc,
and select Import.
This will ent er t he cont inuous-t ime model int o i dent along wit h t he r elevant
infor mat ion.
What Cannot be Done Using the GUI
The GUI cover s pr imar ily ever yt hing you would like t o do t o examine dat a ,
est imat e models and evaluat e a nd compar e models. It does not cover
Gener a t ion (simulat ion) of dat a set s
Model cr eat ion (ot her t han by est imat ion)
Model manipulat ion and conver sions
Recur sive (on-line) est ima t ion algor it hms
Check Cha pt er 3, "Tut or ial," as well as t he headings Si mul at i on and
Pre di ct i on, Mode l St ruct ure Cre ati on, Mani pul at i ng Model
Structures , Mode l Conve rs i ons , and Re curs i ve Parame t er Est i mat i on
in t he beginning of Chapt er 4, "Command Refer ence," t o see what M-files ar e
ava ilable in t he t oolbox for t hese funct ions.
Not e t hat at any point you can expor t a dat a set or a model t o t he MATLAB
wor kspa ce (by dr agging and dr opping it s icon on t he To Workspace icon).
Ther e you can modify a nd manipulat e it any wa y you want and t hen impor t it
back int o i dent . You can, for example, const r uct a cont inuous-t ime model fr om
an est imat ed discr et e-t ime one (using thd2thc) and t hen use t he model views
t o compar e t he t wo.
2 Th e G r a p h i c a l U se r In te rf a c e
2-38

3
Tut or ial
The Toolbox Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
An Int roduc tory Exampl e to Command Mode . . . . . . . . . . . 3-5
The Sys te m Ide nt i fi cat i on Probl e m . . . . . . . . . . . . . . . . . . . . 3-8
Nonparame t ri c Mode l Es t i mat i on . . . . . . . . . . . . . . . . . . . . . 3-19
Parame t ri c Mode l Es t i mat i on . . . . . . . . . . . . . . . . . . . . . . . . 3-22
De fi ni ng Mode l Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-29
Exami ni ng Mode l s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-40
Mode l Struc ture Se l e cti on and Vali dat i on . . . . . . . . . . . . . 3-49
De al i ng wi th Dat a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-58
Re curs i ve Parame t e r Es ti mat i on . . . . . . . . . . . . . . . . . . . . . 3-61
Some Spe ci al Topi cs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-68
3 Tu to r i a l
3-2
This chapt er has t wo pur poses. It descr ibes t he commands of t he Syst em
Ident ificat ion Toolbox, t heir synt a x a nd use. If you use t he gr aphical user
int er face (GUI), you will not have t o bot her a bout t hese aspect s. The chapt er
also descr ibes t he under lying met hods and algor it hms used. The commands
t hat ar e not r eached fr om t he GUI, i.e., t he r ecur sive algor it hms and mor e
advanced model st r uct ur e definit ions, ar e also t r ea t ed her e.
3-3
1. The Toolbox Commands
It may be useful t o r ecognize sever al layers of t he Syst em Ident ifica t ion
Toolbox. Init ially concent r at e on t he fir st layer of ba sic t ools, which cont ains
t he commands fr om t he Syst em Ident ificat ion Toolbox t hat any user must
mast er . You can pr oceed t o t he next levels whenever an int er est or t he need
fr om t he applica t ions wa r r ant s it . The la yer s ar e descr ibed in t he following
par a gr a phs:
Layer 1: Basic Tools. The fir st layer cont ains t he basic t ools for cor r elat ion and
spect r al analysis, and t he est imat ion of so-called ARX models using t he
least -squar es met hod. It also cont ains t he basic t ools for examining t he
obt ained models. The commands ar e:
ar, arx, bodeplot, compare, cra, dtrend, ffplot
idsim, present, resid, spa, th2arx, th2ff, th2zp, zpplot
The cor r esponding backgr ound is given in t he following sect ions: 3,4,5,6,7 and
8 of t his cha pt er .
Layer 2: Model Structure Selection. The second layer of t he t oolbox cont a ins
some useful t echniques t o select or der s and delays, and t o est imat e mor e
gener al input -out put model st r uct ur es. The commands ar e:
armax, arxstruc, bj, etfe, idfilt, iv4, n4sid
oe, poly2th, selstruc, th2poly
Not e t hat t he commands arx and iv4 also apply t o mult i-input , mult i-out put
syst ems. The cor r esponding backgr ound is given in t he sect ions 3, 5, 6 ,8 a nd 9
of t his chapt er .
Layer 3: More Methods To Ex amine Models and Multi-Input Systems .
This t hir d layer cont ains t r ansfor mat ions bet ween cont inuous and discr et e
t ime, and funct ions for est imat ing complet ely gener al mult i-input model
st r uct ur es. The commands ar e:
pe, pem, predict, th2ss, th2tf, thc2thd, thd2thc
The cor r esponding backgr ound is given in sect ion 7 of t his chapt er .
3 Tu to r i a l
3-4
Layer 4: Recursive Identification. Recur sive (adapt ive, online) met hods of
par amet er est imat ion ar e cover ed by t he comma nds:
rarmax, rarx, rbj, roe, rpem, rplr
The cor r esponding backgr ound is given Recur sive Pa r amet er Est imat ion on
page 3-61.
Layer 5: State-Space Modeling. To build models in st at e-space for m (bot h
cont inuous and discr et e t ime), and t o handle mor e advanced mult i-out put
st r uct ur es, t her e ar e t he commands:
canstart, fixpar, mf2th, modstruc, ms2th, unfixpar
The cor r esponding t heor y is cover ed in sect ions 3, 5, 6, and 8 of t his cha pt er .
(See t he beginning of t he Chapt er 4, "Command Refer ence," for a complet e list
of a vailable funct ions.)
3-5
2. An Introductory Example to Command Mode
A demonst r at ion M-file called iddemo.m pr ovides sever al examples of what
might be t ypical sessions wit h t he Syst em Ident ificat ion Toolbox. To st ar t t he
demo, execut e iddemo fr om inside MATLAB.
Befor e giving a for mal t r eat ment of t he capabilit ies and possibilit ies of t he
t oolbox, t his example is designed t o get you using t he soft war e quickly. This
example is essent ially t he sa me as demo #2 in iddemo. You ma y want t o invoke
MATLAB at t his t ime, execut e iddemo1, and follow along.
Dat a have been collect ed fr om a la bor at or y sca le pr ocess. (Feedbacks Pr ocess
Tr ainer PT326; see page 440 in Ljung, 1987 a nd Rea ding Mor e About Syst em
Ident ificat ion on page 1-18 for r efer ences.) The pr ocess oper a t es much like a
common ha nd-held hair dr yer . Air is blown t hr ough a t ube aft er being hea t ed
at t he inlet t o t he t ube. The input t o t he pr ocess is t he power applied t o a mesh
of r esist or wir es t hat const it ut es t he heat ing device. The out put of t he pr ocess
is t he air t emper at ur e at t he out let measur ed in volt s by a t her mocouple
sensor .
One t housand input -out put dat a point s wer e collect ed fr om t he pr ocess as t he
input was changed in a r andom fa shion bet ween t wo levels. The sampling
int er val is 80 ms. The dat a wer e loaded int o MATLAB in ASCII for m a nd ar e
now st or ed as t he vect or s y2 (out put ) and u2 (input ) in t he file dryer2.mat.
Fir st load t he dat a:
load dryer2
This example select s t he fir st 300 dat a point s for building a model. For
convenience, t he input -out put vect or s ar e mer ged int o a mat r ix:
z2 = [y2(1:300) u2(1:300)];
Take a look at t he dat a,
idplot(z2)
The t oolbox makes fr equent use of default ar gument s. Default values ar e used
when t r ailing ar gument s ar e omit t ed. In t he case above, by default , all dat a
point s ar e gr aphed and t he sa mpling int er va l is one t ime unit .
3 Tu to r i a l
3-6
You can select t he va lues bet ween sample number s 200 a nd 300 for a close-up,
and at t he sa me t ime obt ain cor r ect t ime scales, wit h
idplot(z2,200:300,0.08)
Remove t he const ant levels a nd make t he dat a zer o mea n wit h
z2 = dtrend(z2);
Now, fit t o t he dat a a model of t he for m:
wher e T is t he sampling int er val (her e 0.08 seconds). This model, known as a n
ARX model, t r ies t o explain or comput e t he value of t he out put at t ime t , given
pr evious values of y and u. La t er on, especia lly in Sect ion 8, ar e discussions of
how t o decide upon suit able model or der s (st r uct ur es).
The best values of t he coefficient s and can be comput ed wit h
th = arx(z2,[2 2 3]);
The number s in t he second ar gument t ell arx t o find a model (2.1) wit h t wo
a-par a met er s, t wo b-par amet er s, and t hr ee delays. The r esult is st or ed in t he
mat r ix th in a somewha t coded for m. To specify t he act ual sampling int er va l,
ent er
th = sett(th,0.08);
Ther e ar e sever al ways t o displa y and illust r a t e t he comput ed model. Wit h
present(th)
t he coefficient values of (2.1) and t heir est imat ed st a ndar d deviat ions ar e
pr esent ed on t he scr een.
Next , you might ask how t o evaluat e how well t he model fit s t he dat a . A simple
t est is t o r un a simula t ion wher eby r eal input dat a is fed int o t he model, and
compa r e t he simulat ed out put wit h t he act ual measur ed out put . For t his, select
a por t ion of t he da t a t hat was not used t o build t he model, for exa mple, fr om
sa mple 700 t o 900:
u = dtrend(u2(700:900));
y = dtrend(y2(700:900));
y t ( ) a
1
y t T ( ) a
2
y t 2T ( ) + + b
1
u t 3T ( ) b
2
u t 4T ( ) + =
(2.1)
a
1
a
2
b
1
, , b
2
3-7
ysim = idsim(u,th);
plot([y(100:200) ysim(100:200)])
Not e t hat t he funct ion compare does t his sequence of commands mor e
efficient ly.
You see t hat t he model is quit e capable of descr ibing t he syst em, even for dat a
t hat wer e not used in calculat ing t he fit .
To comput e and gr aph t he poles and zer os of t he model, use
zpth = th2zp(th);
zpplot(zpth)
If you want t o know t he fr equency r esponse, you can comput e t he fr equency
funct ion of t he model and pr esent it a s a Bode plot by ent er ing
gth = th2ff(th);
bodeplot(gth)
Compar e t his t r ansfer funct ion wit h a t r ansfer funct ion obt ained fr om a
nonpa r amet r ic, spect r al a nalysis met hod. Such an est ima t e is obt ained dir ect ly
fr om t he dat a
gs = spa(z2);
gs = sett(gs,0.08);
The sampling int er val, 0.08, is set by t he second command in or der t o obt a in
cor r ect fr equency scales. The funct ion spa also allows you t o select window
sizes, fr equency r anges, et c. All t hese have her e been given default values.
You can compar e t he est ima t e of t he t r ansfer funct ion obt a ined by spect r al
ana lysis a nd t he one obt a ined fr om t he model (2.1) wit h
bodeplot([gs gth])
The agr eement is quit e good.
Finally, plot t he st ep r esponse of t he model. The model comes wit h an est ima t e
of it s own uncer t aint y. Ten differ ent st ep r esponses ar e comput ed and gr aphed.
They cor r espond t o possible models, dr awn fr om t he dist r ibut ion of t he t r ue
syst em (accor ding t o our model):
step = ones(30,1);
idsimsd(step,th)
3 Tu to r i a l
3-8
3. The System Identification Problem
This sect ion discusses differ ent basic ways t o descr ibe linear dynamic syst ems
and also t he most impor t ant met hods for est imat ing such models.
Impulse Responses, Frequency Functions, and
Spectra
The basic input -out put configur at ion is depict ed in t he figur e a bove. Assuming
unit sampling int er val, t her e is an input signal
u ( t ) ; t =1 , 2 , . . . . . . . . , N
and an out put signal
y ( t ) ; t =1 , 2 , . . . . . . . , . N
Assuming t he signals ar e r elat ed by a linear syst em, t he r ela t ionship can be
wr it t en
wher e q is t he shift oper at or and is shor t for
u
e
y
y t ( ) G q ( )u t ( ) v t ( ) + =
(3.1)
G q ( )u t ( )
G q ( )u t ( ) g k ( )u t k ( )
k 1 =

=
(3.2)
and
G q ( ) g k ( )q
k
;
k 1 =

=
q
1
u t ( ) u t 1 ( ) =
(3.3)
3-9
The number s ar e called t he impulse response of t he syst em. Clea r ly,
is t he out put of t he syst em at t ime k if t he input is a single (im)pulse a t
t ime zer o. The funct ion is called t he transfer function of t he syst em. This
funct ion eva luat ed on t he unit cir cle gives t he frequency function
In (3.1) is an addit iona l, unmea sur able dist ur bance (noise). It s pr oper t ies
ca n be expr essed in t er ms of it s (aut o) spect r um
which is defined by
wher e is t he covar iance funct ion of :
and E denot es mat hemat ical expect at ion. Alt er nat ively, t he dist ur bance
ca n be descr ibed as filt er ed whit e noise:
wher e is whit e noise wit h var iance and
Equat ions (3.1) and (3.8) t oget her give a time domain descript ion of t he syst em:
g k ( ) {
g k ( )
G q ( )
q ( e
i
) =
G e
i
( )
(3.4)
v t ( )

v
( )
(3.5)

v
( ) R
v
( )e
iwt
=

= (3.6)
R
v
( ) v t ( )
R
v
( ) Ev t ( )v t ( ) =
(3.7)
v t ( )
v t ( ) H q ( )e t ( ) =
(3.8)
e t ( )

(3.9)

v
( ) H e
i
( )
2
=
y t ( ) G q ( )u t ( ) H q ( )e t ( ) + =
(3.10)
3 Tu to r i a l
3-10
while (3.4) and (3.5) const it ut e a frequency domain descript ion:
The impulse r esponse (3.3) and t he fr equency domain descr ipt ion (3.11) ar e
called nonparametric model descriptions since t hey ar e not defined in t er ms of
a finit e number of par a met er s. The basic descr ipt ion (3.10) also applies t o t he
mult iva r iable ca se; i.e., t o syst ems wit h sever al (say nu) input signa ls and
sever al (say ny) out put signals. In t hat case is an ny by nu mat r ix while
and ar e ny by ny mat r ices.
Polynomial Representation of Transfer Functions
Rat her t ha n specifying t he funct ions G and H in (3.10) in t er ms of funct ions of
t he fr equency var iable , you can descr ibe t hem a s r at ional funct ions of
and specify t he numer at or and denominat or coefficient s in some way.
A commonly used pa r amet r ic model is t he ARX model t hat cor r esponds t o
wher e B and A ar e polynomials in t he delay oper at or :
Her e, t he number s na and nb ar e t he or der s of t he r espect ive polynomials. The
number nk is t he number of delays fr om input t o out put . The model is usually
wr it t en
G e
i
( );

v
( ) (3.11)
G q ( )
H q ( )
v
( )
q
1
G q ( ) q
nk
=
B q ( )
A q ( )
-----------; H q ( )
1
A q ( )
----------- =
(3.12)
q
1
A q ( ) 1 a
1
q
1
a
na
q
na
+ + + =
B q ( ) b
1
b
2
q
1
b
nb
q
nb 1 +
+ + + =
(3.14)
(3.13)
A q ( )y t ( ) B q ( )u t nk ( ) e t ( ) + = (3.15)
3-11
or explicit ly
Not e t hat (3.15) -(3.16) a pply a lso t o t he mult ivar iable ca se, wher e and
t he coefficient s become ny by ny mat r ices, and t he coefficient s
become ny by nu mat r ices.
Anot her ver y common, and mor e gener al, model st r uct ur e is t he ARMAX
st r uct ur e
Her e, and ar e as in (3.13)-(3.14), while
An Output-Error (OE) st r uct ur e is obt ained as
wit h
The so-called Box-J enkins (BJ ) model st r uct ur e is given by
wit h
y t ( ) a
1
y t 1 ( ) a
na
y t na ( ) + + + =
b
1
u t nk ( ) b
2
u t nk 1 ( ) b
nb
u t nk nb 1 + ( ) e t ( ) + + + +
(3.16)
A q ( )
a
i
B q ( ) b
i
A q ( )y t ( ) B q ( )u t nk ( ) C q ( )e t ( ) + =
(3.17)
A q ( ) B q ( )
C q ( ) 1 c
1
q
1
c
nc
q
nc
+ + + = (3.18)
y t ( )
B q ( )
F q ( )
-----------u t nk ( ) e t ( ) + =
(3.19)
F q ( ) 1 f
1
q
1
f
nf
q
nf
+ + + =
(3.20)
y t ( )
B q ( )
F q ( )
-----------u t nk ( )
C q ( )
D q ( )
------------e t ( ) + =
(3.21)
D q ( ) 1 d
1
q
1
d
nd
q
nd
+ + + =
(3.22)
3 Tu to r i a l
3-12
All t hese models ar e specia l cases of t he gener al par a met r ic model st r uct ur e:
The var iance of t he whit e noise is assumed t o be .
Wit hin t he st r uct ur e of (3.23), vir t ually all of t he usual linear black-box model
st r uct ur es ar e obt ained as special cases. The ARX st r uct ur e is obviously
obt ained for . The ARMAX st r uct ur e cor r esponds t o
. The ARARX st r uct ur e (or t he gener alized least -squar es model)
is obt ained for , while t he ARARMAX st r uct ur e (or ext ended
mat r ix model) cor r esponds t o . The Out put -Er r or model is obt ained
wit h , while t he Box-J enkins model cor r esponds t o .
(See Sect ion 4.2 in Ljung (1987) for a det ailed discussion.)
The same t ype of models can be defined for syst ems wit h an ar bit r a r y number
of input s. They ha ve t he for m
A q ( )y t ( )
B q ( )
F q ( )
-----------u t nk ( )
C q ( )
D q ( )
------------e t ( ) + =
(3.23)
e t ( ) {
nc nd nf 0 = = =
nf nd 0 = =
nc nf 0 = =
nf 0 =
na nc nd 0 = = = na 0 =
A q ( )y t ( )
B
1
q ( )
F
1
q ( )
--------------u
1
t nk
1
( ) ...+
B
nu
q ( )
F
nu
q ( )
-----------------

u
nu
t nk
nu
( )
C q ( )
D q ( )
------------e t ( ) + + =
3-13
State-Space Representation of Transfer Functions
A common way of descr ibing linear syst ems is t o use t he st ate-space form:
Her e t he r elat ionship bet ween t he input a nd t he out put is defined via
t he nx-dimensional st at e vect or . In t r ansfer funct ion for m (3.24)
cor r esponds t o (3.1) wit h
Her e is t he nx by nx ident it y ma t r ix. Clear ly (3.24) ca n be viewed as one
way of par a met r izing t he t r ansfer funct ion: Via (3.25) becomes a funct ion
of t he element s of t he mat r ices A, B, C, and D.
To fur t her descr ibe t he char a ct er of t he noise t er m in (3.24) a mor e flexible
innovat ions for m of t he st a t e-space model ca n be used:
This is equivalent t o (3.10) wit h given by (3.25) and by
Her e ny is t he dimension of and .
It is oft en possible t o set up a syst em descr ipt ion dir ect ly in t he innovat ions
for m (3.26). In ot her cases, it might be pr efer able t o descr ibe fir st t he nat ur e of
dist ur ba nces t hat act on t he syst em. Tha t lea ds t o a st ochast ic st at e-spa ce
model:
x t 1 + ( ) Ax t ( ) Bu t ( ) + =
y t ( ) Cx t ( ) Du t ( ) v t ( ) + + =
(3.24a)
(3.24b)
u t ( ) y t ( )
x t ( )
G q ( ) C qI
nx
A ( )
1
B D + =
(3.25)
I
nx
G q ( )
v t ( )
x t 1 + ( ) Ax t ( ) Bu t ( ) Ke t ( ) + + =
y t ( ) Cx t ( ) Du t ( ) e t ( ) + + = (3.26b)
(3.26a)
G q ( ) H q ( )
H q ( ) C qI
nx
A ( )
1
K I
ny
+ = (3.27)
y t ( ) e t ( )
x t 1 + ( ) Ax t ( ) Bu t ( ) w t ( ) + + =
y t ( ) Cx t ( ) Du t ( ) e t ( ) + + =
(3.28a)
(3.28b)
3 Tu to r i a l
3-14
wher e and ar e st ochast ic pr ocesses wit h cer t ain covar ia nce
pr oper t ies. In st at ionar it y and fr om an input -out put view, (3.28) is equivalent
t o (3.26) if t he mat r ix K is chosen as t he st eady-st at e Kalman gain. How t o
comput e K fr om (3.28) is descr ibed in t he Cont r ol Syst em Toolbox.
Continuous-Time State-Space Models
It is oft en ea sier t o descr ibe a syst em fr om physical modeling in t er ms of a
cont inuous-t ime model. The r eason is t hat most physica l laws ar e expr essed in
cont inuous t ime as differ ent ial equat ions. Ther efor e, physical modeling
t ypically lea ds t o st a t e-space descr ipt ions like
Her e, means t he t ime der ivat ive of . If t he input is piece-wise const ant over
t ime int er vals , t hen t he r elat ionship bet ween
and can be exa ct ly expr essed by (3.24) by t a king
and associa t e y(t) wit h y[t ], et c.
If you st ar t wit h a cont inuous-t ime innova t ions for m
t he discr et e-t ime count er par t is given by (3.26) wher e st ill t he r elat ionships
(3.30) hold. The exact connect ion bet ween and K is somewhat mor e
complicat ed, t hough. An ad hoc solut ion is t o use
in analogy wit h G and B. This is a good appr oxima t ion for shor t sampling
int er vals T.
w t ( ) e t ( )
(3.29a)
(3.29b)
x

t ( ) Fx t ( ) Gu t ( ) + =
y t ( ) Hx t ( ) Du t ( ) v t ( ) + + =
x

x
kT t k 1 + ( )T < u k [ ] u kT ( ) =
y k [ ] y kT ( ) =
A e
FT
= B e
F
0 =
T

= ; Gd C H = ;
(3.30)
x

t ( ) Fx = t ( ) Gu + t ( ) K

+ e t ( )
y t ( ) Hx = t ( ) Du + t ( ) e + t ( )
(3.31a )
(3.31b)
K

K e
F
0 =
T

= K

d;
(3.32)
3-15
Estimating Impulse Responses
Consider t he descr ipt ion (3.1). Suppose t hat t he input is whit e noise; i.e.,
it s covar ia nce funct ion is
Then, t he cr oss covar iance funct ion bet ween t he input and t he out put is
wher e g() is t he impulse r esponse of t he syst em. In t his case, it ca n ea sily be
est imat ed as
based on t he obser ved input -out put da t a.
If t he input is not whit e, a whit ening filt er L(q) ca n be det er mined for it , so
t hat t he filt er ed sequence
is appr oximat ely whit e. By filt er ing t he out put sequence t hr ough t he same
filt er and comput ing (3.33) based on t he filt er ed dat a, a nat ur a l est imat e of t he
impulse r esponse coefficient s g(k) is obt ained. This pr ocedur e is known a s
correlat ion analysis.
u t ( )
R
u
( ) Eu = t + ( )u t ( )
if 0 =
0 else
'

=
R
yu
( ) Ey t + ( )u t ( ) g ( ) = =
g ( )
1
N
------- = y
t 1 =
N

t + ( )u t ( )
(3.33)
u
F
t ( ) L = q ( )u t ( ) (3.34)
3 Tu to r i a l
3-16
Estimating Spectra and Frequency Functions
This sect ion descr ibes met hods t hat est imat e t he fr equency funct ions and
spect r a (3.11) dir ect ly. The cr oss-covar ia nce funct ion bet ween y(t) and
u(t) was defined a bove. It s Four ier t r ansfor m, t he cr oss spect r um, is
defined analogously t o (3.6). Pr ovided t hat t he input is independent of ,
t he r elat ionship (3.1) implies t he following r elat ionships bet ween t he spect r a:
By est imat ing t he var ious spect r a involved, t he fr equency funct ion and t he
dist ur bance spect r um can be est imat ed as follows:
For m est ima t es of t he covar iance funct ions (as defined in (3.7)) , ,
and , using
and analog expr essions for t he ot her s. Then, for m est imat es of t he
cor r esponding spect r a
and analogously for and . Her e is t he so-ca lled lag window and
M is t he widt h of t he lag window. The est imat es ar e t hen for med as
This pr ocedur e is known as spectral analysis. (See Chapt er 6 in Ljung (1987).)
R
yu
( )

yu
( )
u t ( ) v t ( )

y
( ) G e
i
( )
2

u
( )
v
( ) + =

yu
( ) G e
i
( )
u
( ) =
R

y ( ) R

yu ( )
R

u
( )
R

yu ( )
1
N
--- - y t + ( )u t ( )
t 1 =
N

=
(3.35)

y ( ) R

y
M =
M

= ( )W
M
( )e
i
(3.36)
u yu
W
M
( )
G

N e
i
( )

yu ( )

u ( )
------------------ -; =

v ( )

y ( )

yu ( )
2

u ( )
------------------------ =
(3.37)
3-17
Estimating Parametric Models
Given a descr ipt ion (3.10) and having obser ved t he input -out put dat a u, y, t he
(pr edict ion) er r or s in (3.10) can be comput ed as:
These er r or s ar e, for given dat a y and u, funct ions of G and H. These in t ur n
ar e par a met r ized by t he polynomia ls in (3.15)-(3.23) or by ent r ies in t he
st a t e-space mat r ices defined in (3.29)(3.32). The most common par amet r ic
ident ificat ion met hod is t o det er mine est imat es of G and H by minimizing
t hat is
This is called a predict ion error method. For Gaussian dist ur bances it coincides
wit h t he maximum likelihood met hod. (See Chapt er 7 in Ljung (1987).)
A somewhat differ ent philosophy can be a pplied t o t he ARX model (3.15). By
for ming filt er ed ver sions of t he input
and by mult iplying (3.15) wit h , , 2, , na and ,
, 2, , nb and summing over t , t he noise in (3.15) can be cor r elat ed out
and solved for t he dynamics. This gives t he instrument al variable met hod, and
ar e ca lled t he inst r ument s. (See Sect ion 7.6 in Ljung (1987).)
e t ( )
e t ( ) H
1
q ( ) y t ( ) G q ( )u t ( ) [ ] = (3.38)
V
N
G H , ( ) e
2
t ( )
t 1 =
N

=
(3.39)
G

N H

N , [ ] argmin e
2
t ( )
t 1 =
N

=
(3.40)
N q ( )s t ( ) M q ( )u t ( ) =
(3.41)
s t k ( ) k 1 = u t nk 1 k + ( )
k 1 =
s t ( )
3 Tu to r i a l
3-18
Subspace Methods for Estimating State-Space
Models
The st at e-space ma t r ices A, B, C, D, a nd K in (3.26) can be est imat ed dir ect ly,
wit hout fir st specifying any par t icular par a met r izat ion by efficient subspace
methods. The idea behind t his ca n be expla ined a s follows: If t he sequence of
st at e vect or s x(t ) wer e known, t oget her wit h y(t ) and u(t), eq (3.26b) would be a
linear r egr ession, and C and D could be est imat ed by t he least squar es met hod.
Then e(t ) could be det er mined, and t r eat ed a s a known signa l in (3.26a ), which
t hen would be a not her linear r egr ession model for A, B and K. (One could also
t r eat (3.24) as a linear r egr ession for A, B, C, and D wit h y(t ) and x(t +1) a s
simult aneous out put s, and find t he joint pr ocess and mea sur ement noises as
t he r esiduals fr om t his r egr ession. The Kalman gain K could t hen be comput ed
fr om t he Riccat i equat ion.) Thus, once t he st at es ar e known, t he est imat ion of
t he st at e-space mat r ices is easy.
How t o find t he st at es x(t)? Appendix 4.A of Ljung(1987) shows t hat all st at es
in r epr esent at ions like (3.26) can be for med as linear combina t ions of t he
k-st ep ahead pr edict ed out put s (k=1,2,...,n). It is t hus a mat t er of finding t hese
pr edict or s, and t hen select ing a ba sis among t hem. The subspa ce met hods for m
an efficient and numer ically r elia ble way of det er mining t he pr edict or s by
pr oject ions dir ect ly on t he obser ved dat a sequences. For mor e det ails, see t he
r efer ences under n4sid in Chapt er 4, "Command Refer ence" .
3-19
4. Nonparametric Model Estimation
This and t he following sect ions give an int r oduct ion t o t he basic funct ions in
t he Syst em Ident ificat ion Toolbox. Not all of t he opt ions ava ilable when using
t he funct ions a r e descr ibed her e; see t he Command Reference cha pt er and t he
online Help facilit y.
Data Representation
The obser ved out put and input signals, and , ar e r epr esent ed in t he
Syst em Ident ificat ion Toolbox as column vectors y and u. Row k cor r esponds t o
sample number k. For mult ivar iable syst ems, each input (out put ) component
is r epr esent ed a s a column vect or , so t hat u becomes an N by nu mat r ix (N =
number of sa mpled obser vat ions, nu = number of input signa ls). The
out put -input dat a is collect ively r epr esent ed as a ma t r ix whose fir st column(s)
is t he out put a nd next column(s) is t he input :
z = [y u]
The da t a can be gr aphed by t he command idplot:
idplot(z)
This gives plot s of all combinat ions of input s and out put s for visual inspect ion.
Some of t he funct ions in t he Syst em Ident ificat ion Toolbox apply only t o single
out put da t a ( ) and some only t o single-input -single-out put dat a
( , ). Chapt er 4, "Command Refer ence" gives det a ils about t his.
y t ( ) u t ( )
ny 1 =
ny 1 = nu 1 =
3 Tu to r i a l
3-20
Correlation Analysis
The cor r elat ion analysis pr ocedur e descr ibed in The Syst em Ident ificat ion
Pr oblem in Chapt er 3 is implement ed in t he funct ion cra:
ir = cra(z)
This funct ion r et ur ns t he est imat ed impulse r esponse in t he vect or ir. It also
opt iona lly plot s t he est imat ed covar iance funct ions for y and u, so t hat t he
success of t he whit ening filt er (3.34) can be checked. Fr om t he est imat ed
impulse r esponse it is easy t o for m t he st ep r esponse:
ir = cra(z)
sr = cumsum(ir)
plot(sr)
Spectral Analysis
The funct ion spa per for ms spect r al analysis accor ding t o t he pr ocedur e in
(3.35)(3.37).
[G,PHIV] = spa(z)
Her e z cont ains t he out put -input dat a as above. G a nd PHIV ar e mat r ices t hat
cont ain t he est imat ed fr equency funct ion a nd t he est imat ed dist ur bance
spect r um in (3.37). They ar e coded int o a special for mat , t he freqfunc
format , which allows you t o plot t hem using t he funct ion bodeplot or ffplot:
[G,PHIV] = spa(z)
bodeplot(G)
bodeplot(PHIV)
bodeplot gives logar it hmic amplit ude and fr equency scales (in r ad/sec) and
linear phase scale, while ffplot gives linea r fr equency scales (in Hz). The
det ails of t he freqfunc for mat ar e given in Chapt er 4, "Command Refer ence"
and by t yping help freqfunc. To obt ain cor r ect fr equency scales you ca n
oper at e wit h t he command sett on G or give t he sampling int er va l as a n
opt iona l ar gument t o spa.
By omit t ing t he ar gument PHIV, only t he t r ansfer funct ion est ima t e G is
comput ed:
G = spa(z)
GN
v
3-21
When PHIV is included, t he est imat ed st andar d deviat ions of G and PHIV a r e
also r et ur ned by spa and included in t he fr eqfunc for mat .
If z = y is a t ime ser ies, spa r et ur ns an est imat e of t he spect r um of t hat signal:
PHIY = spa(y)
ffplot(PHIY)
In t he comput at ions (3.35)-(3.37), spa uses a Hamming window for wit h
a default lengt h M equal t o t he minimum of 30 a nd a t ent h of t he number of
dat a point s. This window size M can be changed t o a n ar bit r ar y number by
[G,PHIV] = spa(z,M)
The r ule is t hat as M incr eases, t he est imat ed fr equency funct ions show sha r per
det ails, but ar e also mor e affect ed by r andom dist ur bances. A t ypica l sequence
of commands t hat t est differ ent window sizes is
g10 = spa(z,10)
g25 = spa(z,25)
g50 = spa(z,50)
bodeplot([g10 g25 g50])
An empir ical t r a nsfer funct ion est imat e is obt ained as t he r a t io of t he out put
and input Four ier t r ansfor ms wit h
G = etfe(z)
This can also be int er pr et ed as t he spect r al analysis est imat e for a window size
t hat is equal t o t he dat a lengt h. For a single signal etfe gives t he periodogram
as a spect r al est imat e. The funct ion a lso a llows some smoot hing of t he cr ude
est imat e; it can be a good alt er nat ive for signa ls and syst ems wit h shar p
r esonances. See Chapt er 4, "Command Refer ence" for mor e infor ma t ion.
W ( )
3 Tu to r i a l
3-22
5. Parametric Model Estimation
The Syst em Ident ificat ion Toolbox cont a ins sever al funct ions for par amet r ic
model est imat ion. They all sha r e t he same command st r uct ur e
th = f unc t i on([y u],ths)
Input var iables y and u ar e column vect or s t hat cont ain t he out put and input
dat a sequences, while t he ma t r ix ths specifies t he par t icular st r uct ur e of t he
model t o be est imat ed. The r esult ing est imat ed model is cont ained in th. It is
coded int o t he thet a format. This is t he basic for mat for r epr esent ing models in
t he Syst em Ident ificat ion Toolbox. It collect s infor ma t ion about t he model
st r uct ur e and t he or der s, delays, pa r amet er s, and est ima t ed covar iances of
est imat ed par amet er s int o a mat r ix. The det ails of t his r epr esent at ion ar e
found in Chapt er 4, "Command Refer ence" or by t yping help theta. The theta
for mat can be t r anslat ed t o ot her useful model r epr esent a t ions. To just display
t he model infor mat ion, use t he command present:
th = function(z,ths)
present(th)
The following sect ions assume t hat you have for med an ar r a y z t hat consist s of
t he out put y and t he input u:
z = [y u]
ARX Models
To est imat e t he par amet er s and of t he ARX model (3.15), use t he funct ion
arx:
th = arx(z,[na nb nk])
Her e na, nb, and nk ar e t he cor r esponding or der s and delays in (3.16) t hat
define t he exact model st r uct ur e. The funct ion arx implement s t he
least -squa r es est imat ion met hod, using t he MATLAB / oper at or for
over det er mined linear equat ions.
An alt er na t ive is t o use t he Inst r ument al Var ia ble (IV) met hod descr ibed in
connect ion wit h (3.41). This is obt ained wit h
th = iv4(z,[na nb nk])
a
i
b
i
3-23
which gives an aut omat ic (and appr oximat ely opt imal) choice of t he filt er s N
and M in (3.41). (See t he pr ocedur e (15.21)-(15.26) in Ljung (1987).)
Bot h arx and iv4 ar e applicable t o ar bit r ar y mult ivar iable syst ems. If you have
ny out put s and nu input s, t he or der s ar e defined accor dingly: na is an
ny by ny mat r ix whose i -j ent r y gives t he or der of t he polynomial t hat r elat es
past va lues of t o t he cur r ent va lue of (i.e., past values of up t o
ar e used when pr edict ing . Similar ly t he i -j ent r ies of t he
ny by nu mat r ices nu and nk, r espect ively, give t he or der and delay fr om input
number j when pr edict ing out put number i. (See Defining Model St r uct ur es
on page 3-29 a nd Chapt er 4, "Command Refer ence" for exact det a ils.)
AR Models
For a single signal t he count er par t of t he ARX model is t he AR model:
The arx command also cover s t his special case
th = arx(y,na)
but for scalar signa ls mor e opt ions ar e offer ed by t he command
th = ar(y,na)
which has an opt ion t hat a llows you t o choose t he algor it hm fr om a gr oup of
sever al popular t echniques for comput ing t he least -squar es AR model. Among
t hese ar e Bur gs met hod, a geomet r ic lat t ice met hod, t he Yule-Walker
appr oach, a nd a modified covar iance met hod. (See Chapt er 4, "Command
Refer ence" for det ails.) The count er par t of t he iv4 command is
th = ivar(y,na)
which uses an inst r ument a l var ia ble t echnique t o comput e t he AR par t of a
t ime ser ies.
General Polynomial Black-Box Models
Based on t he pr edict ion er r or met hod (3.40), you can const r uct models of
basically a ny st r uct ur e. For t he gener al model (3.23), t her e is t he funct ion
th = pem(z,nn)
y
j
y
i
y
j
y
j
t na i j , ( ) ( ) y
i
t ) ( )
y t ( )
A q ( )y t ( ) e t ( ) =
(5.1)
3 Tu to r i a l
3-24
wher e nn gives all t he or der s and delays
nn = [na nb nc nd nf nk]
The pem command cover s all cases of bla ck-box linear syst em models. Mor e
efficient r out ines ar e available, however , for t he common special cases
th = armax(z,[na nb nc nk])
th = oe(z,[nb nf nk])
th = bj(z,[nb nc nd nf nk])
These handle t he model st r uct ur es (3.17), (3.19) and (3.21), r espect ively.
All t he r out ines also cover single-out put , mult i-input syst ems of t he t ype
wher e nb, nf, and nk ar e r ow vect or s of t he same lengt hs as t he number of input
channels cont aining each of t he or der s and delays
nb = [nb1 ... nbnu];
nf = [nf1 ... nfnu];
nk = [nk1 ... nknu];
These par a met er est imat ion r out ines r equir e a n it er at ive sear ch for t he
minimum of t he funct ion (3.39). This sear ch uses a special st ar t -up pr ocedur e
based on least squar es and inst r ument al var iables (t he det ails ar e given as
equat ion (10.75) in Ljung (1987)). Fr om t he init ial est imat e, a Gauss-Newt on
minimizat ion pr ocedur e is car r ied out unt il t he nor m of t he Gauss-Newt on
dir ect ion is less t han a cer t ain t oler a nce. See Ljung (1987), Sect ion 11.2 or
Dennis and Schnabel(1983) for det a ils. See also t he ent r y on opt ional var ia bles
associat ed wit h t he sear ch at t he end of t his sect ion.
The r out ines pem, armax, oe, and bj can also be st ar t ed at any init ial value thi
specified in t he t het a for mat by r eplacing nn by thi. For example
th = pem(z,thi)
While t he sear ch is t ypica lly init ialized using t he built -in st ar t -up pr ocedur e
giving just or der s and delays (as descr ibed above), t he a bilit y t o for ce a specific
init ial condit ion is useful in sever al cont ext s. Some examples ar e ment ioned in
Some Specia l Topics on page 3-68.
A q ( )y t ( )
B
1
q ( )
F
1
q ( )
--------------u
1
t nk
1
( )
B
nu
q ( )
F
nu
q ( )
-----------------u
nu
t nk
nu
( )
C q ( )
D q ( )
------------e t ( ) + + + =
(5.2)
3-25
If a last ar gument trace is a dded, as in
th = armax(z,nn,trace)
t hese r out ines give st at us r epor t s t o t he scr een dur ing t he minimizat ion,
cont aining cur r ent and pr evious est ima t es, t he associat ed loss funct ions, and
t he Gauss-Newt on updat e vect or and it s nor m. The est imat es ar e t hen
r epr esent ed by a column vect or , list ing t he par a met er s in alphabet ica l or der .
The number t hen flicker ing in t he upper left cor ner shows how many t imes t he
suggest ed upda t e dir ect ion has been bisect ed dur ing t he sear ch. It is a healt hy
sign if t his number is small.
These r out ines r et ur n t he est imat ed covar iance ma t r ix of t he est imat ed
par a met er vect or as par t of th. This r eflect s t he r eliabilit y of t he est imat es. The
covar iance mat r ix est imat e is comput ed under t he assumpt ion t hat it is
possible t o obt ain a t r ue descr ipt ion in t he given st r uct ur e.
State-Space Models
Black-box , discrete-time, parametrizations. Suppose fir st t hat t her e is no
par t icular knowledge about t he int er nal st r uct ur e of t he discr et e-t ime
st a t e-space model (3.16). Any linear model of a given or der is sought . Then
t her e ar e essent ially t wo differ ent ways t o est imat e st at e-space models, like
(3.26). The simplest one is t o use n4sid:
th = n4sid(z,order);
which cr eat es a model in st at e-space for m (coded as usua l in t he t het a for mat )
in a r ealizat ion t hat is aut omat ically chosen t o be r easonably well condit ioned.
The basic idea behind t his subspace algor it hm was descr ibed in The Syst em
Ident ificat ion Pr oblem on page 3-8.
The ot her alt er nat ive is t o use a pr edict ion er r or met hod, minimizing t he
cr it er ion (5.3) below. Init ializing t he sear ch at t he n4sid model is t hen a good
idea. This is obt a ined by
thi = canstart(z,order,nu)
th = pem(z,thi)
3 Tu to r i a l
3-26
Arbitrarily parameterized models in discrete and continuous time. For
st at e-space models of given st r uct ur e, most of t he effor t involved r elat es t o
defining and manipulat ing t he st r uct ur e. This is discussed in Defining Model
St r uct ur es on pa ge 3-29. Once t he st r uct ur e is defined in t he t het a for mat as
ths, you can est imat e it s par amet er s wit h
th = pem(z,ths)
When t he syst ems ar e mult i-out put , t he following cr it er ion is used for t he
minimizat ion:
which is t he maximum likelihood cr it er ion for Gaussian noise wit h unknown
covar iance mat r ix.
The numer ical minimizat ion of t he pr edict ion er r or cr it er ion (3.39) or (5.3) can
be a difficult pr oblem for gener al model par a met r izat ions. The cr it er ion, as a
funct ion of t he fr ee par amet er s, ca n define a complicat ed sur face wit h ma ny
local minima, na r r ow valleys and so on. This may r equir e subst ant ial
int er act ion fr om t he user , in pr oviding r easonable init ial par amet er values,
and also by fr eezing cer t ain par amet er values while allowing ot her s t o be fr ee.
Not e t hat pem easily allows t he fr eezing of any pa r amet er s t o t heir nominal
va lues. The funct ions fixpar and unfixpar ar e also useful. A pr ocedur e t hat is
oft en used for st at e-spa ce models is t o allow t he noise par a met er in t he K
mat r ix fr ee, only when a r easonable model of t he dynamic pa r t has been
obt ained. See a lso Some Special Topics on pa ge 3-68.
Optional Variables
The funct ions pem, armax, oe, and bj can accept t hr ee addit ional input opt ions
t hat affect t he minimizat ion, as well as one ext r a out put a r gument . For
example,
[th, iter_info] = bj(z,nn,maxiter,tol,lim)
The for mat is t he same for t he ot her funct ions. If t hese var iables ar e not given,
default values ar e assigned t o t hem.
det e t ( )e
T
t ( )
t 1 =
N

min (5.3)
3-27
maxiter: This var iable det er mines t he maximum number of it er at ions
per for med in t he sear ch for t he minimum. The default value is 10. Set t ing t he
value of maxiter t o zer o r esult s in t he r et ur n of t he est imat e fr om t he st ar t -up
pr ocedur e.
tol: The it er at ions ar e cont inued unt il t he nor m of t he Gauss-Newt on updat e
vect or is less t han tol. The default value is 0.01. The it er at ions also t er minat e
when maxit er is r eached or when no decr ease in t he cr it er ion ca n be found a long
t he sear ch dir ect ion aft er it has been bisect ed 10 t imes. (Aft er t he 10 fir st
bisect ions, t he sear ch dir ect ion is changed t o t he gr adient one, and 10 new
bisect ions ar e t r ied.)
The par amet er s associat ed wit h t he noise dynamics, (C and D), ar e oft en mor e
difficult t o est imat e t han t he dynamics par amet er s, A, B, and F. Major
cont r ibut ions t o t he nor m of t he updat e dir ect ion t hen come fr om t he ent r ies
cor r esponding t o t he noise pa r amet er s. The Gauss-Newt on vect or can be
monit or ed t o see if it is r easonable t o incr ea se tol on t his gr ound.
lim: The quadr at ic cr it er ion (3.39) gives a consider able r elat ive weight t o la r ge
pr edict ion er r or s. You may want t o limit t heir influence, using robust
est imat ion techniques. In t he est imat ion funct ions ar, bj, max, oe, and pem, a
pr edict ion er r or t hat is lar ger t han lim
*
(est imat ed st a ndar d deviat ion of e)
ca r r ies a linear , r at her t han a quadr at ic, weight .
The default value of lim is 1.6. lim=0 disables t he r obust est ima t ion a nd
applies a pur ely quadr a t ic cr it er ion. The st andar d deviat ion is est imat ed
r obust ly as t he median of t he a bsolut e devia t ions fr om t he median, divided by
0.7. (See eq (15.9)-(15.10) in Ljung (1987).)
Not e t hat t he loss funct ion displayed by present(th) is quadr at ic and t hat t he
dat a-dependent delimit er is comput ed only once, befor e t he minimizat ion
st a r t s.
iter_info: This a a r ow vect or wit h t hr ee ent r ies t hat give infor mat ion about
t he it er at ion pr ocess. The fir st ent r y is t he number of used it er at ions. The
second one is t he impr ovement of t he fit over t he last it er at ion, and t he t hir d
var iable is t he nor m of t he Gauss-Newt on sear ch vect or . If t he number of used
it er at ions is less t han maxiter, at t he same t ime as t his nor m is lar ger t hen
tol, it means t hat t he it er a t ions have been a bor t ed because no bet t er fit could
be obt ained along t he indicat ed sear ch dir ect ion.
3 Tu to r i a l
3-28
For t he spect r al analysis est imat e, you can comput e t he fr equency funct ions a t
ar bit r ar y fr equencies. If t he fr equencies ar e specified in a r ow vect or w, t hen
[G,PHIV] = spa(z,M,w)
r esult s in G and PHIV being comput ed at t hese fr equencies. This comput at ion is
somewhat slower , however , t han using t he default fr equencies.
You can gener at e logar it hmically spaced fr equencies using t he MATLAB
logspace funct ion. For example
w = logspace(3,pi,128)
The opt ional t r a iling ar gument s can be omit t ed, in which case default values
ar e used. Ent er ing t hem a s empt y mat r ices, [ ], a lso causes funct ions t o r ely
upon default s.
3-29
6. Defining Model Structures
Since t he Syst em Ident ificat ion Toolbox handles a wide va r iet y of differ ent
model st r uct ur es, it is impor t ant t ha t t hese can be defined in a flexible way. In
t he pr evious sect ion you saw how model st r uct ur es t ha t ar e specia l ca ses of t he
gener al model (3.23) can be defined by specifying t he or der s and delays in t he
var ious est imat ion r out ines arx, iv4, oe, bj, armax, and pem. This sect ion
descr ibes how model st r uct ur es and models can be dir ect ly defined. For
black-box models (3.23) t his may be r equir ed, for example, when cr eat ing a
model for simula t ion. Commands for cr ea t ing st at e-space model st r uct ur es ar e
discussed in t his sect ion.
The gener a l way of r epr esent ing models a nd model st r uct ur es in t he Syst em
Ident ificat ion Toolbox is t he thet a format . This sect ion int r oduces t he
commands (a par t fr om t he par amet r ic est imat ion funct ions t hemselves) t hat
cr eat e models in t he t het a for mat .
Polynomial Black-Box Models
The gener a l input -out put for m (3.23):
is defined by t he five polynomials A(q), B(q), C(q), D(q), and F(q). These ar e
r epr esent ed in t he st andar d MATLAB for mat for polynomials. Polynomia l
coefficient s ar e st or ed as r ow vect or s or der ed by descending power s. For
example, t he polynomial
is r epr esent ed a s
A = [1 a1 a2 ... an]
Delays in t he syst em ar e indicat ed by leading zer os in t he polynomial. For
example, t he ARX model
A q ( )y t ( )
B q ( )
F q ( )
-----------u t nk ( )
C q ( )
D q ( )
------------e t ( ) + =
(6.1)
A q ( ) 1 a1q
1
a2q
2
anq
n
+ + + + =
B q ( )
y t ( ) 1.5y t 1 ( ) 0.7y t 2 ( ) + 2.5u t 2 ( ) 0.9u t 3 ( ) + = (6.2)
3 Tu to r i a l
3-30
is r epr esent ed by t he polynomia ls
A = [1 1.5 0.7]
B = [0 0 2.5 0.9]
The t het a for ma t r epr esent at ion of (6.1) is now cr ea t ed by t he command
th = poly2th(A,B,C,D,F,lam,T)
lam is her e t he var iance of t he whit e noise sour ce and T is t he sampling
int er val. Tr ailing ar gument s ca n be omit t ed for default values. The syst em
(6.2) can for example be r epr esent ed by
th = poly2th([1 1.5 0.7],[0 0 0.5 0.7])
In t he mult i-input case (5.2) B and F a r e mat r ices, whose r ow number k
cor r esponds t o t he k-t h input . The command poly2th can also be used t o define
t ime-cont inuous syst ems. See t he Command Reference chapt er for det ails.
Multivariable ARX Models
A mult ivar iable ARX model is given by
Her e A(q) is an ny by ny mat r ix whose ent r ies ar e polynomials in t he delay
oper at or q
-1
. You can r epr esent it as
as well as t he mat r ix
e t ( )
A q ( )y t ( ) B q ( )u t ( ) e t ( ) + =
(6.3)
A q ( ) I
ny
A
1
q
1
A
na
q
na
+ + + =
(6.4)
a
11
(q) . . .
a
21
(q)
a
ny1
(q)
.

.

.
a
12
(q)
a
22
(q)
a
ny2
(q)
.

.

.
a
1ny
(q)
a
2ny
(q)
a
nyny
(q)
.

.

.
. . .
.

.

.
.

.

.
A(q) =
3-31
wher e t he ent r ies ar e polynomials in t he delay oper at or :
This polynomial descr ibes how old values of out put number j a ffect out put
number k. Her e is t he Kr onecker -delt a; it equals 1 when , ot her wise,
it is 0. Similar ly is an ny by nu mat r ix
or
wit h
The dela y fr om input number j t o out put number k is . To link wit h t he
st r uct ur e definit ion in t er ms of [na nb nk] in t he arx and iv4 commands, not e
t hat na is a ma t r ix whose kj-element is , while t he kj-element s of nb and nk
ar e and r espect ively.
The t het a for mat r epr esent at ion of t he model (6.3) can be cr ea t ed by
th = arx2th(A,B,ny,nu)
wher e ny a nd nu a r e t he number of out put s and input s, r espect ively, and A and
B ar e mat r ices t hat define t he ma t r ix polynomials (6.4) and (6.7):
A = [eye(ny) A1 A2 .. Ana]
B = [B0 B1 .. Bnb]
a
kj
q
1
a
kj
q ( )
kj
a
kj
1
q
1
a
kj
na
kj
q
na
kj

+ + + =
(6.6)

kj
k j =
B q ( )
B q ( ) B
0
B
1
q
1
B
nb
q
nb
+ + = (6.7)
b
11
(q) . . .
b
21
(q)
b
ny1
(q)
.

.

.
b
12
(q)
b
22
(q)
b
ny2
(q)
.

.

.
b
1nu
(q)
b
2nu
(q)
b
nynu
(q)
.

.

.
. . .
.

.

.
.

.

.
B(q) =
b
kj
q b
1
kj
q
nk
kj
= b
kj
nb
q
nk
ij
nb
i j
1 +
+
nk
kj
na
kj
nb
kj
nk
kj
3 Tu to r i a l
3-32
Consider t he following syst em wit h t wo out put s and t hr ee input s:
This syst em is defined and simulat ed for a cer t ain input u, a nd t hen est imat ed
in t he cor r ect ARX st r uct ur e by t he following st r ing of commands:
A0 = eye(2);
A1 = [1.5 0.4; 0.2 0];
A2 = [0.7 0 ; 0.01 0.7];
B0 = [0 0.4 0;1 0 0];
B1 = [0 0.1 0;0 0 3];
B2 = [0 0.15 0;0 0 4];
B3 = [0 0 0;0 0 0];
B4 = [0.2 0 0;0 2 0];
B5 = [0.3 0 0;0 0 0];
A = [A0 A1 A2];
B = [B0 B1 B2 B3 B4 B5];
th0 = arx2th(A,B,2,3);
e = randn(200,2);
u = [idinput(200),idinput(200),idinput(200)];
y = idsim([u e],th0);
na = [2 1;2 1];
nb = [2 3 0;1 1 2];
nk = [4 0 0;0 4 1];
the = arx([y u],[na nb nk]);
[Ae, Be] = th2arx(the);
You can use t he t wo comma nds fixpar and unfixpar t o manipulat e ARX
st r uct ur es, so t hat cer t ain par amet er s in t he st r uct ur e ar e fixed t o cer t ain
known values and not est imat ed. See Chapt er 4, "Command Refer ence"for
mor e infor mat ion.
y
1
t ( ) 1.5y
1
t 1 ( ) 0.4y
2
t 1 ( ) 0.7y
1
t 2 ( ) + + 0.2u
1
t 4 ( ) + =
0.3u
1
t 5 ( ) 0.4u
2
t ( ) 0.1u
2
t 1 ( ) 0.15u
2
t 2 ( ) e
1
t ( ) + + +
2u
2
t 4 ( ) 3u
3
t 1 ( ) 4u
3
t 2 ( ) e
2
t ( ) + + +
y
2
t ( ) 0.2 ( )y
1
t 1 ( ) 0.7
y2
t 2 ( ) 0.01
y1
t 2 ( ) u
1
t ( ) + = +
3-33
State-Space Models w ith Free Parameters
The ba sic st at e-space models ar e t he following ones: (See also The Syst em
Ident ificat ion Pr oblem on page 3-8.)
Discrete-Time Innovations Form
Her e T is t he sampling int er va l, is t he input at t ime inst ant and
is t he out put at t ime . (See Ljung (1987) page 87.)
System Dyna mics Ex pressed in Continuous Time
(See Ljung (1987) page 82.) It is oft en easier t o define a pa r amet r ized
st at e-space model in cont inuous t ime because physical laws a r e most oft en
descr ibed in t er ms of differ ent ial equat ions. The mat r ices F, G, H, and D
cont ain element s wit h physical significance (for example, ma t er ial const a nt s).
The numer ical values of t hese may or may not be known. To est imat e unknown
par amet er s based on sampled dat a (assuming T is t he sampling int er va l) fir st
t r ansfor m (6.9) t o (6.8) using t he for mulas (3.30). The value of t he Kalman-ga in
mat r ix K in (6.8) or in (6.9) depends on t he assumed cha r act er of t he a ddit ive
noises and in (3.28), and it s cont inuous-t ime count er par t . Disr egar d
t hat link and view K in (6.8) (or in (6.9)) as t he basic t ool t o model t he noise
pr oper t ies. This gives t he direct ly paramet rized innovations form. (See Ljung
(1987) pa ge 88.) If t he int er nal noise st r uct ur e is impor t ant , you could use
user -defined st r uct ur es as in Example 6.4.
The Syst em Ident ificat ion Toolbox a llows you t o define ar bit r ar y
par amet er izat ions of t he mat r ices in (6.8) or (6.9). When defining t he st r uct ur e,
t he known element s in t he mat r ices ar e ent er ed wit h t heir numer ical values,
x kT T + ( ) Ax kT ( ) Bu kT ( ) Ke kT ( ) + + =
y kT ( ) Cx kT ( ) Du kT ( ) e kT ( ) + + =
x 0 ( ) x0 =
(6.8a)
(6.8b)
(6.8c)
u kT ( ) kT y kT ( )
kT
x

t ( ) Fx t ( ) Gu t ( ) K

w t ( ) + + =
y t ( ) Hx t ( ) Du t ( ) w t ( ) + + =
x 0 ( ) x0 =
(6.9a)
(6.9b)
(6.9c)
K
~
w t ( ) e t ( )
K
~
3 Tu to r i a l
3-34
while t he unknown element s ar e ent er ed as NaN. Use t he commands modstruc
and ms2th.
The Black-Box , Discrete-Time Case
For a discr et e-t ime model, like (6.8) wit hout a ny par t icular int er nal st r uct ur e,
it is easier and mor e nat ur al t o use canstart or n4sid t o est ima t e t he model,
wit hout any pr ior specifica t ion of t he par amet r iza t ion.
Example 6.1: A Discrete-Time Structure. Consider t he discr et e-t ime model
wit h five unknown par a met er s , i=1, ...,3. This st r uct ur e is defined in t he
t het a for mat by
A = [1 NaN; 0 1];
B = [NaN;NaN];
C = [1 0];
D = 0;
K = [NaN;NaN];
x0 = [0;0];
ms1 = modstruc(A,B,C,D,K,x0);
th1 = ms2th(ms1,'d')
The definit ion t hus follows in t wo st eps. Fir st t he a ct ual st r uct ur e (known and
unknown par a met er values) is coded in t he mat r ix ms1 and t hen a t het a for mat
mat r ix is cr eat ed by ms2th. The ar gument 'd' denot es t ha t t he st r uct ur e is a
discr et e-t ime st r uct ur e. Ot her opt ional ar gument s allow definit ion of guessed
va lues of t he unknown pa r amet er s, as well as specificat ion of t he cova r iance
mat r ix of and of t he sampling int er va l T. You can also specify unknown
element s in t he init ia l value vect or .
x t 1 + ( )
1
1
0 1
x t ( )

2

3
u t ( )

4

5
e t ( ) + + =
y t ( )
1 0
x t ( ) e t ( ) + =
x 0 ( )
0
0
=

i
e t ( )
x 0 ( )
3-35
For models t hat ar e par amet r ized as ca nonical for ms, use canform inst ead of
modstruc t o define t he model st r uct ur e.
Ex ample 6.2: A Continuous-Time Model Structure. Consider t he following
model st r uct ur e
This cor r esponds t o an elect r ical mot or , wher e is t he angular
posit ion of t he mot or shaft and is t he angular velocit y. The
par a met er is t he inver se t ime const a nt of t he mot or and is t he
st a t ic gain fr om t he input t o t he angular velocit y. (See page 84 in Ljung (1987).)
The mot or is a t r est at t ime 0 but at a n unknown angula r posit ion. Suppose
t hat is a r ound -1 a nd is a r ound 0.25. If you also know t ha t t he va r iance
of t he er r or s in t he posit ion mea sur ement is 0.01 a nd in t he angular velocit y
measur ement s is 0.1, you can t hen define a t het a st r uct ur e using
F = [0 1; 0 NaN]
G = [0 ;NaN]
H = eye(2)
D = zeros(2,1)
K = zeros(2,2)
x0 = [NaN;0]
ms2 = modstruc(F,G,H,D,K,x0);
thguess=[1, 0.25, 0]
noisevar = [0.01 0; 0 0.1]
th2 = ms2th(ms2,'c',thguess,noisevar)
The st r uct ur e th2 can now be used t o est imat e t he unknown par amet er s
fr om obser ved dat a z = [y1 y2 u] by
model = pem(z,th2)
x

t ( )
0 1
0
1
x t ( )
0

2
u t ( ) + =
y t ( )
1 0
0 1
x t ( ) e t ( ) + =
x 0 ( )

3
0
=
y
1
t ( ) x
1
t ( ) =
y
2
t ( ) x
2
t ( ) =

1

2

1

1

2

i
3 Tu to r i a l
3-36
The it er at ive sear ch for minimum is t hen init ia lized a t thguess. The st r uct ur e
can also be used t o simula t e t he syst em above wit h sampling int er val T=0.1 for
input u and noise r ea lizat ion e:
e=randn(300,2)
u=idinput(300);
th2 = sett(th2,0.1) % setting the sampling interval
y = idsim([u e],th2)
The nominal par a met er values thguess ar e t hen used, and t he noise sequence
is scaled a ccor ding t o t he mat r ix noisevar.
When est imat ing models, you can t r y a number of neighbor ing st r uct ur es,
like what happens if I fix t his pa r amet er t o a cer t ain value or what happens
if I let loose t hese par amet er s. Rat her t han going t hr ough t he whole pr ocedur e
in r edefining t he st r uct ur e, you can use t he commands fixpar and unfixpar.
For example, t o fr ee t he par amet er x
2
(0) (per haps t he mot or wasnt a t r est
aft er all) you can use
th = unfixpar(th2,'x0',[2,1])
To manipulat e init ial condit ions, t he funct ion thinit is also useful.
State-Space Models with Coupled Parameters
In some sit uat ions you may want t he unknown par amet er s in t he mat r ices in
(6.8) or (6.9) t o be linked t o each ot her . Then t he NaN feat ur e is not sufficient t o
descr ibe t hese links. Inst ea d you need t o wr it e an M-file t hat descr ibes t he
st r uct ur e. The for mat is
[A,B,C,D,K,x0] = mymfile(par,T,aux);
wher e mymfile is t he user -defined name for t he M-file, par cont ains t he
par amet er s, T is t he sampling int er val, and aux cont ains a uxiliar y var ia bles.
The lat t er var iables ar e used t o house opt ions, so t hat some differ ent cases can
be t r ied out wit hout having t o edit t he M-file. The mat r ices A, B, C, D, K, and x0
r efer t o t he discr et e-t ime descr ipt ion (6.8). If t he under lying pa r amet er izat ion
is in cont inuous t ime, as in (6.9), it is desir able t o wr it e t he M-file so t hat a
negat ive value of T inhibit s t he sampling. This means t hat A, B, C and D should
be r et ur ned as t he mat r ices in (6.9) when mymfile is called wit h a negat ive T.
To obt a in t he same st r uct ur e as in t he Example 6.2 , you can do t he following:
3-37
function [A,B,C,D,K,x0] = mymfile(par,T,aux)
F = [0 1; 0 par(1)];
G = [0;par(2)];
C = eye(2);
D = zeros(2,2);
K = zeros(2,1);
x0 =[par(3);0];
if T>0, [A,B] = c2d(F,G,T); else A=F; B=G; end
Her e c2d is t he sampling funct ion fr om t he Cont r ol Syst em Toolbox, which
consequent ly is r equir ed t o r un t his example.
Once t he M-file has been wr it t en, t he cor r esponding t het a st r uct ur e is defined
by t he comma nd mf2th (M-file t o t het a):
th = mf2th('mymfile','c',par,aux);
wher e par cont ains t he nominal (init ia l) values of t he cor r esponding ent r ies in
t he st r uct ur e. 'c' signa ls t hat t he under lying par amet r izat ion is cont inuous
t ime, and t hat t he M-file is equipped wit h sampling inhibit ion (for ). aux
cont ains t he values of t he auxiliar y pa r amet er s.
Fr om her e on, est imat e models and evaluat e r esult s as for any ot her model
st r uct ur e. Not e, t hough t hat t he fea t ur es fixpar and unfixpar ar e not
ava ilable for t hese gener a l st r uct ur es. Some fur t her examples of user -defined
model st r uct ur es ar e given below.
State-Space Structures: Initial Values and Numerical
Derivatives
It is somet imes difficult t o find good init ial par amet er values a t which t o st ar t
t he numer ical sear ch for a minimum of (3.38). It is always best t o use physical
insight , whenever possible, t o suggest such va lues wit h thguess. For r andom
init ializat ion, t he comma nd thinit is a useful alt er nat ive a nd complement t o
thguess. Since t her e is always a r isk t hat t he numer ical minimizat ion may get
st uck in a local minimum, it is advisable t o t r y sever al differ ent init ializat ion
values for .
In t he sear ch for t he minimum, t he gr adient of t he pr edict ion er r or s is
comput ed by numer ical differ ent iat ion. The st ep-size is det er mined by t he
M-file nuderst. In it s default ver sion t he st ep-size is simply t imes t he
absolut e value of t he par amet er in quest ion (or t he number if t his is
T 0 <

e t ( )
10
4
10
7
3 Tu to r i a l
3-38
lar ger ). When t he model st r uct ur e cont ains par amet er s wit h differ ent or der s of
magnit ude, t r y t o scale t he var iables so t hat t he pa r amet er s ar e a ll r oughly t he
sa me magnit ude. In any case, you may need t o edit t he M-file nuderst t o
addr ess t he pr oblem of suit able st ep sizes for numer ical differ ent iat ion.
Some Examples of User-Defined Model Structures
Wit h user -defined st r uct ur es, you have complet e fr eedom in t he choice of
models of linea r syst ems. This sect ion gives t wo examples of such st r uct ur es.
Example 6.3: Heat Diffusion. Consider a syst em dr iven by t he heat -diffusion
equat ion (see also Example 4.3 in Ljung (1987)).
This is a met al r od wit h heat -diffusion coefficient which is insulat ed at t he
nea r end a nd heat ed by t he power u (W) at t he far end. The out put of t he
syst em is t he t emper at ur e at t he nea r end. This syst em is descr ibed by a par t ial
differ ent ial equat ion in t ime and space. Replacing t he space-second der ivat ive
by a cor r esponding differ ence appr oximat ion gives a t ime-cont inuous
st at e-space model (6.9), wher e t he dimension of x depends on t he st ep-size in
space used in t he appr oxima t ion. This is descr ibed by t he following M-file:
function [A,B,C,D,K,x0] = heatd(pars,T,aux)
N = aux(1); % Number of points in the
% spacediscretization
L = aux(2); % Length of the rod
temp = aux(3); % Assuming uniform initial
% temperature of the rod
deltaL = L/N; % Space interval
kappa = pars(1); % The heatdiffusion coefficient
K = pars(2); % Heat transfer coefficient at
% far end of rod
F=zeros(N,N);
for kk=2:N1
F(kk,kk1)=1;
F(kk,kk)=2;
F(kk,kk+1)=1;
end
F(1,1)=1; F(1,2)=1; % Near end of rod
% insulated
F(N,N1)=1; F(N,N)=1;
F=Fkappa/deltaL/deltaL;

3-39
G=zeros(N,1);
G(N,1)=K/deltaL;
C=zeros(1,N);
C(1,1)=1;
D=0;
K=zeros(N,1);
x0=tempones(N,1);
if T>0 [A,B]=c2d(F,G,T);else A=F;B=G;end
You can t hen get st ar t ed wit h t he t het a for mat wit h
th = mf2th('heatd','c',[0.27 1],[10,1,22],[],10)
for a 10t h or der appr oximat ion of a heat r od one met er in lengt h, wit h an init ial
t emper at ur e of 22 degr ees and a sampling int er val of 10 seconds. The init ial
est imat e of t he heat conduct ivit y is 0.27, and of t he heat t r ansfer coefficient is
1. The cova r iance mat r ix of t he pr edict ion er r or s is given a default value.
Ex ample 6.4: Parametrized Noise Models. Consider a discr et e-t ime model
x ( t +1 ) =A x ( t ) +B u (t ) +w (t )
y (t )=Cx (t )+e(t )
wher e w and e ar e independent whit e noises wit h covar iance ma t r ices R1 and
R2, r espect ively. Suppose t hat you know t he var iance of t he measur ement
noise R2, and t ha t only t he fir st component of is nonzer o. This can be
handled by t he following M-file:
function [A,B,C,D,K,x0] = mynoise(par,T,aux)
R2 = aux(1); % The assumed known measurement
% noise variance
A = [par(1) par(2);1 0];
B = [1;0];
C=[par(3) par(4)];
D=0;
R1= [par(5) 0;0 0];
K = Adlqe(A,eye(2),C,R1,R2); % from the
% Control System Toolbox
x0=[0;0];
w t ( )
3 Tu to r i a l
3-40
7. Ex amining Models
Once you have est imat ed a model, you need t o invest igat e it s pr oper t ies. You
have t o simulat e it , t est it s pr edict ions, and comput e it s poles and zer os and so
on. You t hus ha ve t o t r ansfor m t he model fr om t he t het a for mat t o ot her ways
of r epr esent ing and pr esent ing it .
Theta Format: th
The basic for mat for r epr esent ing models in t he Syst em Ident ificat ion Toolbox
is called t he t het a format . It st or es all r elevant infor mat ion about t he model
st r uct ur e used, including t he values of t he est imat ed par amet er s, t he
est imat ed covar iances of t he par amet er s, and t he est imat ed innovat ions
va r iance and so on. It also cont ains some infor ma t ion about how and when t he
model was cr eat ed. The det a ils of t he r epr esent at ion can be found in t he
Chapt er 4, "Command Refer ence" or by t yping help theta (for st at e-space
based st r uct ur es t ype help thss). The r epr esent a t ion should, however , be
t hought of a s an int er nal one; unless you ar e an advanced user , you do not need
t o wor r y about t he det a ils. Defining Model St r uct ur es on pa ge 3-29 descr ibes
how t o cr eat e models in t he t het a for mat using sever al differ ent commands.
The infor mat ion in t he t het a for mat is displayed by t he present command:
present(th)
This spells out t he infor mat ion in th. Depending on t he char act er of t he
under lying model st r uct ur e, t he infor mat ion is given in t er ms of t he
polynomials in (6.1), in t er ms of t he mat r ices in (6.8) or (6.9), or in t er ms of t he
ARX polynomials in (6.3). Est imat ed st andar d deviat ions for t he par a met er s
ar e always supplied. For mult ivar iable ARX models and for st at e-space
mat r ices, t he st andar d devia t ions a r e given as ima ginar y number s added t o t he
par amet er s. For t he polynomials t hey ar e given as a second r ow. For example,
t he following pr int out fr om present
The polynomial coefficients and their standard deviations are
B =
0.0000 0.0000 1.7345
0.0000 0.0000 0.0563
A =
1.0000 1.5312 0.6983
0.0000 0.0214 0.0022
3-41
is int er pr et ed as and t he st andar d deviat ion
of 1 is zer o (nat ur ally enough , since it is not est imat ed). The st andar d
deviat ion of is 0.0214. Not e t hat leading zer os in t he B polynomial indicat e
t he delay, a s defined in Defining Model St r uct ur es on page 3-29.
The act ual par amet er s can be ext r act ed fr om t he t het a for mat by
[par,P] = th2par(th)
Her e par is a r ow vect or cont aining t he pa r amet er s, and P is t he est imat ed
covar iance mat r ix of t he par amet er s. The par amet er s ar e list ed in
alphabet ical or der . See Some Special Topics on page 3-68. For t he
polynomia l model (6.1) t he coefficient s of t he A, B, C, D, a nd F polynomials ar e
given in t he or der of incr easing power s of . (See for exa mple (6.2).) Not e t hat
leading 0s of B and t he leading 1 in t he ot her polynomials a r e omit t ed since
t hey do not cor r espond t o est imat ed par amet er s. For t he st at e-space model
(6.8) t he par amet er s ar e given in t he or der obt ained as t he ma t r ix A is fir st
sear ched for est imat ed par amet er s r ow by r ow, t hen B and t hen C, et c. The
same is t r ue for t he cont inuous model (6.9). For user -defined st r uct ur es, t he
or der ing in par is t he same as defined in t he cor r esponding M-file. For
mult ivar iable ARX models, t he or der ing of par a met er s is somewhat t r icky and
it is safer use th2arx. (See The ARX For mat : ar x on page 3-45.)
The sampling int er val can be ext r act ed fr om t he t het a for ma t by
T = gett(th)
A negat ive T means t hat th r epr esent s a t ime-cont inuous syst em. Then syst em
abs(T) indicat es t he sampling int er val for t he dat a for which t he model was
est imat ed. It is also t he sampling int er val t hat applies when th is used for
simulat ion or pr edict ion.
Frequency Function Format: ff
The fr equency funct ion and t he dist ur bance spect r um cor r esponding t o a model
th in t he t het a for mat is comput ed by
[G,PHIV] = th2ff(th)
This gives G and in (3.11) along wit h t heir est ima t ed st andar d deviat ions,
which ar e t r anslat ed fr om t he covar ia nce mat r ix of t he est imat ed pa r amet er s.
If th cor r esponds t o a t ime-cont inuous model, t he fr equency funct ions ar e
comput ed accor dingly.
A q ( ) 1 1.5312q
1
0.6983q
2
+ =
a
1
q
1

v
3 Tu to r i a l
3-42
The r esult ing mat r ices G and PHIV a r e given in t he freqfunc format . This for mat
st or es t he fr equency funct ions and spect r a (3.11) and t heir st andar d devia t ions
as column vect or s. The fir st r ow is r eser ved for a dminist r at ive infor mat ion,
giving det a ils about input and out put number s. The fr equency values can be
chosen ar bit r ar ily, but default t o 128 va lues equally spaced bet ween 0
(excluded) and t he Nyquist fr equency. For t ime-cont inuous models, t he default
fr equency r ange ext ends t o a deca de over t he Nyquist fr equency for t he
sa mpled dat a upon which t he model is ba sed. Typing help freqfunc descr ibes
t he det ails of t he for ma t , which, however , is not impor t ant for basic use of t he
t oolbox.
The funct ion th2ff has opt ions t hat allow t he select ion of specific input -out put
pair s, and t he comput at ion of fr equency funct ions and spect r a at ar bit r ar y
fr equencies.
If th cor r esponds t o a model of a t ime ser ies, it s spect r um is obt a ined a s
PHIY = th2ff(th)
Models in t he fr eqfunc for mat a r e also obt ained by t he nonpa r amet r ic
est imat ion r out ines spa and etfe, as descr ibed in Nonpar a met r ic Model
Est imat ion on page 3-19.
Thr ee funct ions offer gr aphic display of t he fr equency funct ions and spect r a:
bodeplot, ffplot, and nyqplot.
bodeplot(G)
plot s t he Bode diagr am of G (logar it hmic scales and fr equencies in r ad/sec). If G
is a spect r um, only an amplit ude plot is given. Sever al cur ves in t he same
diagr am ar e obt ained wit h
bodeplot([G1 G2 ... Gn])
If infor ma t ion about st andar d deviat ions is included in G, confidence int er vals
cor r esponding t o sd st anda r d deviat ions ar e gr aphed wit h
bodeplot(G,sd)
The comma nd ffplot has t he same synt ax as bodeplot but wor ks wit h linear
fr equency sca les and Her t z as t he unit . The command nyqplot also has t he
sa me synt ax, but pr oduces Nyquist plot s; i.e., gr aphs of t he fr equency funct ion
in t he complex pla ne.
For t he cr eat ion of own fr equency plot s, t he command getff ext r act s t he
r elevant por t ions of t he fr eqfunc for ma t . (See Chapt er 4, "Comma nd
Refer ence"for mor e infor mat ion.)
3-43
Zero-Pole Format: zp
The command th2zp comput es t he zer os, poles, and st at ic gains of t he syst em
associat ed wit h th:
[zepo,K] = th2zp(th)
The mat r ix zepo now cont ains infor mat ion about t he zer os and t he poles of t he
model, along wit h t heir est imat ed st anda r d deviat ions. It also cont a ins (in t he
fir st r ow) administ r a t ive infor mat ion about input and out put number s, which
is used for plot t ing. Similar ly, K cont ains t he st at ic gains and t heir st andar d
deviat ions. The best way of using t he infor mat ion in zepo is t o gr aph t he zer os
and poles by
zpplot(zepo)
Confidence r egions (lines a nd ellipsoids) cor r esponding t o sd st andar d
deviat ions ar e illust r at ed by
zpplot(zepo,sd)
Compar isons bet ween sever al models ar e obt ained by
zp1 = th2zp(th1)
zp2 = th2zp(th2)
zpplot(zpform(zp1,zp2))
zpplot has sever al opt ions t hat det er mine how infor mat ion about differ ent
models a nd differ ent input -out put pair s is depict ed. It also keeps t r ack of
whet her t he under lying model is in discr et e or cont inuous t ime and dr aws t he
complex plane accor dingly. The command th2zp also allows t he select ion of
specific input -out put subsyst ems in t he case of mult ivar iable models.
The funct ion getzp allows you t o ext r a ct t he zer os and t he poles explicit ly fr om
t he zer o-pole for ma t .
State-Space Format: ss
The command
[A,B,C,D,K,X0] = th2ss(th)
comput es t he mat r ices of a st at e-spa ce r epr esent at ion of th. The
r epr esent at ion is in discr et e t ime as (6.8) or in cont inuous t ime as (6.9)
depending on t he st at us of th. If t he under lying model st r uct ur e is a
3 Tu to r i a l
3-44
st at e-space one, t he mat r ices A, B, et c. ar e given in t he same basis as or igina lly
defined. If t he under lying model is defined in t er ms of input -out put
polynomials, t he st a t e-space r epr esent at ion is in obser ver canonical for m. The
st at e-space mat r ices ca n be used for fur t her ana lysis and design in t he Cont r ol
Syst em Toolbox and t he Signa l Pr ocessing Toolbox.
The command th2ss can also comput e t he st andar d deviat ions of t he element s
in st at e-space mat r ices.
Transfer Function Format: tf
The t r a nsfer funct ions associat ed wit h t he model th ar e comput ed by
[NUM,DEN] = th2tf(th)
NUM and DEN ar e given in t he same for mat t hat is used in t he Cont r ol Syst em
Toolbox and t he Syst em Pr ocessing Toolbox. The common denominat or DEN as
a r ow mat r ix and t he k-t h r ow of NUM gives t he numer a t or polynomial
associat ed wit h out put number k. If t he model th ha s sever al input s, specify
t he input number as an ar gument . The polynomia ls a r e r epr esent ed as r ow
vect or s in descending power s of s (in cont inuous t ime) or z or q (in discr et e
t ime). It t hus differ s fr om t he polynomia l for mat . (See below.) For example, t he
cont inuous-t ime syst em
is r epr esent ed as
NUM = [0 0 1] (or just 1)
DEN = [1 2 0]
while t he discr et e-t ime syst em
is r epr esent ed as
NUM = 1
DEN = [1 1.5 0.7 0]
1
s s 2 + ( )
-------------------
q
3
1 1.5q
1
0.7q
2
+
-----------------------------------------------
1
q
3
1.5q
2
0.7q +
------------------------------------------ =
(7.1)
3-45
Polynomial Format: poly
In t he polynomial for mat , t he polynomials A, B, C, D, and F in (3.23) ar e given
as follows: Polynomial coefficient s ar e st or ed in r ow vect or s, or der ed by
ascending power s in t he delay oper at or , , 1, , always st ar t ing wit h
. This means t hat (7.1) is r epr esent ed by
B = [0 0 0 1]
A = [1 1.5 0.7]
Delays ar e t hus denot ed by leading zer os in B. Not e t he differ ence wit h t he
t r ansfer funct ion r epr esent at ion, in t hat leading zer os must be explicit ly given.
Only when t he lengt hs of A and B ar e t he sa me do t he for mat s coincide. See also
Sect ion 6. The polynomials cor r esponding t o th ar e ext r a ct ed by
[A,B,C,D,F] = th2poly(th)
This is consequent ly t he inver se of poly2th descr ibed in Defining Model
St r uct ur es on page 3-29.
Cont inuous-t ime syst ems can also be r epr esent ed in t he polynomial for mat .
Then t he polynomials ar e given a s r ow vect or s in descending power s of t he
Laplace var iable s just as in t he t r ansfer funct ion case.
The ARX Format: arx
To obt ain an ARX descr ipt ion fr om a model th t hat cor r esponds t o such a
descr ipt ion (i.e., it has or iginally been gener at ed by arx, iv4, or arx2th), use
[A,B] = th2arx(th)
The mat r ices A a nd B t hen cont ain t he ARX polynomials as descr ibed in Sect ion
6. th2arx is t hus an inver se of arx2th.
q
k
k 0 =
k 0 =
3 Tu to r i a l
3-46
Transformations Betw een Discrete and Continuous
Models
Continuous-Time Models
A model in t he t het a for ma t can be int er nally r epr esent ed a s a cont inuous-t ime
model. This occur s if t he st r uct ur e was or iginally defined a s a st at e-space
st r uct ur e wit h ms2th or mf2th using t he ar gument 'c'. (See Defining Model
St r uct ur es on page 3-29 a nd t he Chapt er 4, "Comma nd Refer ence".) The model
t hen r emains a cont inuous-t ime one dur ing t he est imat ion phases wit h pem
even t hough t he est imat ion is per for med using sa mpled dat a. A
cont inuous-t ime model of t he t ype (6.1) in polynomial for m also r esult s when
poly2th is used wit h a negat ive value of t he sampling int er val. This st r uct ur e
cannot , however , be used for fur t her est imat ion. Finally, cont inuous-t ime
models ar e obt ained by t he comma nd thd2thc. (See below.)
Cont inuous-t ime models ar e indicat ed by a negat ive sa mpling int er va l. A quick
check can t hus be given by
gett(th)<0
All t he model t r a nsfor ma t ions th2ff, th2zp, th2ss, th2tf, a nd th2poly r esult
in t he cor r esponding char act er ist ics in cont inuous t ime for models th t hat ar e
indicat ed a s cont inuous. For simulat ion and pr edict ion, however , t he model is
fir st t r a nsfor med t o discr et e t ime.
The absolut e value of t he sa mpling int er val of a cont inuous-t ime model is t he
sa mpling int er val of t he da t a for which t he model was est imat ed. It is also used
t o select suit able default fr equency int er vals in th2ff (t he default being fr om
zer o up t o 10
*
/ | T| r ad/sec). The absolut e value of T also applies when t he
model is used for simulat ion a nd pr edict ion.
Discrete-Time Models
These models a r e obt ained fr om t he est imat ion funct ions ar, armax, arx, bj,
ivar, iv4, n4sid, and oe. They ar e a lso obt ained fr om pem when applied t o (6.1)
and t o st at e-space st r uct ur es gener at ed by ms2th a nd mf2th wit h t he ar gument
'd'. Discr et e-t ime models also r esult fr om poly2th wit h posit ive or default
va lues of t he sampling int er val. Finally discr et e-t ime models ar e obt ained wit h
t he command thc2thd. (See below.)
3-47
The sa mpling int er val T is obt a ined by T = gett(th). It indicat es t he sampling
int er val of t he model as well as of t he dat a t o which t he model wa s adjust ed. It
is also used for appr opr ia t e fr equency sca les in t he fr eqfunc for mat .
Transformations
Tr ansfor mat ions bet ween cont inuous-t ime and discr et e-t ime model
r epr esent at ions ar e achieved by thc2thd and thd2thc. The cor r esponding
uncer t aint y mea sur e (t he est imat ed covar iance mat r ix of t he int er nal
par a met er s) is also t r ansfor med in most cases. The synt ax is
thc = thd2thc(thd)
thd = thc2thd(thc,T)
If t he discr et e-t ime model has some pur e t ime delays ( ) t he default
command r emoves t hem befor e for ming t he cont inuous-t ime model. They
should t hen be appended as an ext r a dead t ime. This is done aut oma t ically by
th2ff. thd2thc offer s as an opt ion t o appr oximat e t he dead t ime by a finit e
dimensional syst em. Not e t hat t he noise pr oper t ies ar e t r anslat ed by t he
somewhat quest iona ble for mula (3.32). The cova r iance mat r ix is t r anslat ed by
Gauss appr oximat ion for mula using numer ical der ivat ives. The M-file
nuderst is t hen invoked. You may want t o edit it for applicat ions wher e t he
par a met er s have ver y differ ent or der s of magnit ude. See t he comment s in
Defining Model St r uct ur es on pa ge 3-29.
Her e is an example which compar es t he Bode plot s of an est imat ed model and
it s cont inuous-t ime count er par t :
th = armax(z,[2 3 1 2]);
gd = th2ff(th);
thc = thd2thc(th);
gc = th2ff(thc);
bodeplot([gd gc])
Simulation and Prediction
Any model, when given in t he t het a for ma t , ca n be simulat ed wit h
y = idsim([u e],th)
wher e u and e ar e column vect or s (or mat r ices) cont a ining t he input and noise
sequences. The out put is r et ur ned in a column vect or y of t he same lengt h.
Not ice t ha t th cont ains infor ma t ion about t he noise var iance so e should be a
nk 1 >
3 Tu to r i a l
3-48
zer o-mean, unit -var iance sequence. If e is omit t ed, a noise-fr ee simulat ion is
obt ained. Her e is a t ypical st r ing of commands:
A = [1 1.5 0.7];
B = [0 1 0.5];
th0 = poly2th(A,B,[1 1 0.2]);
u = idinput(400,rbs,[0 0.3]);
e = randn(400,1);
y = idsim([u e],th0);
plot(y)
The inver se model (3.38), which comput es t he pr edict ion er r or s fr om given
input -out put dat a, is simulat ed wit h
e = pe([y u],th)
To comput e t he k-st ep ahead pr edict ion of t he out put signal based on a model
th, t he pr ocedur e is as follows:
yhat = predict([y u],th,k)
The pr edict ed value is comput ed using t he infor mat ion in up t o
t ime and infor mat ion in up t o t ime . The act ual way t hat
t he infor mat ion in past out put s is used depends on t he noise model in th. For
example, a n out put er r or model maint ains t hat t her e is no
infor mat ion in past out put s, t her efor e, pr edict ions and simulat ions coincide.
predict can eva luat e how well a t ime ser ies model is capable of pr edict ing
fut ur e values of t he dat a. Her e is an example, wher e y is t he or iginal ser ies of,
sa y, mont hly sa les figur es. A model is est imat ed based on t he fir st half, and
t hen it s abilit y t o pr edict half a year ahead is checked out on t he second half of
t he obser vat ions:
idplot(y)
y1 = y(1:48), y2 = y(49:96)
th = ar(y1,4)
yhat = predict(y2,th4,6)
plot([y2 yhat])
The command compare is useful for any compar isons involving idsim and
predict.
y t t k ( ) u s ( )
s t = y s ( ) s t k =
A C D 1 = = =
3-49
8. Model Structure Selection and Validation
Aft er you have been analyzing dat a for some t ime, you t ypically end up wit h a
lar ge collect ion of models wit h differ ent or der s and st r uct ur es. You need t o
decide which one is best , and if t he best descr ipt ion is an adequat e model for
your pur poses. These a r e t he pr oblems of model validation.
Model validat ion is t he hear t of t he ident ificat ion pr oblem, but t her e is no
absolut e pr ocedur e for appr oaching it . It is wise t o be equipped wit h a var iet y
of differ ent t ools wit h which t o evaluat e model qualit ies. This sect ion descr ibes
t he t echniques you ca n use t o evaluat e model qualit ies using t he Syst em
Ident ificat ion Toolbox.
Comparing Different Structures
It is nat ur al t o compar e t he r esult s obt ained fr om model st r uct ur es wit h
differ ent or der s. For st at e-space models t his is easily obt ained by using a vect or
ar gument for t he or der in n4sid:
th = n4sid(z,1:10)
This invokes a plot fr om which a best or der is chosen.
For models of ARX t ype, var ious or der s a nd dela y can be efficient ly st udied
wit h t he command arxstruc. Collect in a mat r ix NN all of t he ARX st r uct ur es
you wa nt t o invest igat e, so t hat each r ow of NN is of t he t ype
[na nb nk]
Wit h
V = arxstruc(ze,zv,NN)
an ARX model is fit t ed t o t he dat a set ze for each of t he st r uct ur es in NN. Next ,
for each of t hese models, t he sum of squar ed pr edict ion er r or s is comput ed, as
t hey ar e a pplied t o t he dat a set zv. The r esult ing loss funct ions a r e st or ed in V
t oget her wit h t he cor r esponding st r uct ur es.
To select t he st r uct ur e t ha t has t he sma llest loss funct ion for t he validat ion set
zv, use
nn = selstruc(V,0)
3 Tu to r i a l
3-50
Such a pr ocedur e is known as cross validat ion and is a good way t o appr oach
t he model select ion pr oblem.
It is usually a good idea t o visually inspect how t he fit cha nges wit h t he number
of est imat ed par amet er s. A gr aph of t he fit ver sus t he number of par amet er s is
obt ained wit h
nn = selstruc(V)
This r out ine pr ompt s you t o choose t he number of par a met er s t o est imat e,
based upon visua l inspect ion of t he gr aph, and t hen it select s t he st r uct ur e
wit h t he best fit for t hat number of par amet er s.
The command struc helps gener at e t ypica l st r uct ur e mat r ices NN for
single-input syst ems. A t ypical sequence of commands is
V = arxstruc(ze,zv,struc(2,2,1:10));
nn = selstruc(V,0);
nk = nn(3);
V = arxstruc(ze,zv,struc(1:5,1:5,nk1:nk+1));
nn = selstruc(V)
wher e you fir st est ablish a suit a ble value of t he delay nk by t est ing second
or der models wit h dela ys bet ween one and t en. The best fit select s t he delay,
and t hen all combinat ions of ARX models wit h up t o five a and b pa r amet er s
ar e t est ed wit h delays ar ound t he chosen value (a t ot al of 75 models).
If t he model is validat ed on t he same dat a set fr om which it wa s est ima t ed; i.e.,
if ze = zv, t he fit always impr oves as t he model st r uct ur e incr eases. You need
t o compensat e for t his aut omat ic decr ea se of t he loss funct ions. Ther e ar e
sever al appr oaches for t his. Pr obably t he best known t echnique is Akaikes
Fina l Pr edict ion Er r or (FPE) cr it er ion and his closely r elat ed Infor mat ion
Theor et ic Cr it er ion (AIC). Bot h simulat e t he cr oss valida t ion sit uat ion, wher e
t he model is t est ed on anot her dat a set .
The FPE is for med a s
FPE
1 n + N
1 n N
-------------------- = *V
3-51
wher e n is t he t ot al number of est imat ed par amet er s and N is t he lengt h of t he
dat a r ecor d. V is t he loss funct ion (quadr at ic fit ) for t he st r uct ur e in quest ion.
The AIC is for med as
(See Sect ion 16.4 in Ljung (1987).)
Accor ding t o Akaikes t heor y, in a collect ion of differ ent models, choose t he one
wit h t he sma llest FPE (or AIC). The FPE va lues ar e displayed by t he present
command and ar e also given as t he ent r y (2,1) of t he th mat r ix. The st r uct ur e
t hat minimizes t he AIC is obt ained wit h
nn = selstruc(V,'AIC')
wher e V was gener at ed by arxstruc.
A r ela t ed cr it er ion is Rissanens minimum descr ipt ion lengt h (MDL) appr oach,
which select s t he st r uct ur e t hat a llows t he shor t est over -all descr ipt ion of t he
obser ved dat a . This is obt ained wit h
nn = selstruc(V,'MDL')
If subst ant ia l noise is pr esent , t he ARX models may need t o be of high or der t o
descr ibe simult aneously t he noise char a ct er ist ics and t he syst em dynamics.
(For ARX models t he noise model 1/A(q) is dir ect ly coupled t o t he dyna mics
model B(q)/A(q).) An alt er nat ive is t o comput e t he dynamics model only, using
an IV t echnique, a nd t o comput e t he fit bet ween t he models simulat ed out put
and t he out put in t he valida t ion dat a set zv. This is accomplished wit h
V = ivstruc(ze,zv,NN)
The infor mat ion in V can t hen be handled as descr ibed above. In t his case, V
also cont ains t he condit ion number of t he mat r ix fr om which t he IV est ima t es
ar e solved. Poor condit ioning of t his ma t r ix indicat es unnecessa r ily high model
or der s. (See page 415 in Ljung, 1987).
Checking Pole-Zero Cancellations
A near pole-zer o cancellat ion in t he dynamics model is an indicat ion t hat t he
model or der may be t oo high. To judge if a near cancellat ion is a r eal
ca ncellat ion, t ake t he uncer t aint ies in t he pole- and zer o-loca t ions int o
AIC log 1 2n + N ( )*V [ ]
3 Tu to r i a l
3-52
consider at ion. The funct ion th2zp comput es confidence r egions for t he poles
and zer os, which ar e gr aphed by
zpplot(th2zp(th),1)
wher e t he 1 indicat es how many st anda r d-deviat ions wide t he confidence
int er val is. If t he confidence r egions over lap, t r y lower model or der s.
This check is especially useful when t he models have been gener at ed by arx. As
ment ioned under Compar ing Differ ent St r uct ur es, t he or der s can be pushed
up due t o t he r equir ement t hat 1/A(q) descr ibe t he noise char act er ist ics.
Checking cancellat ions in B(q)/A(q) t hen gives a good indicat ion of which or der s
t o chose fr om model st r uct ur es like armax, oe, and bj.
Residual Analysis
The r esiduals associat ed wit h t he da t a and a given model, as in (3.38), ar e
ideally whit e and independent of t he input for t he model t o cor r ect ly descr ibe
t he syst em. The funct ion
e = resid(z,th)
comput es t he r esiduals e and per for ms whit eness and independence analyses.
The aut o cor r elat ion funct ion of e and t he cr oss cor r elat ion funct ion bet ween e
and u ar e comput ed and displayed for up t o lag 25. Also displayed ar e 99%
confidence int er va ls for t hese var iables, assuming t hat e is indeed whit e and
independent of u.
The r ule is t hat if t he cor r elat ion funct ions go significant ly out side t hese
confidence int er va ls, do not a ccept t he cor r esponding model a s a good
descr ipt ion of t he syst em. Some qualificat ions of t his st at ement ar e necessar y:
Model st r uct ur es like t he OE st r uct ur e (3.19) and met hods like t he IV
met hod (3.41) focus on t he dynamics G and less about t he noise pr oper t ies H.
If you ar e int er est ed pr imar ily in G, focus on t he independence of e a nd u
r at her t han t he whit eness of e.
Cor r elat ion bet ween e and u for negat ive lags, or cur r ent affect ing
fut ur e , is an indicat ion of out put feedback. This is not a r eason t o r eject
t he model. Cor r ela t ion at negat ive lags is of int er est , since cer t ain met hods
do not wor k well when feedba ck is pr esent in t he input -out put da t a, (see
e t ( )
u t ( )
3-53
Dealing wit h Dat a on page 3-58), but concent r at e on t he posit ive lags in t he
cr oss-cor r elat ion plot for model validat ion pur poses.
When using t he ARX model (3.15), t he least -squar es pr ocedur e
a ut omat ically ma kes t he cor r elat ion bet ween and zer o for
, , , for t he dat a used for t he est imat ion.
As par t of t he validat ion pr ocess, you ca n gr a ph t he r esiduals using
plot(e)
for a simple visual inspect ion of ir r egula r it ies and out lier s. (See also Dea ling
wit h Dat a on page 3-58.)
Noise-Free Simulations
To check whet her a model is capable of r epr oducing t he obser ved out put when
dr iven by t he act ual input , you can r un a simulat ion:
yh = idsim(u,th)
plot([y yh])
The same r esult is obt a ined by
compare([y,u],th)
It is a much t ougher a nd r evealing t est t o per for m t his simulat ion, as well as
t he r esidual t est s, on a fr esh dat a set [y u] t hat was not used for t he est imat ion
of t he model th. This is ca lled cross validat ion. (Not e t hat ivstruc for ms t he
squar ed differ ence of y and yh for IV-comput ed models th.)
Assessing the Model Uncertainty
The est imat ed model is always uncer t ain, due t o dist ur ba nces in t he obser ved
dat a, a nd due t o t he lack of an a bsolut ely cor r ect model st r uct ur e. The
var iabilit y of t he model t hat is due t o t he r andom dist ur bances in t he out put is
est imat ed by most of t he est imat ion pr ocedur es, and it can be displayed and
illuminat ed in a number of ways. This var iabilit y a nswer s t he quest ion of how
differ ent ca n t he model be if I r epeat t he ident ificat ion pr ocedur e, using t he
same model st r uct ur e, but wit h a differ ent dat a set t hat uses t he same input
sequence. It does not account for syst emat ic er r or s due t o an inadequat e choice
of model st r uct ur e. Ther e is no guar ant ee t hat t he t r ue syst em lies in t he
confidence int er val.
e t ( ) u t k ( )
k nk = nk 1 + nk nb 1 +
3 Tu to r i a l
3-54
The uncer t aint y in t he fr equency r esponse is calcula t ed wit h
[g,phiv] = th2ff(th)
and can subsequent ly be gr aphed wit h bodeplot. The uncer t aint y in t he t ime
r esponse is displayed by
idsimsd(u,th)
Ten possible models a r e dr awn fr om t he asympt ot ic dist r ibut ion of t he model
th. The r esponse of each of t hem t o t he input u is gr aphed on t he same dia gr a m.
The uncer t aint y of t hese r esponses concer ns t he ext er nal, input -out put
pr oper t ies of t he model. It r eflect s t he effect s of inadequat e excit at ion and t he
pr esence of dist ur bances.
You can also dir ect ly get t he st a ndar d deviat ion of t he simulat ed r esult by
[ysim,ysimsd] = idsim(u,th)
The uncer t aint y in int er nal r epr esent at ions is manifest ed in t he covar iance
mat r ix of t he est imat ed pa r amet er s,
present(th)
and in t he st anda r d deviat ions of t he pole- and zer o-locat ions, which ar e
comput ed wit h
zepo = th2zp(th)
and displayed using zpplot. Lar ge uncer t aint ies in t hese r epr esent a t ions ar e
caused by excessively high model or der s, inadequat e excit at ion, or bad
signal-t o-noise r at ios.
Comparing Different Models
It is a good idea t o display t he model pr oper t ies in t er ms of quant it ies t hat have
mor e physical meaning t han t he pa r amet er s t hemselves. Bode plot s, zer o-pole
plot s, and model simulat ions all give a sense of t he pr oper t ies of t he syst em
t hat have been picked up by t he model.
If sever al models of differ ent char act er s give ver y similar Bode plot s in t he
fr equency r ange of int er est , you can be fa ir ly confident t hat t hese must r eflect
feat ur es of t he t r ue, unknown syst em. You can t hen choose t he simplest model
among t hese.
3-55
A t ypical ident ificat ion session includes est imat ion in sever a l differ ent
st r uct ur es, and compar isons of t he model pr oper t ies. Her e is an example:
a1 = arx(z,[1 1]);
[gs,nss] = spa(z);
[ga1,nsa1] = th2ff(a1);
bodeplot([gs ga1])
bodeplot([nss nsa1])
zpa1 = th2zp(a1);
am2 = armax(z,[2 2 2 1]);
[gam2,nsam2] = th2ff(am2);
bodeplot([gs gam2])
zpam2 = th2zp(am2);
zpplot(zpform(zpa1,zpam2))
Conditioning of the Prediction Error Gradient
When t he model or der s in (3.23) ar e over est imat ed, so t hat a pole-zer o
ca ncellat ion can t ake place in t he model, t he pr edict ion er r or gr adient
t heor et ically becomes r ank deficient . The mat r ix t hat is inver t ed when
est imat ing t he covar iance mat r ix becomes singular , and t he Gauss-Newt on
sear ch dir ect ion becomes ambiguous.
Due t o t he high numer ic pr ecision in MATLAB, you ar e unlikely t o encount er
messages a bout singular and r a nk deficient mat r ices. Inst ead, over est imat ed
model or der s usually show up a s lar ge est ima t ed par amet er var iances and
lar ge nor ms of t he Gauss-Newt on vect or (alt hough only minor decr eases in t he
cr it er ion value r esult ). Consequent ly, t hese ar e good indicat or s t ha t you have
gone t oo far in incr easing t he model or der s. See also Some Special Topics on
page 3-68.
Selecting Model Structures for Multivariable
Systems
Mult iva r iable syst ems ar e oft en mor e difficult t o model. Some basic aspect s
and advice wer e given in The Basic St eps of Syst em Ident ificat ion on page
1-10. The gr aphical user int er fa ce (GUI) offer s par t icular ly useful suppor t for
t he mult ivar iable case. In t his sect ion we give some mor e t echnical comment s
about t he ident ifica t ion of mult ivar iable syst ems.
3 Tu to r i a l
3-56
The basic comment s given so fa r in t his sect ion also apply t o such syst ems.
Ther e ar e, however , a lar ge number of possible st r uct ur es for syst ems wit h
sever al out put s, and syst emat ic t est s of t he many possibilit ies a r e impr act ical.
This pr oblem is a difficult one, and for a mor e compr ehensive t r eat ment , r efer
t o Appendix 4.A of Ljung (1987).
Fir st of all, physical insight is mor e impor t ant t han anyt hing else. Whenever
t her e is pr ior knowledge sufficient t o for m physically par amet r ized st at e-spa ce
models, you should t est t hat . Even lacking mor e pr ecise knowledge, some
physical insight might help you t o come up wit h fir st suggest ions of or der s and
delays.
For mult i-out put black-box models, it is easiest t o fir st t r y st at e-space models
using n4sid for t he model est imat ion.
Mult ivar ia ble ARX models ar e also easy t o dea l wit h. When building such
models, a simple st ar t -up pr ocedur e is t o t r y arx wit h a st r uct ur e t hat is filled
wit h par a met er s. Then consider t hose est imat es t hat ar e of t he same
magnit ude as t heir st andar d deviat ions, a nd t r y or der s a nd delays t hat
aut omat ically set t hem t o zer o. Not e t hat for arx each r ow is est imat ed
independent ly of t he ot her s. Changing or der s and delays associa t ed wit h
out put number i (i.e. t he i-t h r ow of na, nb, a nd nk) does not cha nge t he
par amet er est imat es associa t ed wit h t he ot her r ows. When a r easonable
st r uct ur e has been found, t r y iv4 wit h it and evaluat e t he models in t he usua l
ways.
If t he signal t o noise level is not good, and it is impor t ant t o have models t hat
descr ibe t he noise char a ct er ist ics, t r y st a t e-space models. (These a r e
equivalent t o mult ivar iable ARMAX models.) Again, it is easier t o est imat e
st at e-space models dir ect ly wit hout specifying t he pa r t icula r st r uct ur e. This is
done using n4sid.
An alt er na t ive is t o apply t he pr edict ion er r or met hod using ca nonical
st at e-space for ms. These ar e obt ained by t he command canstart. This defines
a canonical for m st r uct ur e fr om t he pseudo-obser vabilit y indices. These indices
for m a vect or wit h t he sa me number of ent r ies as t he number of out put s.
Loosely speaking, index number k descr ibes how many delayed va lues of y
k

affect t he cur r ent value of y
k
. The sum of t he indices is equal t o t he or der of t he
3-57
syst em. The number of possible pseudo-obser vabilit y indices for a syst em of
or der n wit h p out put s is
It is, however , r eassur ing t o know t hat almost ever y syst em of or der n can be
descr ibed in a st r uct ur e cor r esponding t o a ny set of pseudo-obser vabilit y
indices whose sum is n. You can est imat e t he or der of t he syst em (or , r at her ,
t r y sever al differ ent or der s) and pick a ny set of pseudo-obser vabilit y indices
cor r esponding t o t hat or der . A default choice of indices can be made by
canstart if only t he or der is specified. Only if t he minimizat ion in pem shows
signs of poor condit ioning of t he involved mat r ices do you need t o t r y ot her
indices.
Not e t hat t he canonical for m par amet r izat ions cannot handle input delays. To
deal wit h specific delays fr om t he input (s), shift t he input sequences
accor dingly.
Also not e t hat wit h fixpar any canonical for m par a met er izat ion can be
t r ansfor med t o a cor r esponding out put -er r or st r uct ur e, by fixing t he mat r ix K
t o zer o.
n
p . ,
| `
3 Tu to r i a l
3-58
9. Dealing w ith Data
Ext r act ing infor ma t ion fr om da t a is not a n ent ir ely st r aight for wa r d t ask. In
addit ion t o t he decisions r equir ed for model st r uct ur e select ion and validat ion,
t he dat a may need t o be ha ndled car efully. This sect ion gives some a dvice on
handling sever a l common sit uat ions.
Offset Levels
When t he dat a have been collect ed fr om a physical plant , t hey ar e t ypically
measur ed in physical unit s. The levels in t hese r aw input s and out put s may not
mat ch in any consist ent way. This will for ce t he models t o wast e some
par amet er s cor r ect ing t he levels.
Offset s a r e easily dealt wit h; always subt r act t he mean levels fr om t he input
and out put sequences befor e t he est imat ion. It is best if t he mean levels
cor r espond t o a physical equilibr ium, but if such values ar e not known, use t he
sa mple means:
z = dtrend(z);
Sect ion 14.6 in Ljung (1987) discusses t his in mor e det a il. Wit h t he dtrend
comma nd, you can also r emove piece-wise linear t r ends.
Outliers
Real dat a ar e also subject t o possible bad dist ur bances; an unusually lar ge
dist ur bance, a t empor a r y sensor or t r ansmit t er failur e, et c. It is impor t ant t ha t
such out lier s ar e not allowed t o affect t he models t oo st r ongly.
The r obust ificat ion of t he er r or cr it er ion (descr ibed under lim in Opt ional
Var iables on page 3-26) helps her e, but it is always good pr act ice t o exa mine
t he r esiduals for unusually lar ge values, and t o go back and cr it ically evaluat e
t he or iginal dat a r esponsible for t he la r ge va lues. If t he r aw dat a ar e obviously
in er r or , t hey ca n be smoot hed, and t he est imat ion pr ocedur e r epea t ed.
Filtering Data
Depending upon t he applicat ion, int er est in t he model can be focused on
specific fr equency ba nds. Filt er ing t he da t a befor e t he est ima t ion, t hr ough
filt er s t hat enhance t hese bands, impr oves t he fit in t he int er est ing r egions.
This is used in t he Syst em Ident ificat ion Toolbox funct ion idfilt. For
3-59
example, t o enhance t he dat a in t he fr equency band bet ween 0.02
*
and
0.1
*
, execut e
zf = idfilt(z,5,[0.02 0.1]);
This comput es and uses a fift h or der But t er wor t h ba ndpass filt er wit h
passband bet ween t he indicat ed fr equencies. Chapt er 13 in Ljung (1987)
discusses t he r ole of filt er ing in mor e det a il.
The SITB cont ains ot her useful commands for r elat ed pr oblems. For exa mple,
if you want t o lower t he sampling r at e by a fact or of 5, use
z5 = idresamp(z,5);
Feedback in Data
If t he syst em was oper at ing in closed loop (feedback fr om t he past out put s t o
t he cur r ent input ) when t he da t a wer e collect ed, some car e ha s t o be exer cised.
Basically, all t he pr edict ion er r or met hods wor k equally well for closed-loop
dat a. Not e, however , t ha t t he Out put -Er r or model (3.19) and t he Box-J enkins
model (3.21) ar e nor mally capable of giving a cor r ect descr ipt ion of t he
dynamics G, even if H (which equa ls 1 for t he out put er r or model) does not
allow a cor r ect descr ipt ion of t he noise pr oper t ies. This is no longer t r ue for
closed-loop dat a. You t hen need t o model t he noise pr oper t ies car efully.
The spect r al analysis met hod and t he inst r ument a l va r iable t echniques (wit h
defa ult inst r ument s) give unr eliable r esult s when applied t o closed-loop da t a.
These t echniques should be avoided when feedba ck is pr esent .
To det ect if feedback is pr esent , use t he basic met hod of applying cra t o
est imat e t he impulse r esponse. Significant values of t he impulse r esponse a t
negat ive lags is a clea r indicat ion of feedback. When a par amet r ic model ha s
been est imat ed and t he resid command is applied, a gr aph of t he cor r elat ion
bet ween r esidua ls and input s is given. Significant cor r ela t ion at negat ive la gs
aga in indicat es out put feedback in t he gener at ion of t he input . Test ing for
feedba ck is, t her efor e, a nat ur al par t of model va lidat ion.
Delays
The select ion of t he delay nk in t he model st r uct ur e is a ver y impor t ant st ep in
obt aining good ident ificat ion r esult s. You can get an idea about t he delays in
t he syst em by t he impulse r esponse est imat e fr om cra.
3 Tu to r i a l
3-60
Incor r ect delays ar e also visible in par amet r ic models. Under est imat ed delays
(nk t oo small) show up a s small values of leading est imat es, compar ed t o
t heir st andar d deviat ions. Over est imat ed delays (nk t oo lar ge) ar e usually
visible as a significant cor r elat ion bet ween t he r esiduals and t he input a t t he
lags cor r esponding t o t he missing t er ms.
A good pr ocedur e is t o st ar t by using arxstruc t o t est a ll feasible delays
t oget her wit h a second-or der model. Use t he dela y t hat gives t he best fit for
fur t her modeling. When you have found an ot her wise sa t isfact or y st r uct ur e,
va r y nk ar ound t he nomina l value wit hin t he st r uct ur e, and eva luat e t he
r esult s.
b
k
b
k
3-61
10. Recursive Parameter Estimation
In ma ny cases it may be necessar y t o est imat e a model on line a t t he same t ime
as t he input -out put da t a is r eceived. You may need t he model t o make some
decision on line, as in adapt ive cont r ol, adapt ive filt er ing, or adapt ive
pr edict ion. It may be necessar y t o invest igat e possible t ime var iat ion in t he
syst ems (or signals) pr oper t ies dur ing t he collect ion of dat a. Ter ms like
recursive identificat ion, adaptive parameter est imation, sequent ial est imation,
and online algorithms ar e used for such algor it hms. Chapt er 11 in Ljung (1987)
deals wit h such algor it hms in some det ail.
The Basic Algorithm
A t ypical r ecur sive ident ifica t ion algor it hm is
Her e is t he pa r amet er est imat e at t ime t , and is t he obser ved out put
at t ime t . Mor eover , is a pr edict ion of t he value based on obser vat ions
up t o t ime and also based on t he cur r ent model (a nd possibly also ear lier
ones) at t ime . The gain det er mines in what way t he cur r ent
pr edict ion er r or affect s t he upda t e of t he par amet er est imat e. It is
t ypically chosen as
wher e is (an appr oximat ion of) t he gr adient wit h r espect t o of .
The lat t er symbol is t he pr edict ion of accor ding t he model descr ibed by .
Not e t hat model st r uct ur es like AR and ARX t hat cor r espond t o linear
r egr essions can be wr it t en as
wher e t he regression vect or cont ains old values of obser ved input s and
out put s, and r epr esent s t he t r ue descr ipt ion of t he syst em. Mor eover ,
is t he noise sour ce (t he innovat ions). Compar e wit h (3.15). The nat ur al
pr edict ion is and it s gr adient wit h r espect t o becomes
exact ly .

t ( )

t 1 ( ) K t ( ) y t ( ) y

t ( ) ( ) + = (10.1)

t ( ) y t ( )
y

t ( )
y t ( )
t 1
t 1 K t ( )
y t ( ) y t ( )
K t ( ) Q t ( ) t ( ) = (10.2)
t ( ) y t ( )
y t ( )
y t ( )
T
t ( )
0
t ( ) e t ( ) + =
(10.3)
t ( )

0
t ( )
e t ( )
y t ( )
T
t ( ) t 1 ( ) =
t ( )
3 Tu to r i a l
3-62
For models t hat cannot be wr it t en as linear r egr essions, you cannot r ecur sively
comput e t he exact pr edict ion a nd it s gr adient for t he cur r ent est imat e .
Then appr oximat ions and must be used inst ead. Sect ion 11.4 in
Ljung (1987) descr ibes suit able ways of comput ing such a ppr oximat ions for
gener al model st r uct ur es.
The mat r ix t hat affect s bot h t he adapt at ion gain and t he dir ect ion in
which t he updat es ar e made, can be chosen in sever al differ ent wa ys. This is
discussed in t he following sect ion.
Choosing an Adaptation Mechanism and Gain
The most logical a ppr oach t o t he adapt at ion pr oblem is t o assume a cer t a in
model for how t he t r ue par amet er s cha nge. A t ypica l choice is t o descr ibe
t hese par amet er s as a r a ndom walk:
Her e is assumed t o be whit e Gaussian noise wit h covar ia nce mat r ix

t 1 ( )
y t ( ) t ( )
Q t ( )

0
t ( )
0
t 1 ( ) w t ( ) + = (10.4)
w t ( )
Ew t ( )w
T
t ( ) R
1
= (10.5)
3-63
Suppose t hat t he under lying descr ipt ion of t he obser vat ions is a linea r
r egr ession (10.3). An opt ima l choice of in (10.1)-(10.2) can t hen be
comput ed fr om t he Kalman filt er , and t he complet e a lgor it hm becomes
Her e is t he var iance of t he innovat ions in (10.3): (a scalar ).
The algor it hm (10.6) will be called t he Kalman Filt er (KF) Appr oach t o
adapt at ion, wit h drift mat rix . See eq (11.66)-(11.67) in Ljung (1987). The
algor it hm is ent ir ely specified by , , , , and t he sequence of dat a
, , , 2,. Even t hough t he algor it hm was mot ivat ed for a linear
r egr ession model st r uct ur e, it can also be applied in t he gener al case wher e
is comput ed in a differ ent way fr om (10.6b).
Anot her appr oach is t o discount old measur ement s exponent ially, so t hat a n
obser vat ion t hat is samples old car r ies a weight t ha t is of t he weight of
t he most r ecent obser vat ion. This means t hat t he following funct ion is
minimized r at her t han (3.39):
at t ime t. Her e is clear ly is a posit ive number 1. The measur ement s t hat
ar e older t han car r y a weight in (10.7) t ha t is less t han about 0.3.
Think of a s t he memory horizon of t he a ppr oach. Typica l values
of ar e in t he r ange 0.97 0.995.
Q t ( )

t ( )

t 1 ( ) K t ( ) y t ( ) y t ( ) ( ) + =
y t ( )
T
t ( )

t 1 ( ) =
K t ( ) Q t ( ) t ( ) =
Q t ( )
P t 1 ( )
R
2
t ( )
T
P t 1 ( ) t ( ) +
--------------------------------------------------------- =
P t ( ) P t 1 ( ) R
1
P t 1 ( ) t ( ) t ( )
T
P t 1 ( )
R
2
t ( )
T
P t 1 ( ) t ( ) +
----------------------------------------------------------------- + =
(10.6a)
(10.6b)
(10.6c)
(10.6d)
(10.6e)
R
2
e t ( ) R
2
Ee
2
t ( ) =
R
1
R
1
R
2
P 0 ( ) 0 ( )
y t ( ) t ( ) t 1 =
y t ( )

t k
e
2
k ( )
k 1 =
t

(10.7

1 1 ( ) =
1 1 ( ) =

3 Tu to r i a l
3-64
The cr it er ion (10.7) can be minimized exact ly in t he linear r egr ession case
giving t he algor it hm (10.6abc) wit h t he following choice of :
This algor it hm will be called t he For get t ing Fact or (FF) Appr oach t o
adapt a t ion, wit h t he forget ting fact or . See eq (11.63) in Ljung (1987). The
algor it hm is also known as RLS, recursive least squares in t he linear r egr ession
case. Not e t hat in t his appr oach gives t he same algor it hm as
in t he Ka lman filt er appr oach.
A t hir d appr oach is t o allow t he mat r ix t o be a mult iple of t he ident it y
mat r ix:
It ca n also be nor malized wit h r espect t o t he size of :
See eqs (11.45) a nd (11.46), r espect ively in Ljung (1987). These choices of
move t he upda t es of in (10.1) in t he nega t ive gr adient dir ect ion (wit h r espect
t o ) of t he cr it er ion (3.39). Ther efor e, (10.9) will be called t he Unnor malized
Gr adient (UG) Appr oach and (10.10) t he Nor malized Gr adient (NG) Appr oach
t o a da pt at ion, wit h gain . The gr a dient met hods ar e also known as LMS, least
mean squares in t he linear r egr ession case.
Q t ( )
Q t ( ) P t ( )
P t 1 ( )
t ( )
T
P t 1 ( ) t ( ) +
------------------------------------------------------ = =
P t ( )
P t 1 ( )
P t 1 ( ) t ( ) t ( )
T
P t 1 ( )
t ( )
T
P t 1 ( ) t ( ) +
---------------------------------------------------------------- -
. ,

| `
=
(10.8a)
(10.8b)

1 =
R
1
0 R
2
, 1 = =
Q t ( )
Q t ( ) I =
(10.9)

Q t ( )

t ( )
2
----------------I =
(10.10)
Q t ( )

3-65
Available Algorithms
The Syst em Ident ificat ion Toolbox pr ovides t he following funct ions t hat
implement all common r ecur sive ident ifica t ion algor it hms for model st r uct ur es
in t he family (6.1): rarmax, rarx, rbj, rpem, rplr, and roe. They all shar e t he
following basic synt ax:
[thm,yh] = rfcn(z,nn,adm,adg)
Her e z cont a ins t he out put -input da t a as usual. nn specifies t he model
st r uct ur e, exact ly as for t he cor r esponding offline a lgor it hm. The ar gument s
adm a nd adg select t he adapt at ion mechanism and adapt at ion gain list ed above.
adm = 'ff'; adg = lam
gives t he for get t ing fact or algor it hm (10.8), wit h for get t ing fa ct or lam.
adm = 'ug'; adg = gam
gives t he unnor malized gr adient appr oach (10.9) wit h gain gam. Similar ly,
adm = 'ng'; adg = gam
gives t he nor malized gain appr oach (10.10). To obt ain t he Kalman filt er
appr oach (10.6) wit h dr ift mat r ix R1 ent er
adm = 'kf'; adg = R1
The value of is a lways 1. Not e t hat t he est imat es in (10.6) ar e not affect ed
if a ll t he ma t r ices and ar e sca led by t he same number . You can
t her efor e always scale t he or iginal pr oblem so t hat becomes 1.
The out put ar gument thm is a mat r ix t hat cont ains t he cur r ent models at t he
differ ent samples. Row k of thm cont ains t he model par amet er s, in alphabet ical
or der at sample t ime k, cor r esponding t o r ow k in t he dat a mat r ix z. The
or der ing of t he par amet er s is t he sa me as th2par would give when applied t o
t he t het a for mat of a cor r esponding offline model.
The out put ar gument yh is a column vect or t hat cont ains, in r ow k, t he
pr edict ed va lue of , based on past obser va t ions and cur r ent model. The
vect or yh t hus cont ains t he adapt ive pr edict ions of t he out put s, and is useful
also for noise cancelling and ot her adapt ive filt er ing applicat ions.
The funct ions also have opt ional input ar gument s t hat allow t he specificat ion
of , and . Opt ional out put ar gument s include t he last value of
t he mat r ix P and of t he vect or .
R
2

R
1
R
2
, P 0 ( )
R
2
y k ( )
0 ( ) P 0 ( ) , 0 ( )

3 Tu to r i a l
3-66
Now, rarx is a r ecur sive var iant of arx; similar ly rarmax is t he r ecur sive
count er par t of armax and so on. Not e, t hough t hat rarx does not ha ndle
mult i-out put syst ems, and rpem does not handle st at e-spa ce st r uct ur es.
The funct ion rplr is a var iant of rpem, and uses a differ ent appr oximat ion of
t he gr adient . It is known as t he recursive pseudo-linear regression approach,
and cont ains some well known special cases. See equat ion (11.57) in Ljung
(1987). When applied t o t he out put er r or model (nn=[0 nb 0 0 nf nk]) it
r esult s in met hods known as HARF ('ff'case) and SHARF ('ng'case). The
common extended least squares (ELS) met hod is a n rplr algor it hm for t he
ARMAX model (nn=[na nb nc 0 0 nk]).
The following example shows a second or der out put er r or model, which is built
r ecur sively and it s t ime var ying par amet er est ima t es plot t ed as funct ions of
t ime:
thm = roe(z,[2 2 1],'ff',0.98);
plot(thm)
A second or der ARMAX model is r ecur sively est imat ed by t he ELS met hod,
using Kalman filt er a da pt at ion. The r esult ing st at ic gains of t he est ima t ed
models ar e t hen plot t ed as a funct ion of t ime:
[N,dum]=size(z);
thm = rplr(z,[2 2 2 0 0 1],'kf',0.01eye(6));
nums = sum(thm(:,3:4)')';
dens = ones(N,1)+sum(thm(:,1:2)')';
stg = nums./dens;
plot(stg)
So far , t he examples of applicat ions wher e a bat ch of dat a is examined cover
st udies of t he va r iabilit y of t he syst em. The algor it hms ar e, however , also
pr epar ed for t r ue online applicat ions, wher e t he comput ed model is used for
some online decision. This is accomplished by st or ing t he updat e infor mat ion
in and infor mat ion about past da t a in (and )
and using t hat infor mat ion a s init ial dat a for t he next t ime st ep. The following
example shows t he r ecur sive least -squar es algor it hm being used on line (just
t o plot one cur r ent par amet er est imat e):
%Initialization, first i/o pair y,u (scalars)
[th,yh,P,phi] = rarx([y u],[2 2 1],'ff',0.98);
axis([1 50 2 2])
plot(1,th(1),''),hold

t 1 ( ) P t 1 ( ) , t 1 ( ) t 1 ( )
3-67
%The online loop:
for k = 2:50
% At time k receive y,u
[th,yh,P,phi] = ...
rarx([y u],[2 2 1],'ff',0.98,th',P,phi);
plot(k,th(1),'')
end
Execut ing iddemo 6 illust r a t es t he r ecur sive a lgor it hms.
Segmentation of Data
Somet imes t he syst em or signal exhibit s abr upt changes dur ing t he t ime when
t he dat a is collect ed. It may be impor t ant in cer t ain applicat ions t o find t he
t ime inst ant s when t he changes occur and t o develop models for t he differ ent
segment s dur ing which t he syst em does not change. This is t he segment ation
problem. Fault det ect ion in syst ems a nd det ect ion of t r end br eaks in t ime
ser ies can ser ve as t wo examples of t ypical pr oblems.
The Syst em Ident ificat ion Toolbox offer s t he funct ion segment t o deal wit h t he
segment at ion pr oblem. The ba sic synt ax is
thm = segment(z,nn)
wit h a for mat like rarx or rarmax. The mat r ix thm cont ains t he piecewise
const ant models in t he same for mat as for t he algor it hms descr ibed ear lier in
t his sect ion.
The algor it hm t hat is implement ed in segment is based on a model descr ipt ion
like (10.4), wher e t he change t er m is zer o most of t he t ime, but now and
t hen it a br upt ly changes t he syst em par amet er s . Sever a l Kalman filt er s
t hat est imat e t hese par amet er s ar e r un in pa r allel, each of t hem cor r esponding
t o a par t icular a ssumpt ion about when t he syst em act ually changed. The
r elat ive r eliabilit y of t hese assumed syst em behavior s is const ant ly judged, a nd
unlikely hypot heses ar e r eplaced by new ones. Opt ional a r gument s allow t he
specificat ion of t he measur ement noise var iance in (10.3), of t he pr oba bilit y
of a jump, of t he number of par a llel models in use, and also of t he gua r ant eed
lifespan of each hypot hesis. See iddemo 7 in Chapt er 4, "Command Refer ence"
also.
w t ( )

0
t ( )
R
2
3 Tu to r i a l
3-68
11. Some Special Topics
This sect ion descr ibes a number of miscellaneous t opics. Most of t he
infor mat ion her e is a lso cover ed in ot her par t s of t he manual, but since
manuals seldom ar e r ea d fr om t he beginning, you can also check if a par t icular
t opic is br ought up her e.
Time Series Modeling
When t her e is no input pr esent , t he gener al model (6.1) r educes t o t he ARMA
model st r uct ur e:
Wit h you have an AR model st r uct ur e.
Basically all commands st ill apply t o t hese t ime ser ies models, but wit h na t ur al
modifica t ions. They ar e list ed as follows:
th = poly2th(A,[],C,1,[],lam)
y = idsim(e,th)
Spect r al analysis (etfe and spa) a nd t he th2ff funct ion now r et ur n t he
spect r al est imat e of y as t heir fir st out put ar gument s:
PHIY = th2ff(th)
PHIY = spa(y)
PERIOD = etfe(y)
Not e t hat etfe gives t he periodogram est imat e of t he spect r um.
armax a nd arx wor k t he same way, but need no specificat ion of nb and nk:
th = arx(y,na)
th = armax(y,[na nc])
Not e t hat arx also handles mult ivar iat e signals. St at e-spa ce models of t ime
ser ies can be built simply by specifying B = [], D = [] in modstruc, mf2th, and
ms2th. resid wor ks t he same wa y for t ime ser ies models, but does not pr ovide
any input -r esidual cor r elat ion plot s:
e = resid(y,th)
A q ( )y t ( ) C q ( )e t ( ) =
(11.1)
C q ( ) 1 =
3-69
In addit ion t her e a r e t wo commands t hat ar e specifically const r uct ed for
building scalar AR models of t ime ser ies. One is
th = ar(y,na)
which has an opt ion t hat a llows you t o choose t he algor it hm fr om a gr oup of
sever al popular t echniques for comput ing t he least -squar es AR model. Among
t hese ar e Bur gs met hod, a geomet r ic lat t ice met hod, t he Yule-Walker
appr oach, a nd a modified covar iance met hod. See Chapt er 4, "Command
Refer ence" for det ails. The ot her command is
th = ivar(y,na)
which uses an inst r ument a l var ia bles t echnique t o comput e t he AR par t of a
t ime ser ies.
Finally, when no input is pr esent , t he funct ions bj, iv, iv4, a nd oe ar e not
defined.
Her e is an example wher e you ca n simulat e a t ime ser ies, compar e spect r al
est imat es a nd covar iance funct ion est imat es, and also t he pr edict ions of t he
model.
ts0 = poly2th([1 1.5 0.7],[]);
% The true spectrum:
spe0 = th2ff(ts0);
ir = idsim([1;zeros(24,1)],ts0);
% The true covariance function:
Ry0 = conv(ir,ir(25:1:1));
e = randn(200,1);
y = idsim(e,ts0);
plot(y)
per = etfe(y);
speh = spa(y);
ffplot([per,speh,spe0])
% A second order AR model:
ts2 = ar(y,2);
sp2 = th2ff(ts2);
ffplot([speh,sp2,spe0,3])
% The covariance function estimates:
Ryh = covf(y,24);
ir2 = idsim([1;zeros(24,1)],ts2);
Ry2 = conv(ir2,ir2(25:1:1));
3 Tu to r i a l
3-70
plot([24:24]ones(1,3),[Ryh,Ry2,Ry0])
% The prediction ability of the model:
compare(y,th2,5)
The Sampling Interval
The Syst em Ident ificat ion Toolbox assumes a nor malized sampling int er val of
, unless you specify ot her wise. This means t hat t he fr equency unit
becomes r adians per sampling int er val, and t hat all t he t r ansfor mat ions
bet ween cont inuous- and discr et e-t ime models give numer ical par amet er
va lues cor r esponding t o t he unit ... per sampling int er val r a t her t han ... per
second. To obt ain cor r ect physical unit s in t hese cases, t he sampling int er val
must be specified accor dingly.
All models in t he t het a for ma t cont ain t he sampling int er val T as t he (1,2)
element . It can be r ead by
T = gett(th)
and it is changed by
thnew = sett(thold,T)
Not e t hat t he va lue of T is just changed; no t r ansfor mat ion of par amet er s is
car r ied out by sett.
A nega t ive value of T indicat es t hat t he cor r esponding model is given in
cont inuous t ime. The absolut e value of T denot es, in t hat case, t he sampling
int er val of t he dat a, for which t his model was est imat ed. This is also t he
sa mpling int er val used when t he model is used for simulat ion or pr edict ion. All
ot her t r ansfor mat ions (t o t he fr equency funct ion, t o poles a nd zer os, t o t r a nsfer
funct ions and t o st at e-space mat r ices) will be in t er ms of t he cont inuous-t ime
model. In t he ca se of th2ff, abs(T) is used for t he default choice of fr equency
r ange.
You can specify t he sampling int er val as an opt ional ar gument in all t he
funct ions t ha t cr eat e t het a st r uct ur es. It is gener ally t he last ar gument . Not e
t hat in ms2th and mf2th, it is t he sampling int er va l of t he dat a t hat you need
t o specify, even if t he model it self in par amet r ized in cont inuous t ime. If t he
init ial st r uct ur e in pem, armax, bj, a nd oe is given by a mat r ix th in t he t het a
for mat , t he defa ult value of T is t he one given by th. An explicit ly given
sa mpling int er val (as an a r gument t o pem, for example) over r ides t he default
va lue in th.
T 1 =
3-71
The sampling int er val T is also used by etfe, spa, and th2ff t o det er mine
defa ult fr equency r anges. For discr et e-t ime syst ems, t his default is [1:128]/
128
*
pi/T and for cont inuous-t ime syst ems, it is
logspa ce(log10(pi/abs(T)/100),log10(10
*
pi/abs(T)),128).
Discr et e-t ime default fr equency r anges can be changed by sett, like in
g = spa(z);
g = sett(g,T);
Out of Memory
If you r un out of memor y on comput er s wit h memor y limit at ions, clear
unnecessar y var iables and use t he pack funct ion. When you ar e using t he
it er at ive pr ocedur es armax, bj, oe, and pem, it is a good idea t o use pack t o
clean up a ft er t he st ar t -up est imat ion pr ocedur e using, for example
th = armax(z,nn,0);
pack
th = armax(z,th);
All t he r eleva nt Syst em Ident ificat ion Toolbox funct ions have an opt ional
var iable MAXSIZE t hat cont r ols t he memor y/speed t r ade-off and is set
aut omat ica lly, ba sed upon t he best values for t he machine you ar e using. The
r out ines do not a llow any mat r ix of size lar ger t han MAXSIZE t o for m. Inst ead
t hey go int o for -loops t o handle t he sit uat ion.
The default value of MAXSIZE is set in t he M-file idmsize. Theor et ica lly,
MAXSIZE is 8188 on t he smaller machines, but since ma ny mat r ices may for m,
it best t o set t he default value for t hese machines t o MAXSIZE = 4096.
If you have memor y pr oblems, you ca n use t he ar gument MAXSIZE, or edit
idmsize, wit h values lower t han t he default .
If you ha ve a lar ge amount of input -out put dat a, so t hat t he memor y delimit er
gives you a slower r esponse, use a por t ion of t he dat a t o calculat e a good init ia l
condit ion for t he minimizat ion, for exa mple
th = armax(z(1:500,:),[na nb nc],10,0.1);
th = armax(z,th);
3 Tu to r i a l
3-72
On a small machine, if you ha ve collect ed mor e t han 8188 da t a point s so t hat
you cannot for m z=[y u], no memor y help is offer ed. You t hen have t o build
separ at e models for separ at e par t s of t he dat a and r econcile t he models.
Memory-Speed Trade-Offs
On machines wit h no for mal memor y limit at ions, it is st ill of int er est t o
monit or t he sizes of t he mat r ices t hat ar e for med. The t ypical sit uat ion is when
an over det er mined set of linear equat ions is solved for t he lea st -squar es
solut ion. The solut ion t ime depends, of cour se, on t he dimensions of t he
cor r esponding mat r ix. The number of r ows cor r esponds t o t he number of
obser ved dat a, while t he number of columns cor r esponds t o t he number of
est imat ed par amet er s. The a r gument MAXSIZE used wit h all t he r elevant
M-files, guar ant ees t hat no mat r ix wit h mor e t han MAXSIZE element s is for med.
Lar ger dat a set s and/or higher or der models ar e handled by for -loops. For -loops
give linear incr ea se in t ime when t he dat a r ecor d is incr eased, plus some
over head (a nd somewhat wor se numer ica l pr oper t ies).
If you r egular ly wor k wit h lar ge dat a set s and/or high or der models, it is
advisable t o t ailor t he memor y and speed t r ade-off t o your machine by choosing
t he default value of MAXSIZE in t he M-file idmsize car efully. Not e t hat t his
va lue is allowed t o depend on t he number of r ows a nd columns of t he mat r ices
for med.
Regularization
The Gauss-Newt on dir ect ion is usually defined as
wher e is t he gr adient ma t r ix of t he pr edict ions wit h r espect t o t he
par amet er s, and e is t he vect or of r esiduals.
When t he inver t ed mat r ix is ill-condit ioned, you can add a sma ll fr act ion of t he
ident it y mat r ix t o it . This is called regularizat ion. See Ljung (1987), Sect ion
10.2.
The r out ines in t he Syst em Ident ificat ion Toolbox comput e t he Gauss-Newt on
dir ect ion wit h
g=psi\e
gn

( )
1
= *
*
*e
N n
N 1
3-73
which uses t he MATLAB mechanism for dealing wit h under det er mined,
over det er mined syst ems of equat ions. An adva nced ver sion of r egular izat ion is
t hus aut oma t ica lly included.
Because of t he high pr ecision of MATLAB, r egular izat ion is not invoked easily.
You may see some ver y lar ge norm of gnvector values befor e you see t he
MATLAB message t hat t he mat r ix is r ank deficient .
A lar ge va lue for t he gnvector suggest s t hat you decr ease t he model or der s.
However , if you ar e int er est ed in how t he r egular iza t ion wor ks, you can
decr ea se t he value of t he machine epsilon. For example, set
eps = 0.000001
and r un t he ident ificat ion a gain.
Local Minima
The it er at ive sear ch pr ocedur es in pem, armax, oe, and bj lead t o t het a values
cor r esponding t o a local minimum of t he cr it er ion funct ion (3.39). Not hing
guar ant ees t hat t his local minimum is also a global minimum. The st ar t -up
pr ocedur e for black-box models in t hese r out ines is, however , r easonably
efficient in giving init ial est imat es t hat lead t o t he global minimum.
If t her e is an indicat ion t hat a minimum is not as good as you expect ed, t r y
st a r t ing t he minimizat ion at sever al differ ent init ial condit ions, t o see if a
smaller value of t he loss funct ion can be found.
Initial Parameter Values
When only or der s and delays ar e specified, t he funct ions armax, bj, oe, a nd pem
use a st ar t -up pr ocedur e t o pr oduce init ial values. The st ar t -up pr ocedur e goes
t hr ough t wo t o four lea st squar es and inst r ument a l var ia bles st eps. It is
r easonably efficient in t ha t it usua lly saves sever al it er a t ions in t he
minimizat ion pha se. Somet imes it may, however , pay t o use ot her init ial
condit ions. For example, you ca n use an iv4 est imat e comput ed ear lier as an
init ial condit ion for est imat ing an out put -er r or model of t he sa me st r uct ur e:
th1 = iv4(z,[na nb nk]);
[a,b] = th2poly(th1);
th2 = poly2th(1,b,1,1,a);
th3 = oe(z,th2);
3 Tu to r i a l
3-74
Anot her example is when you want t o t r y a model wit h one mor e delay (for
example, t hr ee inst ead of t wo) because t he leading b-coefficient is quit e small:
th1 = armax(z,[3 3 2 2]);
[a,b,c] = th2poly(th1);
b(3) = 0;
th2 = poly2th(a,b,c);
th3 = armax(z,th2);
If you decr ease t he number of delays, r emember t hat poly2th st r ips away
leading zer os. Suppose you go fr om t hr ee t o t wo delays in t he a bove exa mple:
th1 = armax(z,[3 3 2 3]);
[a,b,c] = th2poly(th1);
b(3) = 0.00001;
th2 = poly2th(a,b,c);
th3 = armax(z,th2);
Not e t hat when const r uct ing home-made init ial condit ions, t he condit ions
must cor r espond t o a st able pr edict or (C and F being Hur wit z polynomials),
and t hat t hey should not cont ain any exact pole-zer o cancellat ions.
For st at e-space and mult i-out put models, you must pr ovide t he init ia l
par amet er values eit her when defining t he st r uct ur e in ms2th or mf2th, or wit h
t he special init ializat ion funct ion thinit. The basic appr oach is t o use physical
insight t o choose init ial values of t he pa r amet er s wit h physical significa nce,
and t r y some differ ent (r andomized) init ial values for t he ot her s. For models
par amet r ized in ca nonical st at e-spa ce for m, use canstart t o get st ar t ed.
Linear Regression Models
A linear r egr ession model is of t he t ype
wher e and ar e measur ed var iables and r epr esent s noise. Such
models ar e ver y useful in most applicat ions. They allow, for example, t he
inclusion of nonlinea r effect s in a simple way. The Syst em Ident ifica t ion
Toolbox funct ion arx allows an ar bit r a r y number of input s. You ca n t her efor e
handle ar bit r ar y linear r egr ession models wit h arx. For example, if you want
t o build a model of t he t ype
y t ( )
T
t ( ) e t ( ) + =
(11.2)
y t ( ) t ( ) e t ( )
3-75
ca ll
z = [y ones(u) u u.^2 u.^3];
th = arx(z,[0 1 1 1 1 0 0 0 0])
This is for mally a model wit h one out put and four input s, but all t he model
t est ing in t er ms of compare, idsim, and resid oper at e in t he nat ur al way for
t he model (11.2), once t he dat a mat r ix z is defined as above.
Not e t hat when pem is applied t o linear r egr ession st r uct ur es, by default a
r obust ified quadr at ic cr it er ion is used. The sear ch for a minimum of t he
cr it er ion funct ion is car r ied out by it er at ive sear ch. Nor mally, use t his
r obust ified cr it er ion. If you insist on a quadr at ic cr it er ion, t hen set t he
ar gument lim in pem t o zer o. Then pem also conver ges in one st ep.
Spectrum Normalization and the Sampling Interval
In t he funct ion spa t he spect r um est imat e is nor malized wit h t he sampling
int er val T as
wher e
(See also (3.3)). The nor malizat ion in etfe is consist ent wit h (11.4). This
nor malizat ion means t ha t t he unit of is power per r a dians/t ime unit
and t hat t he fr equency scale is r adians/t ime unit . You t hen have
y t ( ) b
0
b
1
u t ( ) b
2
u
2
t ( ) b
3
u
3
t ( ) + + + = (11.3)

y
( ) T R

y
k M =
M

= kT ( )e
i T
W
M
k ( )
(11.4)
R

y kT ( )
1
N
--- - y lT kT ( )y lT ( )
l 1 =
N

y
( )
Ey
2
t ( )
1
2
------
y
w ( ) w d
T
T

=
(11.5)
3 Tu to r i a l
3-76
In MATLAB language, t her efor e, you have wher e
sp = spa(y); sp = sett(sp,T);
[om,PHIY] = getff(sp);
S1 = sum(PHIY)/length(PHIY)/T;
S2 = sum(y.^2)/length(y);
Not e t hat PHIY cont ains bet ween and wit h a fr equency
st ep of / T / (length(PHIY)). The sum S 1 is, t her efor e, t he r ect a ngular
appr oximat ion of t he int egr al in (11.5). The spect r um nor malizat ion differ s
fr om t he one used by spectrum in t he Signal Pr ocessing Toolbox, and t he above
example shows t he nat ur e of t he differ ence.
The nor malizat ion wit h T in (11.4) also gives consist ent r esult s when t ime
ser ies ar e decimat ed. If t he ener gy a bove t he Nyquist fr equency is r emoved
befor e decimat ion (as is done in idresamp), t he spect r al est imat es coincide;
ot her wise you see folding effect s.
Tr y t he following sequence of commands:
th0 = poly2th(1,[],[1 1 1 1]);
% 4th order MAprocess
y = idsim(randn(2000,1),th0);
g1 = spa(y);
g2 = spa(y(1:4:2000));g2 = sett(g2,4);
ffplot([g1 g2]) % Folding effects
g3 = spa(idresamp(y,4)); % Prefilter applied
g3 = sett(g3,4);
ffplot([g1 g3]) % No folding
For a pa r amet r ic noise (t ime ser ies) model
t he spect r um is comput ed as
which is consist ent wit h (11.4) and (11.5). Think of as t he spect r al densit y
of t he whit e noise sour ce .
When a par amet r ic noise model is t r a nsfor med bet ween cont inuous t ime and
discr et e t ime and/or r esampled at anot her sampling r at e, t he funct ions
S1 S2

y
( ) 0 = T =
y t ( ) H q ( )e t ( ) =
Ee
2
t ( ) =
y w ( ) T H e
i wt
( )
2
=
(11.6)
T
e t ( )
3-77
thc2thd and thd2thc in t he Syst em Ident ificat ion Toolbox use for mulas t hat
ar e for mally cor r ect only for piecewise const ant input s. (See (3.32)). This
appr oximat ion is good when T is small compar ed t o t he bandwidt h of t he noise.
Dur ing t hese t r ansfor mat ions t he var ia nce of t he innova t ions is
changed so t ha t t he spect r al densit y T
.
r emains const ant . This has t wo
effect s:
The spect r um scalings ar e consist ent , so t hat t he noise spect r um is
essent ia lly invar ia nt (up t o t he Nyquist fr equency) wit h r espect t o
r esampling.
Simula t ions wit h noise using idsim has a higher noise level when per for med
a t fast er sampling.
This lat t er effect is well in line wit h t he st andar d descr ipt ion t hat t he
under lying cont inuous-t ime model is subject t o cont inuous-t ime whit e noise
dist ur ba nces (which have infinit e, inst ant aneous var iance), and appr opr iat e
low-pass filt er ing is applied befor e sampling t he measur ement s. If t his effect is
unwant ed in a par t icular applicat ion, scale t he noise sour ce a ppr opr iat ely
befor e a pplying idsim.
Not e t he following caut ions r elat ing t o t hese t r ansfor mat ions of noise models.
Cont inuous-t ime noise models must have a whit e noise component . Ot her wise
t he under lying st at e-space model, which is for med and used in thc2thd and
thd2thc, is ill-defined. War nings about t his ar e issued by poly2th and t hese
funct ions. Modify t he C-polynomial accor dingly. Make t he degr ee of t he monic
C-polynomia l in cont inuous t ime equal t o t he sum of t he degr ees of t he monic
A- and D-polynomials; i.e., in cont inuous t ime
length(C)1 = (length(A)1)+(length(D)1).
Interpretation of the Loss Function
The value of t he quadr a t ic loss funct ion is given as element 1,1 in t he t het a
for mat , and a lso displayed by present. For mult i-out put syst ems, t his is equal
t o t he det er mina nt of t he est ima t ed covar iance mat r ix of t he innovat ions.
For most models t he est imat ed covar iance ma t r ix of t he innovat ions is obt ained
by for ming t he cor r esponding sample mean of t he pr edict ion er r or s, comput ed
(using pe) fr om t he model wit h t he dat a for which t he model was est imat ed.
e t ( )

3 Tu to r i a l
3-78
Not e t he discr epancy bet ween t his value and t he va lues shown dur ing t he
minimizat ion pr ocedur e (in pem, armax, bj, or oe, since t hese ar e t he values of
t he robustified loss funct ion (see under lim in Sect ion 5).
Be car eful when compa r ing loss funct ion values bet ween differ ent st r uct ur es
t hat use ver y differ ent noise models. An Out put -Er r or model ma y have a bet t er
input -out put fit , even t hough it displays a higher value of t he loss funct ion
t han, say, a n ARX model.
Not e t hat for ARX models comput ed using iv4, t he covar iance mat r ix of t he
innovat ions is est ima t ed using t he pr ovisional noise model t hat is used t o for m
t he opt imal inst r ument s. The loss funct ion t her efor e differ s fr om what would
be obt ained if you comput ed t he pr edict ion er r or s using t he model dir ect ly fr om
t he dat a . It is st ill t he best available est imat e of t he innovat ions covar iance. In
par t icular , it is difficult t o compar e t he loss funct ion in an ARX model
est imat ed using arx and one est imat ed using iv4.
Enumeration of Estimated Parameters
In some ca ses t he par amet er s of a model ar e given just as an or der ed list . This
is t he case for th2par, and also when online infor mat ion fr om t he minimizat ion
r out ines ar e given. Fur t her mor e, in ms2th, you ar e asked t o give a list of
nominal/init ial par amet er values. In t hese cases it is impor t ant t o know in
what or der t he par amet er ar e list ed. The basic t hr ee cases ar e as follows:
For t he input -out put model (3.23) or it s mult i-input var iant (5.2), you have
t he following a lphabet ical or der ing
Her e super scr ipt r efer s t o t he input number .
For a st at e-space st r uct ur e, defined by ms2th, t he par amet er s in pars ar e
obt ained in t he following or der . The A mat r ix is fir st scanned r ow by r ow for
fr ee par amet er s. Then t he B mat r ix is scanned r ow by r ow, a nd so on for t he
C, D, K, and X0 mat r ices. (See ms2th in t he Command Reference chapt er .)
For a st at e-space mat r ix t ha t is defined by mf2th, t he or der ing of t he
par amet er s is t he same as in t he user -wr it t en M-file.
b
1
nu
b
nbnu
nu
c
1
c
nc
d
1
d
nc
, , , , , , , , ,
pars a
1
a
na
b
1
1
b ,
nb1
1
b
1
2
b
nb2
2
, , , , , , , [ =
f
1
1
f
nf 1
1
f ,
1
nu
f
nf nu
nu
] , , , ,
3-79
Mult iva r iat e ARX models ar e int er nally r epr esent ed in st at e-space for m. The
par a met er or der ing follows t he one descr ibed above. The or der ing of t he
par a met er s may, however , not be t r anspar ent so it is bet t er t o use th2arx and
arx2th inst ead of th2par and ms2th.
Complex-Valued Data
Some a pplicat ions of syst em ident ificat ion wor k wit h complex valued dat a, and
t hus cr eat e complex-valued models. Most of t he r out ines in t he SITB suppor t
complex dat a and models. This is t r ue for t he est imat ion r out ines ar, armax,
arx, bj, covf, ivar, iv4, oe, pem, and spa, but (cur r ent ly) not for canstart and
n4sid. The t r ansfor mat ion r out ines, like th2ff, th2zp, et c. also wor k for
complex-valued models, but no pole-zer o confidence r egions ar e given. Not e
also t ha t t he pa r amet er va r iance-covar ia nce infor mat ion t hen r efer s t o t he
complex va lued par amet er s, so no sepa r at e infor mat ion about t he accur a cy of
t he r eal a nd ima gina r y par t s will be given. Some display funct ions like compare
and
idplot do not wor k for t he complex ca se. Use idsim and plot r eal and
imaginar y par t s separ at ely.
Strange Results
St r ange r esult s ca n of cour se be obt ained in any number of ways. We only point
out t wo ca ut ions: It is t empt ing in ident ificat ion applicat ions t o call t he
r esiduals eps. Dont do t hat . This cha nges t he machine , which cer t ainly
will give you st r ange r esult s.
It is also nat ur a l t o use names like step, phase, et c., for cer t ain var ia bles. Not e
t hough t ha t t hese var iables t ake pr ecedence over M-files wit h t he same name
so be sur e you dont use var iable names t ha t a lso ar e names of M-files.

3 Tu to r i a l
3-80

4
Command Refer ence
4 C o m m a n d Re f e r e n c e
4-2
This chapt er cont ains det ailed descr ipt ions of all of t he funct ions in t he Syst em
Ident ificat ion Toolbox. It begins wit h a list of funct ions gr ouped by subject a r ea
and cont inues wit h t he ent r ies in alphabet ical or der . Infor mat ion is also
available t hr ough t he online Help facilit y.
By t yping a funct ion name wit hout ar gument s, you also get immediat e synt ax
help about it s ar gument s.
For ease of use, most funct ions ha ve sever al default ar gument s. The Synopsis
fir st list s t he funct ion wit h t he necessar y input ar gument s and t hen wit h all
t he possible input ar gument s. The funct ions can be used wit h any number of
ar gument s bet ween t hese ext r emes. The r ule is t hat missing, t r a iling
ar gument s ar e given default values, as defined in t he manual. Defa ult values
ar e also obt ained by ent er ing t he ar gument s as t he empt y mat r ix [ ].
MATLAB does not r equir e t hat you specify all of t he out put ar gument s; t hose
not specified ar e not r et ur ned. For funct ions wit h sever a l out put ar gument s in
t he Syst em Ident ificat ion Toolbox, missing ar gument s ar e, as a r ule, not
comput ed, in or der t o save t ime.
The Graphi cal Use r Int e rface
ident Open t he int er face.
midprefs Set dir ect or y wher e t o st or e st ar t -up infor mat ion.
Si mulati on and Pre di ct i on
idinput Gener at e input signa ls.
idsim Simulat e a gener al linear syst em.
pe Comput e pr edict ion er r or s.
poly2th Cr eat e a model st r uct ur e for input -out put models
defined as numer at or and denomina t or polynomials.
predict Comput e pr edict ions accor ding t o model.
4-3
Data Mani pul at i on
dtrend Remove t r ends fr om da t a.
idfilt Filt er dat a.
idresamp Resample dat a.
Nonparame tri c Es t i mati on
covf Est imat e covar ia nce funct ion.
cra Est imat e impulse r esponse and covar iance funct ions
using cor r elat ion a nalysis.
etfe Est imat e spect r a and t r ansfer funct ions using dir ect
Four ier t echniques.
spa Est imat e spect r a and t r ansfer funct ions using
spect r al analysis.
Parame te r Est i mat i on
ar Est imat e AR model.
armax Est imat e ARMAX model.
arx Est imat e ARX model using lea st squar es.
bj Est imat e Box-J enkins model.
canstart Est imat e mult ivar iat e models in canonica l
st at e-space for m.
ivar Est imat e AR model using inst r ument al var iable
met hods.
ivx Est imat e ARX model using gener al inst r ument s.
iv4 Est imat e ARX model using four-st age inst r ument a l
var iable met hod.
4 C o m m a n d Re f e r e n c e
4-4
oe Est imat e Out put -Er r or model.
n4sid Est imat e st at e-space model using subspace met hod.
pem Est imat e gener al linear model.
Mode l St ruct ure Cre at i on
arx2th Define (mult ivar iat e) ARX st r uct ur es.
canform Gener at e canonical for ms.
mf2th Cr eat e a r bit r ar y linear model st r uct ur e via an M-file
t ha t you wr it e.
modstruc Define st at e-space models wit h known and unknown
par a met er s.
ms2th Cr eat e model st r uct ur e for linear st a t e-space models
wit h known and unknown par amet er s.
poly2th Cr eat e a model st r uct ur e for input -out put models
defined as numer at or and denomina t or polynomials.
Mani pul at i ng Mode l St ruct ure s
fixpar Fix par amet er s in st r uct ur es t o given values.
sett Set t he sampling int er val.
ss2th Tr ansfor m a st at e-space model t o a par a met r ized
canonical for m.
thinit Select or r a ndomize init ia l par amet er values.
unfixpar Allow cer t ain ear lier fixed pa r amet er s be est ima t ed.
Parame t e r Es ti mat i on
4-5
Model Conversions
idmodred Reduce a model t o lower or der.
thc2thd Tr ansfor m fr om cont inuous t o discr et e t ime.
thd2thc Tr ansfor m fr om discr et e t o cont inuous t ime.
th2arx Thet a t o ARX par amet er s.
th2ff Thet a t o fr equency funct ions and spect r a.
th2par Thet a t o est imat ed par amet er s and var ia nces.
th2poly Thet a t o t r ansfer funct ion polynomials.
th2ss Thet a t o st at e-space mat r ices.
th2tf Thet a t o t r ansfer funct ions.
th2zp Thet a t o zer os, poles, and st a t ic gains.
Mode l Pre s e ntati on
bodeplot Plot Bode diagr ams.
ffplot Plot fr equency funct ions and spect r a.
idplot Display input -out put dat a.
nyqplot Plot Nyquist diagr ams.
present Display model on scr een.
zpplot Plot zer os and poles.
4 C o m m a n d Re f e r e n c e
4-6
Informati on Ext racti on
getff Ext r act t he fr equency funct ions fr om t he fr eqfunc
for mat .
gett Ext r act t he sampling int er val fr om t he t het a for mat .
getmfth Ext r act t he M-file name t hat defines t he model
st r uct ur e.
getncap Ext r act fr om t he t het a for mat t he number of dat a
upon which model is based.
getzp Ext r act t he zer os a nd poles fr om t he zepo for mat .
th2par Ext r act est imat ed pa r amet er s a nd var iances fr om
t he t het a for ma t .
Mode l Val i dati on
compare Compar e models simulat ed or pr edict ed out put wit h
act ual out put .
idsim Simulat e a model.
pe Comput e pr edict ion er r or s.
predict Pr edict fut ur e out put s.
resid Comput e and t est model r esiduals.
As s e s s i ng Mode l Unce rt ai nty
idsimsd Simulat e r esponses fr om sever al possible models.
th2ff Comput e fr equency funct ion and it s st andar d
deviat ion.
th2zp Comput e zer os, poles, st at ic gains, and t heir
st andar d deviat ions.
4-7
Mode l St ruct ure Sel e ct i on
arxstruc Comput e loss funct ions for set s of ARX model
st r uct ur e.
ivstruc Comput e loss funct ions for set s of out put er r or model
st r uct ur es.
selstruc Select st r uct ur e.
struc Gener at e set s of st r uct ur es.
Rec urs i ve Parame t e r Es t i mati on
rarmax Est imat e ARMAX or ARMA models r ecur sively.
rarx Est imat e ARX or AR models r ecur sively.
rbj Est imat e Box-J enkins models r ecur sively.
roe Est imat e Out put -Er r or models (IIR-filt er s)
r ecur sively.
rpem Est imat e gener al input -out put models using a
r ecur sive pr edict ion er r or met hod.
rplr Est imat e gener al input -out put models using a
r ecur sive pseudo-linear r egr ession met hod.
segment Segment dat a and est imat e models for each segment .
4 C o m m a n d Re f e r e n c e
4-8
ar
4-9
ar
Purpose Est imat e t he par amet er s of an AR model for scalar t ime ser ies.
Syntax th = ar(y,n)
[th,refl] = ar(y,n,approach,win,maxsize,T)
Description The pa r amet er s of t he AR model st r uct ur e
ar e est ima t ed using var ia nt s of t he least -squar es met hod.
Column vect or y cont ains t he t ime ser ies dat a. Scalar n specifies t he or der of
t he model t o be est imat ed (t he number of A pa r amet er s in t he AR model).
Not e t hat t he r out ine is for scalar t ime ser ies only. For mult ivar iat e dat a use
arx.
The est imat e is r et ur ned in th and st or ed in t het a for mat . For t he t wo
lat t ice-based appr oaches, 'burg' and 'gl' (see below), var iable refl is
r et ur ned cont aining t he r eflect ion coefficient s in t he fir st r ow, and t he
cor r esponding loss funct ion va lues in t he second. The fir st column is t he zer o-t h
or der model, so t hat t he (2,1) element of refl is t he nor m of t he t ime ser ies
it self.
Var iable approach a llows you t o choose an algor it hm fr om a gr oup of sever al
popular t echniques for comput ing t he least -squar es AR model. Available
met hods ar e as follows:
approach = 'fb': The for war d-backwar d a ppr oach. This is t he default
appr oach. The sum of a least -squar es cr it er ion for a for war d model and t he
ana logous cr it er ion for a t ime-r ever sed model is minimized.
approach = 'ls': The least -squar es a ppr oach. The st andar d sum of squar ed
for wa r d pr edict ion er r or s is minimized.
approach = 'yw': The Yule-Walker appr oach. The Yule-Walker equat ions,
for med fr om sa mple covar ia nces, ar e solved.
approach = 'burg': Bur gs la t t ice-ba sed met hod. The lat t ice filt er equat ions
ar e solved, using t he har monic mean of for war d and ba ckwar d squar ed
pr edict ion er r or s.
A q ( )y t ( ) e t ( ) =
ar
4-10
approach = 'gl': A geomet r ic la t t ice appr oa ch. As in Bur gs met hod, but t he
geomet r ic mean is used inst ead of t he har monic one. .
The comput a t ion of t he covar iance mat r ix ca n be suppr essed in any of t he
above met hods by ending t he approach ar gument wit h 0 (zer o), for example,
'burg0'.
Windowing, wit hin t he cont ext of AR modeling, is a t echnique for dea ling wit h
t he fact t hat infor mat ion about past a nd fut ur e dat a is la cking. Ther e ar e a
number of var iant s ava ilable:
window = 'now': No windowing. This is t he default value, except when
approach = 'yw'. Only act ually measur ed dat a ar e used t o for m t he r egr ession
vect or s. The summat ion in t he cr it er ia st a r t s only a t t ime n.
window = 'prw': Pr e-windowing. Missing past dat a ar e r eplaced by zer os, so
t hat t he summa t ion in t he cr it er ia can be st ar t ed at t ime zer o.
window = 'pow': Post -windowing. Missing end dat a ar e r eplaced by zer os, so
t hat t he summa t ion can be ext ended t o t ime N + n. (N being t he number of
obser vat ions.)
window = 'ppw': Pr e- and post -windowing. This is used in t he Yule-Walker
appr oach.
The combinat ions of a ppr oaches a nd windowing have a var iet y of names. The
least -squar es appr oach wit h no windowing is also known as t he covariance
met hod. This is t he same met hod t hat is used in t he arx r out ine. The MATLAB
default met hod, for war d-backwar d wit h no windowing, is oft en ca lled t he
modified covariance met hod. The Yule-Walker a ppr oach, least -squar es plus
pr e- and post -windowing, is also known as t he correlat ion method.
ar only ha ndles sca lar t ime ser ies. For mult ivar ia t e ser ies, use arx.
See auxvar for an expla nat ion of t he input ar gument s maxsize and T.
ar
4-11
Examples Compar e t he spect r al est imat es of Bur gs met hod wit h t hose found fr om t he
for wa r d-backwar d nonwindowed met hod, given a sinusoid in noise signal:
y = sin([1:300]') + 0.5*randn(300,1);
thb = ar(y,4,'burg');
thfb = ar(y,4);
sgb = th2ff(thb);
sfb = th2ff(thfb);
bodeplot([sgb sfb])
See Also auxvar, arx, etfe, ivar, spa, theta
References Mar ple, J r ., S. L. Digit al S pectral Analysis wit h Applicat ions, Pr ent ice Hall,
Englewood Cliffs, 1987, Chapt er 8.
armax
4-12
ar ma x
Purpose Est imat e t he pa r amet er s of an ARMAX or ARMA model.
Syntax th = armax(z,nn)
th = armax(z,nn,trace)
[th, iter_info] = armax(z,nn,maxiter,tol,lim,maxsize,T,trace)
Description The pa r amet er s of t he ARMAX model st r uct ur e
ar e est ima t ed using a pr edict ion er r or met hod.
Mat r ix z cont ains t he out put -input da t a z = [y u] wher e y and u a r e column
vect or s (u is a mat r ix in t he mult i-input case). nn can be given eit her as
nn = [na nb nc nk]
or as
nn = thi
In t he for mer case na, nb, and nc ar e t he or der s of t he ARMAX model, and nk
is t he dela y. In t he lat t er ca se thi is an init ial value, given in t het a for ma t . See
Sect ion 3 in t he Tutorial for an exact definit ion of t he or der s.
For mult i-input syst ems, nb and nk ar e r ow vect or s, such t hat t he k-t h ent r y
cor r esponds t o t he or der and delay associat ed wit h t he k-t h input .
If z = y and nn = [na nc], armax calcula t es an ARMA model for y:
th is r et ur ned wit h t he r esult ing par amet er est imat es, t oget her wit h est imat ed
covar ia nces, st or ed in t het a for mat .
armax does not suppor t mult i-out put models. Use st at e-space model for t his
ca se (see canstart, n4sid, and pem)
If a last ar gument trace is supplied, infor mat ion about t he pr ogr ess of t he
it er at ive sear ch for t he model will be fur nished t o t he MATLAB comma nd
window.
The opt iona l auxiliar y var iables iter_info, lim, maxiter, tol, maxsize, and T
ar e explained under auxvar.
A q ( )y t ( ) B q ( )u t nk ( ) C q ( )e t ( ) + =
A q ( )y t ( ) C q ( )e t ( ) =
armax
4-13
Algorithm A r obust ified quadr a t ic pr edict ion er r or cr it er ion is minimized using an
it er at ive Gauss-Newt on algor it hm. The Gauss-Newt on vect or is bisect ed up t o
10 t imes unt il a lower value of t he cr it er ion is found. If no such value is found,
a gr adient sear ch dir ect ion is used inst ead, and t he pr ocedur e is r epeat ed. The
it er at ions ar e t er minat ed when maxiter is r eached, when t he Ga uss-Newt on
vect or has a nor m less t han tol, or when a lower value of t he cr it er ion cannot
be found.
The init ial condit ions for t he it er at ive sea r ch, if not specified in nn, ar e
const r uct ed in a special four -st a ge LS-IV algor it hm.
The cut -off value for t he r obust ificat ion is based on t he par a met er lim as well
as on t he est imat ed st a ndar d deviat ion of t he r esiduals fr om t he init ial
par a met er est imat e. It is not r ecalculat ed dur ing t he minimizat ion. The value
r et ur ned in element th(1,1) is t he nonr obust ified, quadr at ic cr it er ion.
A st abilit y t est of t he pr edict or is per for med, so as t o assur e t hat only models
cor r esponding t o st able pr edict or s ar e t est ed. Gener ally, bot h and (if
applicable) must have all t heir zer os inside t he unit cir cle. Not e t hat if an
init ial par amet er est imat e is given in nn, it s pr edict or st abilit y is t aken for
gr ant ed (not t est ed).
Infor ma t ion about t he minimizat ion is fur nished t o t he scr een in case t he
ar gument trace is specified.. Cur r ent and pr evious par amet er est ima t es (in
column vect or for m, list ing par amet er s in alphabet ical or der ) as well as t he
values of t he cr it er ion funct ion ar e given. The Gauss-Newt on vect or and it s
nor m ar e a lso displayed. The number in t he upper left cor ner is t he number of
t imes t he sear ch vect or ha s been bisect ed.
See Also arx, auxvar, bj, oe, pem, theta
References Ljung (1987), equat ions (10.41), (10.42), (10.46), (10.75)
C q ( ) F
i
q ( )
arx
4-14
ar x
Purpose Est imat e t he pa r amet er s of an ARX or AR model.
Syntax th = arx(z,nn)
th = arx(z,nn,maxsize,T)
Description The pa r amet er s of t he ARX model st r uct ur e
ar e est ima t ed using t he least -squar es met hod.
Mat r ix z cont ains t he out put -input da t a z = [y u] wher e y and u a r e column
vect or s. nn is given as
nn = [na nb nk]
defining t he or der s and delay of t he ARX model. See Sect ion 6 in t he Tut orial
for exact definit ions of t he or der s and delays.
th is r et ur ned as t he least -squar es est imat es of t he pa r amet er s, st or ed in t het a
for mat .
Wit h z = y a nd nn = na, a n AR model of or der na for y is comput ed:
Models wit h sever al input s
ar e ha ndled by a llowing u t o cont ain ea ch input as a column vect or ,
u = [u1 ... unu]
and by allowing nb and nk t o be r ow vect or s defining t he or der s and delays
associat ed wit h each input .
Models wit h sever al input s and sever al out put s ar e handled by a llowing nn t o
cont ain one r ow for each out put number . See Defining Model St r uct ur es on
page 3-29 for exact definit ions.
The opt ional auxiliar y par amet er s maxsize and T ar e expla ined under
auxvar.
A q ( )y t ( ) B q ( )u t nk ( ) e t ( ) + =
A q ( )y t ( ) e t ( ) =
A q ( )y t ( ) B
1
q ( )u
1
t nk
1
( ) B
nu
u
nu
t nk
nu
( ) e t ( ) + + =
arx
4-15
When t he t r ue noise t er m in t he ARX model st r uct ur e is not whit e noise
and na is nonzer o, t he est imat e does not give a cor r ect model. It is t hen bet t er
t o use armax, bj, iv4, or oe.
Examples Her e is an example t hat gener at es and est imat es a n ARX model:
A = [1 1.5 0.7]; B = [0 1 0.5];
th0 = poly2th(A,B);
u = idinput(300,'rbs');
y = idsim([u,randn(300,1)],th0);
z = [y,u];
th = arx(z,[2 2 1]);
Algorithm The lea st -squar es est imat ion pr oblem is an over det er mined set of linear
equat ions t hat is solved using t he MATLAB \ oper a t or .
The r egr ession mat r ix is for med so t hat only measur ed quant it ies ar e used (no
fill-out wit h zer os). When t he r egr ession mat r ix is lar ger t han maxsize, t he
nor mal equat ions ar e for med in a for -loop and subsequent ly solved.
See Also auxvar, ar, iv, iv4, theta
e t ( )
arxstruc
4-16
ar xst r uc
Purpose Comput e loss funct ions for a set of differ ent model st r uct ur es of single-out put
ARX t ype.
Syntax v = arxstruc(ze,zv,NN)
v = arxstruc(ze,zv,NN,maxsize)
Description NN is a ma t r ix t hat defines a number of differ ent st r uct ur es of t he ARX t ype.
Each r ow of NN is of t he for m
nn = [na nb nk]
wit h t he same int er pr et at ion a s descr ibed for arx. See struc for easy
gener at ion of t ypical NN mat r ices for single-input syst ems.
Each of ze and zv a r e ma t r ices cont aining out put -input dat a [y u]. For
mult i-input syst ems, u ha s t he cor r esponding number of columns, while for
t ime ser ies, no u is pr esent . Models for each of t he model st r uct ur es defined by
NN ar e est imat ed using t he dat a set ze. The loss funct ions (nor malized sum of
squar ed pr edict ion er r or s) a r e t hen comput ed for t hese models when applied t o
t he va lidat ion dat a set zv. The dat a set s, ze and zv, need not be of equal size.
They could, however , be t he same set s, in which case t he comput at ion is fa st er .
Not e t hat arxstruc is int ended for single-out put syst ems only.
v is r et ur ned wit h t he loss funct ions in it s fir st r ow. The r emaining r ows of v
cont ain t he t r anspose of NN, so t hat t he or der s a nd delays a r e given just below
t he cor r esponding loss funct ions. The last column of v cont ains t he number of
dat a point s in ze. The select ion of a suit able model st r uct ur e based on t he
infor mat ion in v is best done using selstruc. See Sect ion 8 in t he Tut orial for
advice on model st r uct ur e select ion, cr oss-validat ion, and t he like.
See auxvar for an expla nat ion of maxsize.
Examples Compar e fir st t o fift h or der models wit h one delay using cr oss-validat ion on t he
second half of t he dat a set , and t hen select t he or der t hat gives t he best fit t o
t he va lidat ion dat a set :
NN = struc(1:5,1:5,1);
V = arxstruc(z(1:200,:),z(201:400,:),NN);
nn = selstruc(V,0);
th = arx(z,nn);
See Also arx, ivstruc, selstruc, struc
arx 2th
4-17
ar x2t h
Purpose Const r uct t het a for mat ma t r ix fr om ARX polynomials.
Syntax th = arx2th(A,B,ny,nu)
th = arx2th(A,B,ny,nu,lam,T)
Description arx2th cr eat es a mat r ix cont aining par amet er s t hat descr ibe t he gener al
mult i-input , mult i-out put model st r uct ur e of ARX t ype:
Her e a nd ar e ma t r ices of dimensions ny by ny and ny by nu, r espect ively
(ny is t he number of out put s, i.e., t he dimension of t he vect or and nu is t he
number of input s). Defining Model St r uct ur es on page 3-29.
The ar gument s A a nd B ar e mat r ices t ha t cont a in t he A mat r ices and t he B
mat r ices of t he model:
A = [I A1 A2 ... Ana]
B = [B0 B1 ... Bnb]
Not e t hat A alwa ys st ar t s wit h t he ident it y mat r ix, and t hat delays in t he model
ar e defined by set t ing t he cor r esponding lea ding ent r ies in B t o zer o. For a
mult ivar iat e t ime ser ies t ake B = [].
The ar gument s ny and nu denot e t he number of out put s a nd input s,
r espect ively.
The opt ional ar gument lam set s t he covar iance mat r ix of t he dr iving noise
sour ce in t he model above. The default value is t he ident it y mat r ix.
The opt ional ar gument T defines t he sa mpling int er val (Defa ult 1).
th is r et ur ned as a model st r uct ur e in t he t het a for mat . See theta.
The use of arx2th is t wofold. You can use it t o cr eat e models t ha t ar e simulat ed
(using idsim) or analyzed (using th2ff, th2zp, et c.). You can also use it t o
define init ia l value models t hat ar e fur t her adjust ed t o da t a (using pem). The
fr ee pa r amet er s in t he st r uct ur e ar e consist ent wit h t he st r uct ur e of A a nd B,
i.e., leading zer os in t he r ows of B ar e r egar ded a s fixed delays, and t r ailing
zer os in A and B ar e r egar ded as a definit ion of lower or der polynomials. These
y t ( ) A
1
y t 1 ( ) A
2
y t 2 ( ) A
na
y t na ( ) + + + + =
B
0
u t ( ) B
1
u t 1 ( ) B
nb
u t nb ( ) e t ( ) + + + +
A
k
B
k
y t ( )
e t ( )
arx2th
4-18
zer os ar e fixed, while all ot her par amet er s ar e fr ee. The nominal values of t hese
fr ee pa r amet er s a r e set equal t o t he values in A and B. The fr ee pa r amet er s can
be cha nged by thinit and t he st r uct ur e can be ma nipulat ed by fixpar and
unfixpar.
For a model wit h one out put , arx2th is compat ible wit h poly2th. The int er nal
r epr esent at ion is however differ ent , a nd only a model st r uct ur e t hat has been
defined by arx2th can be manipulat ed by fixpar a nd unfixpar.
Examples Simulat e a second or der ARX model wit h one input and t wo out put s, and t hen
est ima t e a model using t he simula t ed dat a :
A1 = [1.5 0.1;0.2 1.5];
A2 = [0.7 0.3;0.1 0.7];
B1 = [1;1];
B2 = [0.5;1.2];
th0 = arx2th([eye(2) A1 A2],[[0;0],B1 B2],2,1);
u = idinput(300);
e = randn(300,2);
y = idsim([u e],th0);
th = arx([y u],[[2 2;2 2],[2;2],[1;1]]);
See Also arx, fixpar, poly2th, th2arx, unfixpar
auxvar
4-19
auxvar
Purpose Descr ibe auxilia r y var iables iter_info, lim, maxiter, maxsize, tol, and T.
Syntax help auxvar
Description Most of t he funct ions have a n opt ional ar gument maxsize t hat allows a
t r ade-off bet ween memor y usage a nd speed. Sever al of t he funct ions allow t he
sampling int er val T t o be specified. The it er at ive sear ch pr ocedur es in armax,
bj, oe, and pem ar e cont r olled by t he t hr ee par amet er s lim, maxiter, and lim.
maxsize: No mat r ix for med by t he funct ion is allowed t o cont ain mor e t han
maxsize element s. Inst ead, t he algor it hms split t he calculat ions int o for -loops,
which ar e slower . The default value of maxsize is set in t he M-file idmsize. On
small machines, it is maxsize=4096. The main use of maxsize is t o limit
var iable sizes when t he algor it hms r un out of memor y. See Some Special
Topics on page 3-68 for mor e infor mat ion.
T: Specifying t he sampling int er va l T gives cor r ect fr equency sca les on
fr equency funct ion plot s, and cor r ect t ime scales when t r ansfor ming t o
cont inuous t ime using thd2thc. The default value is T=1.
maxiter: This va r iable det er mines t he maximum number of it er at ions
per for med dur ing a sear ch for a minimum. The default value is maxiter=10.
maxiter=0 r et ur ns t he r esult s of t he special st ar t up pr ocedur e.
tol: The it er at ions ar e cont inued unt il t he nor m of t he Gauss-Newt on upda t e
vect or is less t han TOL. The it er at ions also t er minat e when t he algor it hm fa ils
t o find a lower value of t he cr it er ion and when t he maximum number of
it er at ions ar e r ea ched. The default value is tol=0.01.
lim: This var iable det er mines how t he cr it er ion is modified fr om quadr at ic t o
one t hat gives linear weight t o lar ge er r or s. See Par amet r ic Model Est imat ion
on pa ge 3-22 for a mor e pr ecise definit ion. The default value of lim is 1.6. lim=0
disables t he r obust ificat ion and leads t o a pur ely quadr at ic cr it er ion.
Default values of t hese par amet er s ar e obt ained eit her by omit t ing t r ailing
ar gument s or by ent er ing t hem as t he empt y mat r ix [ ].
auxvar
4-20
iter_info: This out put ar gument fr om t he it er at ive numer ical sear ch
algor it hms armax, bj, oe, and pem, supplies infor mat ion about t he it er a t ions. It
is a r ow vect or
iter_info = [last_iteration#, last_fit_improvement,
norm_of_last_search_vector]
cont aining t he indicat ed infor mat ion. If t he nor m of t he last sear ch vect or is
lar ger t ha n tol, and t he number of t he last it er at ion is less t han maxiter, t hen
t he it er at ions wer e st opped since no smaller value of t he cr it er ion could be
found along t he sear ch dir ect ion.
See Also armax, bj, oe, pem
bj
4-21
bj
Purpose Est imat e t he par amet er s of a Box-J enkins model.
Syntax th = bj(z,nn)
th = bj(z,nn,trace)
[th, iter_info]= bj(z,nn,maxiter,tol,lim,maxsize,T,trace)
Description The pa r amet er s of t he Box-J enkins model st r uct ur e
ar e est ima t ed using a pr edict ion er r or met hod.
Mat r ix z cont ains t he out put -input dat a z = [y u] wher e y and u ar e column
vect or s. In t he mult i-input case, u is a mat r ix cont aining t he differ ent input s as
columns. nn can be given eit her as
nn = [nb nc nd nf nk]
or as
nn = thi
In t he for mer ca se, nb, nc, nd, and nf a r e t he or der s of t he Box-J enkins model
and nk is t he dela y. In t he lat t er case, thi is an init ial value, given in t het a
for mat . SeeThe Syst em Ident ificat ion Pr oblem on page 3-8 for exa ct
definit ions of t he model or der s.
th is r et ur ned wit h t he r esult ing par amet er est ima t es a nd est imat ed
covar iances, st or ed in t het a for mat .
The opt ional var iables iter_info, lim, maxiter, maxsize, tol, a nd T ar e
explained under auxvar.
For mult i-input syst ems, nb, nf, and nk ar e r ow vect or s wit h as many ent r ies
as t her e ar e input channels. Ent r y number i t hen descr ibed t he or der s and
delays associat ed wit h t he i-t h input .
bj does not suppor t mult i-out put models. Use st at e-spa ce model for t his case
(see canstart, n4sid, and pem)
y t ( )
B q ( )
F q ( )
-----------u t nk ( )
C q ( )
D q ( )
------------e t ( ) + =
bj
4-22
If a last ar gument trace is supplied, infor mat ion about t he pr ogr ess of t he
it er at ive sear ch for t he model will be fur nished t o t he MATLAB comma nd
window.
Examples Her e is an example t hat gener at es dat a and st or es t he r esult s of t he st a r t up
pr ocedur e separ a t ely:
B = [0 1 0.5];
C = [1 1 0.2];
D = [1 1.5 0.7];
F = [1 1.5 0.7];
th0 = poly2th(1,B,C,D,F,0.1);
e = randn(200,1);
u = idinput(200);
y = idsim([u e],th0);
z = [y u];
thi = bj(z,[2 2 2 2 1],0);
th = bj(z,thi);
present(th)
Algorithm bj uses essent ially t he same algor it hm as armax wit h modificat ions t o t he
comput at ion of pr edict ion er r or s and gr adient s.
See Also armax, auxvar, oe, pem, theta
bodeplot
4-23
bodeplot
Purpose Plot fr equency funct ions in Bode diagr am for m.
Syntax bodeplot(g)
bodeplot([g1 g2 ... gn])
bodeplot(g,sd,C,mode)
Description g cont ains t he fr equency dat a t o be gr aphed. See freqfunc for t he for mat . The
fr equency funct ions do not have t o be specified at t he same fr equencies, but
have t o have t he same number of values.
If t he fr equency funct ions ar e gener at ed by th2ff or spa, and sd is specified as
a number lar ger t han zer o, confidence int er vals for t he funct ions ar e added t o
t he gr aph as dash-dot t ed cur ves (of t he same color a s t he est imat e cur ve). They
indicat e t he confidence r egions cor r esponding t o sd st andar d deviat ions.
On amplit ude plot s, t he loga r it hm of t he absolut e value, plus and minus t he
st a ndar d deviat ion you indicat e, is gr a phed. The la t t er value can somet imes be
negat ive, which r esult s in an er r or messa ge fr om t he plot t ing r out ine. The
r esult ing plot is st ill meaningful, however .
By default , amplit ude and phase plot s ar e shown simult a neously for each input
(noise spect r um) pr esent in g. For spect r a, phase plot s ar e omit t ed. Pr essing
t he Re t urn key advances t he plot fr om one input t o t he next .
To show amplit ude plot s only, use C = 'A'. For phase plot s only, use
C = 'P'. The default is C = 'B' for bot h plot s.
To obt ain all plot s on t he same diagr am use mode = 'same'.
Not e t hat if g cont ains infor ma t ion about sever al out put s, t hese plot s ar e
always given separ at ely.
See Also etfe, ffplot, freqfunc, getff, nyqplot, spa, th2ff
canform
4-24
ca nfor m
Purpose Define mult ivar iable st a t e-space canonical for m model st r uct ur es.
Syntax ms = canform(orders,nu)
ms = canform(orders,nu,dkx)
Description canform is, like modstruc, a funct ion t hat defines model par amet er iza t ions in
st a t e-space for m, which ar e used in ms2th t o cr ea t e model st r uct ur es in t he
t het a for mat . The only use of t he r esult ing mat r ix ms is as an input t o ms2th.
The model consider ed is in st at e-spa ce for m:
The funct ion applies bot h t o t he cont inuous- and discr et e-t ime cases; which one
is det er mined only when t he st r uct ur e is for med wit h ms2th.
orders: The (pseudo-obser vabilit y) indices orders define which mat r ix
element s ar e fixed (t o zer o or one) a nd which ar e left fr ee as par amet er s.
orders is a r ow vect or wit h as many ent r ies as t her e ar e out put s. Element k of
orders descr ibes how many dela yed values of t he out put ar e r equir ed t o
appr opr iat ely pr edict t he k-t h component of t he out put . The sum of t he or der
indices is t he or der of t he syst em (t he dimension of x):
n = sum(orders)
The exact st r uct ur e is defined in Appendix 4.A of Ljung (1987). Br iefly, t he A
mat r ix cont a ins p n pa r amet er s, wher e p is t he number of out put s and n is
t he number of st at es. The C mat r ix cont a ins only zer os a nd ones, while t he B
mat r ix is filled wit h par amet er s.
nu: The number of input s.
dkx: The a r gument dkx det er mines some addit ional st r uct ur e of t he ma t r ices
of t he st at e-space model t o be est imat ed. It is a r ow vect or wit h t hr ee ent r ies:
dkx = [d, k, x]
The ent r ies r efer t o t he mat r ices K, D, and t he init ia l st at e x(0) of t he
st a t e-space model given above.
x

t ( ) A ( )x t ( ) B ( )u t ( ) K ( )e t ( ) + + =
y t ( ) C ( )x t ( ) D ( )u t ( ) e t ( ) + + =
canform
4-25
k = 1 indicat es t hat t he K-mat r ix in t he model (t he Kalma n Gain) will be fully
par a met er ized, while k = 0 means t hat t his mat r ix will be fixed t o zer o. This
will give a so-called out put er r or model.
d = 1 indicat es t hat D-mat r ix in t he model (t he dir ect t er m fr om input t o
out put ) will be fully par amet r ized, while d = 0 mea ns t hat t his mat r ix will be
fixed t o zer o. This also implies t hat t her e will be a dela y of (at lea st ) one sample
bet ween t he input and t he out put .
x = 1 indicat es t hat t he init ial st at e x(0) will be par amet er ized, while x = 0
means t hat t he init ial st at e will be fixed t o zer o.
Default is
dkx = [0, 1, 0]
An alt er na t ive t o canform is t he funct ion canstart. It also pr ovides good init ial
est imat es for t he fr ee par amet er s.
Examples Wr it e out t he st a t e-space mat r ices for a sixt h or der syst em wit h t hr ee out put s
and t wo input s wit h NaN denot ing fr ee par amet er s:
ps = [2 1 3];
ms = canform(ps,2);
th = ms2th(ms,'c',ones(1,18+12+18)NaN);
[A,B,C,D,K] = th2ss(th)
See Also canstart, fixpar, modstruc, ms2th, unfixpar
References Ljung (1987), Appendix 4.A.
canstart
4-26
ca nst ar t
Purpose Define and init ialize st a t e-space canonical for m model st r uct ur es.
Syntax th = canstart(z,orders,nu)
th = canstart(z,orders,nu,dkx)
Description orders,nu,dkx: These ar gument s define t he st at e-space model
par amet er izat ion exact ly as for t he funct ion canform. In t he pr esent case
orders ca n also be t aken as a scalar , giving t he model or der (dimension of st at e
vect or ). Then a default choice of par amet er izat ion is made.
The out put th is a mat r ix in t he t het a for mat . It defines a st at e-space model
par amet er izat ion a ccor ding t o t he ar gument s orders, nu and dkx. The values
of t he par amet er s in th ar e est ima t ed fr om t he dat a mat r ix
z = [y u]
wher e y is t he mat r ix of out put signals, one column for each out put , a nd u is
t he mat r ix of input signals, again one column for each input .
Choosing t he or der indices for many syst ems is not cr it ical in t he sense t hat
most n-t h or der syst ems can be descr ibed by any set of or der
(pseudo-obser vabilit y) indices whose sum is n. See Model St r uct ur e Select ion
and Valida t ion on page 3-49 for mor e infor mat ion.
The model th could be fur t her r efined by using pem.
Algorithm The st at e-space model is fir st est imat ed using n4sid, and t hen t r ansfor med t o
t he chosen ca nonical for m using ss2th.
Examples A syst em wit h t wo input s and t wo out put s is est imat ed wit h a t hir d or der
model:
th = canstart(z,3,2);
th = pem(z,th);
resid(z,th);
See Also canform, pem
compare
4-27
compar e
Purpose Compar e measur ed out put s wit h model out put s.
Syntax compare(z,th);
[yh,fit] = compare(z,th,k,sampnr,leveladj)
Description z is t he out put -input dat a in t he usual for mat
z = [y u]
wher e y is a mat r ix whose r-t h column is t he r-t h out put signal a nd
cor r espondingly for t he input u. compare comput es t he out put yh t ha t r esult s
when t he model th is simulat ed wit h t he input u. The r esult is plot t ed (yellow/
solid) t oget her wit h t he cor r esponding measur ed out put y (magent a/dashed).
The mea n squa r e fit
fit = norm(yh y)/sqrt(length(y))
is also comput ed and displa yed. For mult i-out put syst ems t his is done
separ at ely for ea ch out put . Pr essing t he Re t urn key advances t he plot s.
The ar gument k comput es t he k-st ep ahead pr edict ion of y accor ding t o t he
model th inst ead of t he simula t ed out put . In t he calculat ion of , t he model
ca n use out put s up t o t ime : , , (and input s up t o
t he cur r ent t ime t). The default va lue of k is inf, which obt ains a pur e
simulat ion fr om t he input only.
The ar gument sampnr indicat es t hat only t he sample number s in t his r ow
vect or ar e plot t ed and used for t he calculat ion of t he fit . The whole dat a r ecor d
is used for t he simulat ion/pr edict ion, t hough. If t he opt ional ar gument
leveladj is set t o 'yes', t he simulat ed/pr edict ed out put and t he measur ed
out put ar e level adjust ed so t ha t t hey bot h st ar t a t level zer o. (This applies also
t o t he ca lculat ion of t he fit .) This a llows for discount ing of dr ift phenomena in
t he dat a.
Examples Split t he dat a r ecor d int o t wo par t s. Use t he fir st one for est imat ing a model
and t he second one t o check t he models abilit y t o pr edict six st eps ahead:
ze = z(1:250,:);
zv = z(251:500,:);
th = armax(ze,[2 3 1 0]);
compare(zv,th,6);
See Also idsim, predict
yh t ( )
t k y s ( ) s , t k = t k 1
covf
4-28
covf
Purpose Est imat e t ime ser ies covar iance funct ions.
Syntax R = covf(z,M)
R = covf(z,M,maxsize)
Description z is an N by nz mat r ix and M is t he maximum delay -1 for which t he covar iance
funct ion is est imat ed.
R is r et ur ned as an nz
2
x M mat r ix wit h ent r ies
wher e is t he j-t h column of z and missing values in t he sum ar e r eplaced by
zer o.
The opt ional ar gument maxsize cont r ols t he memor y size as explained under
auxvar.
The ea siest way t o descr ibe and unpa ck t he r esult is t o use
reshape(R(:,k+1),nz,nz) = E z(t)z'(t+k)
Her e ' is complex conjuga t e t r anspose, which also explains how complex dat a
ar e ha ndled. The expect at ion symbol E cor r esponds t o t he sample means.
Algorithm When nz is a t most t wo, and when per mit t ed by maxsize, a fast Four ier
t r ansfor m t echnique is applied. Ot her wise, st r aight for war d summing is used.
See Also spa
R

i j
k ( )
1
N
--- - z
i
t 1 =

= = t ( )z
j
t k + ( )
R(i + ( j 1)nz, k +1)
z
j
cra
4-29
cr a
Purpose Per for m cor r elat ion analysis and est imat e impulse r esponse.
Syntax cra(z);
[ir,R,cl] = cra(z,M,na,plot);
cra(R);
Description The out put -input dat a ar e given as
z = [y u]
wit h y as t he out put column vect or and u as t he input column vect or . The
r out ine only handles single-input -single-out put da t a pa ir s. (For t he
mult ivar iat e case, apply cra t o t wo signals at a t ime.) cra pr ewhit ens t he input
sequence, i.e., filt er s u t hr ough a filt er chosen so t hat t he r esult is as
uncor r elat ed (whit e) as possible. The out put y is subject ed t o t he same filt er ,
and t hen t he covar iance funct ions of t he filt er ed y a nd u ar e comput ed and
gr aphed. The cr oss cor r elat ion funct ion bet ween (pr ewhit ened) input and
out put is a lso comput ed and gr aphed. Posit ive va lues of t he lag var ia ble t hen
cor r esponds t o an influence fr om u t o lat er va lues of y. In ot her wor ds,
significant cor r elat ion for negat ive lags is an indicat ion of feedba ck fr om y t o u
in t he dat a.
A pr oper ly scaled ver sion of t his cor r elat ion funct ion is also a n est imat e of t he
syst ems impulse r esponse ir. This is also gr aphed along wit h 99% confidence
levels. The out put ar gument ir is t his impulse r esponse est imat e, so t ha t it s
fir st ent r y cor r esponds t o la g zer o. (Negat ive lags ar e excluded in ir.)
The out put ar gument R cont ains t he covar iance/cor r ela t ion infor mat ion as
follows: The fir st column of R cont ains t he lag indices. The second column
cont ains t he covar iance funct ion of t he (possibly filt er ed) out put . The t hir d
column cont ains t he covar iance funct ion of t he (possibly pr ewhit ened) input ,
and t he four t h column cont ains t he cor r elat ion funct ion. The plot s can be
r edisplayed by cra(R).
The out put ar gument cl is t he 99% confidence level for t he impulse r esponse
est imat e.
The opt ional ar gument M defines t he number of lags for which t he covar iance/
cor r elat ion funct ions ar e comput ed. These ar e fr om M t o M, so t hat t he lengt h
of R is 2M+1. The impulse r esponse is comput ed fr om 0 t o M. The default value
of M is 20.
cra
4-30
For t he pr ewhit ening, t he input is fit t ed t o an AR model of or der na. The t hir d
ar gument of cra can cha nge t his or der fr om it s default value na = 10. Wit h na
= 0 t he covar ia nce and cor r elat ion funct ions of t he or iginal dat a sequences ar e
obt ained.
plot: plot = 0 gives no plot s. plot = 1 (default ) gives a plot of t he est imat ed
impulse r esponse t oget her wit h a 99% confidence r egion. plot = 2 gives a plot
of all t he covar iance funct ions.
Examples Compar e a second or der ARX models impulse r esponse wit h t he one obt a ined
by cor r elat ion analysis:
ir = cra(z);
th = arx(z,[2 2 1]);
imp = [1;zeros(19,1)];
irth = idsim(imp,th);
subplot(211)
plot([ir irth])
title('impulse responses')
subplot(212)
plot([cumsum(ir),cumsum(irth)])
title('step responses')
See Also covf, spa
dtrend
4-31
dt r end
Purpose Remove t r ends fr om out put -input da t a.
Syntax zd = dtrend(z)
zd = dtrend(z,o,brkp)
Description z is a mat r ix, wit h dat a or ganized in column vect or s. dtrend r emoves t he t r end
fr om ea ch column and r et ur ns t he r esult in zd.
The defa ult (o = 0) r emoves t he zer o-t h or der t r ends, i.e., t he sample means ar e
subt r a ct ed.
Wit h o = 1, linear t r ends ar e r emoved, aft er a least -squar es fit . Wit h brkp not
specified, one single line is subt r a ct ed fr om t he ent ir e dat a r ecor d. A
cont inuous piecewise linea r t r end is subt r act ed if brkp cont ains br eakpoint s at
sample number s given in a r ow vect or .
Not e t hat dtrend differ s somewha t fr om detrend in t he Signal Pr ocessing
Toolbox.
Examples Remove a V-shaped t r end fr om t he out put wit h it s peak at sample number 119,
and r emove t he sample mean fr om t he input :
zd(:,1) = dtrend(z(:,1),1,119);
zd(:,2) = dtrend(z(:,2));
etfe
4-32
et fe
Purpose Est imat e empir ica l t r ansfer funct ions and per iodogr ams.
Syntax g = etfe(z)
g = etfe(z,M,N,T)
Description etfe est imat es t he t r ansfer funct ion g of t he gener a l linear model
The mat r ix z cont ains t he out put -input dat a z = [y u], wher e y and u ar e
column vect or s. The r out ine wor ks only for single-input , single-out put syst ems.
For a t ime ser ies, z = y. Then g is r et ur ned as t he per iodogr am of y.
g is given in fr equency funct ion for mat (see freqfunc), wit h t he est imat e of
at t he fr equencies
w = [1:N]/Npi/T
The defa ult va lues of N and T ar e 128 and 1, r espect ively. N must be a power of
t wo.
When M is specified ot her t han t he default value M = [ ], a smoot hing oper at ion
is per for med on t he r aw spect r al est imat es. The effect of M is t hen similar t o t he
effect of M in spa. This can be a useful alt er nat ive t o spa for na r r owband spect r a
and syst ems, which ot her wise r equir e lar ge values of M.
When etfe is applied t o t ime ser ies, t he cor r esponding spect r al est imat e is
nor malized in t he way t hat is defined in Some Special Topics on page 3-68.
Not e t hat t his nor maliza t ion may differ fr om t he one used by spectrum in t he
Signal Pr ocessing Toolbox.
Examples Compar e an empir ical t r ansfer funct ion est imat e t o a smoot hed spect r al
est ima t e:
ge = etfe(z);
gs = spa(z);
bodeplot([ge gs])
Algorithm The empir ica l t r ansfer funct ion est imat e is comput ed as t he r at io of t he out put
Four ier t r a nsfor m t o t he input Four ier t r ansfor m, using fft. The per iodogr am
y t ( ) G q ( )u t ( ) v t ( ) + =
G e
i
( )
etfe
4-33
is comput ed as t he nor ma lized absolut e squar e of t he Four ier t r a nsfor m of t he
t ime ser ies.
The smoot hed ver sions (M less t han t he lengt h of z) ar e obt ained by applying a
Hamming window t o t he out put FFT t imes t he conjugat e of t he input FFT, a nd
t o t he absolut e squar e of t he input FFT, r espect ively, a nd subsequent ly
for ming t he r at io of t he r esult s. The lengt h of t his Hamming window is equal
t o t he number of dat a point s in z divided by M, plus one.
See Also freqfunc, spa
ffplot
4-34
ffplot
Purpose Plot fr equency funct ions and spect r a.
Syntax ffplot(g)
ffplot([g1 g2 ... gn])
ffplot(g,sd,C,mode)
Description This funct ion has exact ly t he same synt ax as bodeplot. The only differ ence is
t hat it gives gr aphs wit h linear fr equency scales and Hz as t he fr equency unit .
See Also bodeplot, freqfunc, getff
fix par
4-35
fi xpar
Purpose Fix par amet er s in st r uct ur es defined by ms2th a nd arx2th.
Syntax thn = fixpar(tho,matrix)
thn = fixpar(tho,matrix,elements,parval)
Description The fixpar funct ion pr oduces a new model st r uct ur e thn in t he t het a for mat
fr om a n old one tho, by fixing cer t ain par amet er s t o cer t ain values. The mat r ix
tho must be or iginally defined by arx, arx2th, canstart, iv4, or ms2th but may
have been modified lat er on by fixpar, pem, thinit, or unfixpar.
To modify a st at e-space st r uct ur e
t he ar gument matrix is set equa l t o one of 'A', 'B', 'C', 'D','K', or 'x0'. The
ar gument elements is a mat r ix wit h t wo columns, in which each r ow specifies
t he indices of t he element in t he chosen syst em ma t r ix t hat need t o be fixed.
For example, t o fix t he 1,2-element and t he 3,5-element of t he A mat r ix use
thn = fixpar(tho,'A',[1,2;3,5]);
If t he ar gument elements is omit t ed (or ent er ed as t he empt y mat r ix) all
element s of t he indicat ed mat r ix will be fixed. In t his case parval can be given
a sca lar number , a nd a ll t he indicat ed element s will be fixed t o t hat number .
The default is t ha t t he element s ar e fixed t o t heir nominal (init ial or cur r ent ly
est imat ed) value. To fix t hem t o somet hing else use t he four t h input ar gument
parval. The r-t h ent r y of t his vect or cont ains t he value cor r esponding t o t he
element defined by t he r-t h r ow of elements.
To modify an ARX model
t he ar gument matrix is set equal t o one of 'A1', 'A2', ..., 'B0', 'B1', .... The
ar gument elements is t hen a mat r ix wit h t wo columns, wher e ea ch r ow gives
x

t ( ) A ( )x t ( ) B ( )u t ( ) K ( )e t ( ) + + =
y t ( ) C ( )x t ( ) D ( )u t ( ) e t ( ) + + =
y t ( ) A
1
y t 1 ( ) A
2
y t 2 ( ) A
na
y t na ( ) + + + + =
B
0
u t ( ) B
1
u t 1 ( ) B
nb
u t nb ( ) e t ( ) + + + +
fix par
4-36
t he indices of t he element in t he chosen ARX ma t r ix t hat need t o be fixed. The
r ole of parval is t he same as for t he st at e-space case above.
The r out ine does not a pply t o special model st r uct ur es t ha t you have or iginally
defined using mf2th, or t o black-box input -out put models ot her t han ARX
models. Fixing cer t ain par amet er s ca n, in t hose ca ses, be achieved by using t he
t hir d ar gument in pem dur ing t he est ima t ion phase.
Examples Conver t ing a st at e-space st r uct ur e wit h a ll element s in t he Kalman gain
mat r ix K fr ee t o an out put er r or st r uct ur e in which K is fixed t o zer o.
thn = fixpar(thn,'K',[],0)
Fixing t he par a met er t o 1 in a scalar ARX model, and t hen est imat ing t he
r emaining pa r amet er s:
th = arx(z,[2 3 0]);
th = fixpar(th,'B2',[1,1],1);
th = pem(z,th);
See Also theta, thinit, unfixpar
b
2
freqfunc
4-37
fr eqfunc
Purpose Descr ibe t he fr equency-funct ion for ma t .
Syntax help freqfunc
Description Fr equency funct ions ar e cr eat ed by etfe, spa, and th2ff, and used by
bodeplot, ffplot, and nyqplot. The int er nal for mat of t he fr eqfunc for mat is
int ended t o be t r anspar ent . The basic way t o display t he infor mat ion is t o use
t he plot commands. You can also r et r ieve t he infor mat ion fr om t he for mat by
t he funct ion getff. This ent r y gives det ails of t he int er nal r epr esent at ion, but
t his infor mat ion is not necessar y for nor mal use of t he Syst em Ident ificat ion
Toolbox.
The fr eqfunc for mat cont ains infor mat ion about fr equency values, amplit udes,
and phases, as well as t heir st andar d deviat ions. These ar e all given as
columns. The fir st r ow of a freqfunc mat r ix cont ains int eger s, t hat , in coded
for m, descr ibe t he significance of t he column in quest ion. The int er pr et at ion of
t hese int eger s is as follows:
For t r ansfer funct ions and spect r a associat ed wit h out put number 1:
n = 0 : The column is a spect r um.
n = 50: The column cont ains st anda r d deviat ions of a spect r um.
n = 100: The column cont a ins fr equencies for t he spect r um.
n = k, wher e k is value bet ween 1 and 19: The column cont ains amplit ude
values for t he t r ansfer funct ion associat ed wit h input number k.
n = k + 20: The column cont ains phase values (in degr ees) for input number k.
n = k + 50: The column cont ains amplit ude st andar d deviat ions for input
number k.
n = k + 70: The column cont ains phase st andar d deviat ions for input number
k.
n = k + 100: The column cont ains t he fr equency values for input number k.
For t he same quant it ies associa t ed wit h out put number , add 1000
t o t he number s above.
ky ky 1 ( )
freqfunc
4-38
The specified fr equencies ar e for a discr et e-t ime model, which is by default ,
equa lly spaced fr om 0 (excluded) t o over 128 values. Her e T is t he
sampling int er va l (default = 1). For a cont inuous-t ime model, t he fr equencies
ar e 128 values, logar it hmica lly spr ea d over t hr ee deca des, up t o a decade over
t he under lying Nyquist fr equency (see th2ff).
Examples You can comput e and gr aph t he fr equency funct ions a t ar bit r ar y fr equency w (a
r ow vect or wit h an ar bit r ar y number of element s) wit h
g = spa(z,M,w)
g = th2ff(th,ku,w)
The MATLAB funct ion logspace is useful for cr eat ing such fr equency vect or s.
See Also bodeplot, etfe, ffplot, getff, nyqplot, sett, spa, th2ff
T
getff
4-39
get ff
Purpose Ret r ieve fr equency funct ions and spect r a fr om t he fr eqfunc for mat .
Syntax [w,amp,phas] = getff(g)
[w,amp,phas,sdamp,sdphas] = getff(g,ku,ky)
Description This funct ion ext r act s infor mat ion fr om t he fr eqfunc for mat for plot t ing as an
alt er nat ive t o bodeplot, ffplot, and nyqplot. Result s in t he fr eqfunc for mat
ar e obt ained by etfe, spa, and th2ff.
The ar gument g is t he fr equency funct ion or spect r um given in t he fr eqfunc
for mat . ku is t he chosen input number (only one) and ky is t he chosen out put
number . The noise sour ce is count ed as input number 0, so t hat ku = 0 will
ext r act spect r a l infor mat ion.
w is a vect or cont aining t he fr equency values (in r adians/second). amp cont ains
t he values of t he magnit ude (amplit ude) of t he fr equency funct ion and phas
cont ains t he phase values (in degr ees). The out put ar gument s sdamp and
sdphas cont ain t he cor r esponding st andar d deviat ions. All t his infor mat ion is
for input number ku and out put number ky. If sever al ent r ies in g cor r espond
t o t he same input -out put pair , t hen w, amp, phas, sdamp, and sdphas have t he
cor r esponding number of columns. The defa ult values of ku and ky a r e bot h 1,
unless g cont ains only spect r a. In t hat ca se getff ext r a ct s infor mat ion about
t he spect r um cor r esponding t o out put number ky.
Examples Make your own plot of t he per iodogr am wit h linear scales:
per = etfe(y);
[w,amp] = getff(per);
plot(w,amp)
title('Periodogram of seismic data')
getzp
4-40
get zp
Purpose Ext r act zer os and poles fr om t he zepo for mat .
Syntax [ze,po] = getzp(zepo)
[ze,po] = getzp(zepo,ku,ky)
Description The basic use of getzp is t o ext r a ct t he poles a nd zer os of t he coded for mat t hat
th2zp r esult s in. zepo cont ains t his infor mat ion and is t ypically t he out put of
th2zp. ku cont ains t he input number (just one) and ky t he out put number . The
noise sour ce number k is her e count ed a s input number k.
ze cont ains t he zer os and po t he poles of t he dynamics associa t ed wit h input
number ku and out put number ky. The default values of ku and ky ar e bot h 1.
Not e t hat for t he noise dyna mics, zepo nor mally just cont a ins infor mat ion
about t he zer os a nd poles fr om noise sour ce k t o out put number k, (no cr oss
t er ms). To ext r act t his infor mat ion ent er
[ze,po] = getzp(zepo,0,k)
See Also th2zp, zpform, zpplot
getmfth, getncap, gett
4-41
get mft h , get ncap, get t
Purpose Ext r act infor mat ion fr om t he t het a for mat .
Syntax mymfile = getmfth(th)
N = getncap(th)
T = gett(th)
Description These funct ions r et r ieve some infor mat ion t hat is coded int o t he t het a for mat .
mymfile is t he name of t he M-file t hat you wr it e t o define a model st r uct ur e
cr eat ed by mf2th.
N is t he number of dat a, fr om which a cer t ain model th is est ima t ed. If t he
model is not est imat ed N is r et ur ned as [].
T is t he sampling int er va l of t he model th. If T is negat ive, t he model is a
cont inuous-t ime one t hat has been est imat ed fr om dat a wit h t he sa mpling
int er val abs(T).
See Also mf2th, sett
ident
4-42
ident
Purpose Open t he gr aphical user int er face
Syntax ident
ident(session,directory)
Description ident by it self opens t he main int er face window, or br ings it for war d if it is
alr eady open.
session is t he name of a pr evious session wit h t he gr a phical int er fa ce, and
t ypically has ext ension .sid. directory is t he complet e pat h for t he locat ion of
t his file. If t he session file is on t he MATLABPATH, directory can be omit t ed.
When t he session is specified, t he int er face will open wit h t his session act ive.
Typing ident(session,directory) on t he MATLAB comma nd line, when t he
int er face is act ive, will load and open t he session in quest ion.
For mor e infor mat ion about t he gr aphical user int er face, see Chapt er 2 of t his
manual.
Examples ident(iddata1.sid)
ident(mydata.sid,\matlab\data\cdplayer\)
idfilt
4-43
idfil t
Purpose Filt er dat a using But t er wor t h filt er s.
Syntax zf = idfilt(z,ord,Wn)
[zf,thf] = idfilt(z,ord,Wn,hs)
Description idfilt comput es a But t er wor t h filt er of or der ord and filt er s all columns of t he
dat a mat r ix
z = [y u]
t hr ough t his filt er .
If hs is not specified and Wn cont ains just one element , a low pass filt er wit h
cut off fr equency Wn (measur ed as a fr act ion of t he Nyquist fr equency) is
obt ained. If hs =' high' a high pass filt er wit h t his cut off fr equency is
obt ained inst ead.
If Wn = [Wnl Wnh] is a vect or wit h t wo element s, a filt er (of or der 2*ord) wit h
passband bet ween Wnl and Wnh is obt ained is hs is not specified. If
hs = 'stop' a bandst op filt er wit h st op band bet ween t hese t wo fr equencies is
obt ained inst ead.
The out put ar gument thf is t he filt er given in t he t het a for mat .
It is common pr act ice in ident ificat ion t o select a fr equency band wher e t he fit
bet ween model a nd da t a is concent r at ed. Oft en t his cor r esponds t o bandpass
filt er ing wit h a pass band over t he int er est ing br eakpoint s in a Bode diagr am.
If ord is a posit ive int eger , a non-causa l, zer o-phase filt er is used for t he
filt er ing. If or d is a negat ive int eger , a causal filt er (of or der abs(ord)) is used
inst ead.
Algorithm The used filt er is t he same as butter in t he Signal Pr ocessing Toolbox would
give. Also, t he zer o-phase filt er is equiva lent t o filtfilt in t hat t oolbox.
References Ljung (1987), Chapt er 13.
idinput
4-44
idinput
Purpose Gener at e signals, t ypically t o be used as input s for ident ificat ion.
Syntax u = idinput(N)
u = idinput(N,type,band,levels)
u = idinput(N,'sine',band,levels,auxvar)
Description idinput gener at es input signals of differ ent kinds, t hat ar e t ypically used for
ident ificat ion pur poses. Only scala r input s ar e gener at ed.
N is t he number of dat a point s gener at ed, i.e., t he lengt h of u.
type defines t he t ype of input signal t o be gener at ed. This ar gument t akes one
of t he following values:
type = 'rs' : This gives a r andom, Gaussian signal.
type = 'rbs': This gives a r andom, binar y signal.
type = 'prbs': This gives a pseudo-r andom, bina r y signal.
type = 'sine': This gives a signal which is a sum of sinusoids.
Default is type = 'rbs'.
The fr equency cont ent s of t he signal is det er mined by t he a r gument band. For
t he choices type = 'rs', 'rbs', a nd 'sine', t his ar gument is a r ow-vect or wit h
t wo ent r ies
band = [wlow, whigh]
t hat det er mine t he lower and upper bound of t he pass-band. The fr equencies
wlow and whigh ar e expr essed in fr act ions of t he Nyquist fr equency. A whit e
noise char act er input is t hus obt ained for band = [0 1], which also is t he
default va lue.
For t he choice type = 'prbs' we have
band = [twologp, M]
wher e t he per iodicit y of t he gener at ed PRBS is 2^twologp 1, and M is such
t hat t he signal is const ant over int er vals of lengt h 1/M. twologp = 0 gives t he
maximum lengt h PRBS, cor r esponding t o twologp = 18. Also in t his ca se t he
default is band = [0 1].
idinput
4-45
The ar gument levels defines t he input level. It is a r ow vect or
levels = [minu, maxu]
such t hat t he signal u will a lways be bet ween t he values minu and maxu for t he
choices type = 'rbs', 'prbs' and 'sine'. For type = 'rs', t he signal level
is such t hat minu is t he mean value of t he signal, minus one st andar d deviat ion,
while maxu is t he mean value plus one st andar d deviat ion. Gaussian whit e
noise wit h zer o mean a nd var iance one is t hus obt ained for
levels = [1, 1], which is also t he default value.
For t he opt ion type = 'sine', t her e is a four t h ar gument
auxvar = [no_of_sinusoids, no_of_trials]
det er mining t he number of sinusoids t o be used in t he input signal. The
var iable no_of_trials det er mines how many t r ials t o be made t o minimize t he
signal amplit ude by assigning r andom phases t o t he differ ent sinusoids.
Default is auxvar = [10, 10].
Algorithm Ver y simple algor it hms ar e used. The fr equency cont ent s is achieved for 'rs'
by an eight h or der But t er wor t h, non-causal filt er , using idfilt. This is quit e
r elia ble. The same filt er is used for t he 'rbs' case, befor e making t he signal
binar y. This means t hat t he fr equency cont ent s is not guar ant eed t o be pr ecise
in t his case.
For t he 'sine' case, t he fr equencies ar e select ed t o be equally spr ea d over t he
chosen pass band, and each sinusoid is given a r andom phase. A number of
t r ials ar e made, and t he pha ses t hat give t he smallest signal amplit ude ar e
select ed. (The amplit ude is t hen sca led so as t o sat isfy t he specifica t ions of
levels.)
See Also The Fr equency Domain Syst em Ident ificat ion Toolbox cont ains sever al
commands for input design t hat ut ilize mor e sophist icat ed algor it hms.
Reference For PRBS, see, e.g., Sder st r m and St oica (1989), Chapt er C5.3.
idmodred
4-46
idmodr ed
Purpose Reduce t he or der of a model in t het a for mat .
Syntax THRED = idmodred(TH)
THRED = idmodred(TH,ORDER,OE)
Description This funct ion r educes t he or der of any model TH given in t he t het a for mat . The
r esult ing r educed or der model THRED is also in t he t het a for mat . This r educed
model is always r epr esent ed int er na lly in st at e-space for m wit h no fr ee
par amet er s, r egar dless of t he nat ur e of t he model TH.
The funct ion r equir es sever al r out ines in t he Cont r ol Syst ems Toolbox.
ORDER: The desir ed or der (dimension of t he st at e-space r epr esent at ion). If
ORDER = [], which is t he default , a plot will show how t he diagonal element s
of t he obser vabilit y and cont r ollabilit y Gr amians decay wit h t he or der of t he
r epr esent at ion. You will t hen be pr ompt ed t o select an or der based on t his plot .
The idea is t hat such a small element will have a negligible influence on t he
input -out put beha vior of t he model. It is t hus suggest ed t hat an or der is chosen,
such t hat only lar ge element s in t hese mat r ices ar e r et ained.
OE: If t he ar gument OE has t he va lue oe, t hen an out put er r or model THRED is
pr oduced, t hat is, one wit h t he Ka lman gain equal t o zer o (see (3.27) a nd (3.31)
in Chapt er 3, "Tut or ial"). Ot her wise (default ), also t he noise model is r educed.
The funct ion will r ecognize whet her TH is a cont inuous- or discr et e-t ime model
and per for m t he r educt ion accor dingly. The r esult ing model THRED will be of t he
same kind in t his r espect as TH.
Algorithm The funct ions (d)balreal and (d)modred fr om t he Cont r ol Syst ems Toolbox
ar e used. The plot , in case ORDER = [], shows t he vect or g as r et ur ned fr om
(d)balreal.
Examples Build a high or der mult ivar iable ARX model, r educe it s or der t o 3 and compar e
t he fr equency r esponses of t he or iginal and r educed models:
TH = arx([y u],[4ones(3,3),4ones(3,2),ones(3,2)]);
THRED = idmodred(TH,3);
bodeplot([trf(TH),trf(THRED)])
idmodred
4-47
Use t he r educed or der model a s init ia l condit ion for a t hir d or der st at e-space
model:
THI = ss2th(THRED);
THSS = pem([y u],THI);
See Also ss2th
idplot
4-48
idpl ot
Purpose Plot input -out put dat a.
Syntax idplot(z)
idplot(z,int,T,ny,pc)
Description z is t he out put -input da t a z = [y u] t o be gr aphed. A split plot is obt ained wit h
t he out put on t op and t he input s, one by one if sever a l, at t he bot t om. Pr essing
t he Re t urn key advances t he plot .
The dat a point s specified in t he r ow vect or int a r e gr a phed. The default value
of int is a ll t he dat a. You can use t he sampling int er va l T (default T = 1) t o
give cor r ect t ime axes.
The ar gument ny is t he number of out put s in t he dat a mat r ix. Default is
ny = 1. The input is piecewise const ant bet ween sampling point s, and it is
gr aphed accor dingly. If you pr efer linear int er polat ion bet ween input dat a
point s, use pc = 'li'. The default value is pc = 'pc'.
Examples Plot only a por t ion of t he dat a point s:
idplot(z,100:200)
idresamp
4-49
idr esamp
Purpose Resample dat a by int er polat ion and decima t ion.
Syntax zr = idresamp(z,R)
[zr, R_act] = idresamp(z,R,filter_order,tol)
Description z : The dat a t o be r esampled. Each column of z cont ains a signal.
zr : The r esampled dat a. The columns of zr cor r espond t o t hose of z.
R : The r esa mpling fact or . The new dat a r ecor d will cor r espond t o a new
sampling int er val of R t imes t he or iginal one. R > 1 t hus cor r esponds t o
decimat ion and R < 1 cor r esponds t o int er polat ion. Any posit ive r eal number
for R is allowed, but it will be r eplaced by a r at ional appr oxima t ion (R_act).
R_act : The act ually achieved r esampling fa ct or .
filter_order: The or der of t he pr esampling filt er s used befor e int er polat ion
and decimat ion. Default is 8.
tol : The t oler ance in t he r a t ional appr oximat ion of R. Default is 0.1.
Algorithm The r esampling fact or is fir st appr oximat ed by a r at iona l number by
[num,den] = rat(R,tol). The dat a ar e t hen int er polat ed by a fact or den and
t hen decimat ed by a fa ct or num. The int er polat ion and decima t ion ar e pr eceded
by pr efilt er ing, and follow t he same a lgor it hms a s in t he r out ines interp a nd
decimate in t he Signal Pr ocessing Toolbox.
Caution For signals t hat have much ener gy ar ound t he Nyquist fr equency (like
piece-wise const ant input s), t he r esampled wavefor m may look ver y differ ent ,
due t o t he pr efilt er ing effect s. The fr equency and infor mat ion cont ent s for
ident ificat ion is, however , not mishandled.
Example Resample by a fa ct or 1.5 and compar e t he signals.
plot(t,u)
[ur,ra] = idresamp(u,1.5);
plot(t,u,rat,ur)
idsim
4-50
idsi m
Purpose Simulat e syst ems specified in t het a for mat .
Syntax y = idsim([u e],th)
[y, ysd] = idsim(u,th)
Description th descr ibes an ar bit r ar y model in t he t het a for mat . idsim r et ur ns y cont aining
t he simulat ed out put , cor r esponding t o t he input sequence u (one column for
each input ) and t he noise e. If e is omit t ed, a noise-fr ee simulat ion is obt ained.
The noise-sequence e is scaled by , wher e is t he noise var iance (loss
funct ion) as specified by th. To a chieve t he cor r ect noise effect , give e zer o mean
and unit var iance.
For mult i-out put syst ems simulat ed wit h noise, e should have as many
columns as t he number s of out put s. The noise is aga in sca led using t he noise
covar ia nce mat r ix in th.
The second out put ar gument is t he st andar d deviat ion of t he simulat ed out put .
This opt ion is however not available for st at e-space models.
If th is a cont inuous-t ime model, it is fir st conver t ed t o discr et e t ime wit h
sampling int er va l abs(T). See Some Specia l Topics on page 3-68
Examples Simulat e a given syst em th0 (for example cr eat ed by poly2th):
e = randn(500,1);
u = idinput(500,prbs);
y = idsim([u e],th0);
Validat e a model by compar ing a measur ed out put y wit h one simulat ed using
an est imat ed model th:
yh = idsim(u,th);
plot([y yh])
Algorithm In ca se t he model is of input -out put t ype, idsim uses t he MATLAB filter
funct ion. For st at e-space models, it uses ltitr.
See Also idsimsd, poly2th

idsimsd
4-51
idsi msd
Purpose Simulat e t het a for mat syst em wit h uncer t aint y.
Syntax idsimsd(u,th)
idsimsd(u,th,N,noise)
Description u is a column vect or (mat r ix) cont aining t he input (s). th is a model given in t he
t het a for ma t (see theta). N r andom models ar e cr eat ed, a ccor ding t o t he
covar iance infor mat ion given in th. The r esponses of ea ch of t hese models t o
t he input u ar e comput ed and gr aphed in t he same diagr am. If
noise = 'noise', noise is added t o t he simulat ion, in accor dance wit h t he noise
model of th, and it s own uncer t aint y.
The default values a r e
N = 10
noise = 'nonoise'
Examples Plot t he st ep r esponse of t he model th and evaluat e how it var ies in view of t he
models uncer t aint y:
step1 = [zeros(5,1); ones(20,1)];
idsimsd(step1,th)
See Also idsim, th2ff, th2zp
ivar
4-52
ivar
Purpose Est imat e t he pa r amet er s of an AR model using an appr oximat ely opt imal
choice of inst r ument a l var ia ble pr ocedur e.
Syntax th = ivar(y,na)
th = ivar(y,na,nc,maxsize,T)
Description The pa r amet er s of an AR model st r uct ur e
ar e est ima t ed using t he inst r ument al var iable met hod. y is t he signa l t o be
modeled, ent er ed as a column vect or . na is t he or der of t he A polynomial (t he
number of A par amet er s). The r esult ing est ima t e is r et ur ned as th, in t het a
for mat . The r out ine is for scalar signa ls only.
In t he above model, is an ar bit r ar y pr ocess, assumed t o be a moving
aver age pr ocess of or der nc, possibly t ime var ying. (Default is nc = na.)
Inst r ument s ar e chosen as appr opr iat ely filt er ed out put s, delayed nc st eps.
The opt ional ar gument s maxsize and T ar e expla ined under auxvar.
Examples Compar e spect r a for sinusoids in noise, est imat ed by t he IV met hod and
est ima t ed by t he for war d-ba ckwar d least -squar es met hod:
y = sin([1:500]'1.2) + sin([1:500]'1.5)...
+ 0.2randn(500,1);
thiv = ivar(y,4);
thls = ar(y,4);
giv = th2ff(thiv);
gls = th2ff(thls);
bodeplot([giv gls])
See Also ar, etfe, spa
References St oica, P. et al., Opt imal Inst rumental variable est imates of the AR-paramet ers
of an ARMA process, IEEE Tr ans. Aut om. Cont r ol, Vol AC-30, 1985, pp.
1066-1074.
A q ( )y t ( ) v t ( ) =
v t ( )
ivstruc
4-53
ivst r uc
Purpose Comput e fit bet ween simulat ed a nd measur ed out put for a gr oup of model
st r uct ur es.
Syntax v = ivstruc(ze,zv,NN)
v = ivstruc(ze,zv,NN,p,maxsize)
Description NN is a mat r ix t hat defines a number of differ ent st r uct ur es of t he ARX t ype.
Each r ow of NN is of t he for m
nn = [na nb nk]
wit h t he same int er pr et at ion as descr ibed for arx. See struc for easy
gener at ion of t ypica l NN mat r ices for single-input syst ems.
Each of ze and zv ar e ma t r ices cont a ining out put -input dat a [y u]. For
mult i-input syst ems, u has t he cor r esponding number of columns. Models for
each model st r uct ur e defined in NN a r e est imat ed using t he inst r ument al
var iable (IV) met hod on dat a set ze. The est imat ed models a r e simulat ed using
t he input s fr om dat a set zv. The nor malized quadr at ic fit bet ween t he
simulat ed out put and t he measur ed out put in zv is for med and r et ur ned in v.
The r ows below t he fir st r ow in v ar e t he t r anspose of NN, and t he last r ow
cont ains t he logar it hms of t he condit ion number s of t he IV ma t r ix
A lar ge condit ion number indicat es t hat t he st r uct ur e is of unnecessar ily high
or der (see page 415 in Ljung (1987)).
The infor mat ion in v is best ana lyzed using selstruc.
If p is equal t o zer o, t he comput a t ion of condit ion number s is suppr essed. For
t he use of maxsize, see auxvar.
The r out ine is for single-out put syst ems only.
IMPORTANT: The IV met hod used does not guar ant ee t hat t he obt ained
models a r e st able. The out put -er r or fit calcula t ed in v may t hen be mislea ding.
t ( )
T
t ( )

ivstruc
4-54
Examples Compar e t he effect of differ ent or der s and delays, using t he same dat a set for
bot h t he est imat ion and va lidat ion:
v = ivstruc(z,z,struc(1:3,1:2,2:4));
nn = selstruc(v)
th = iv4(z,nn);
Algorithm A maximum or der ARX model is comput ed using t he least -squar es met hod.
Inst r ument s ar e gener at ed by filt er ing t he input (s) t hr ough t his model. The
models ar e subsequent ly obt ained by oper at ing on submat r ices in t he
cor r esponding lar ge IV mat r ix.
See Also arxstruc, iv4, selstruc, struc
ivx
4-55
ivx
Purpose Est imat e t he pa r amet er s of an ARX model using t he inst r ument al var iable (IV)
met hod wit h a r bit r ar y inst r ument s.
Syntax th = ivx(z,nn,x)
th = ivx(z,nn,x,maxsize,T)
Description ivx is a r out ine a nalogous t o t he iv4 r out ine, except t hat you can use ar bit r a r y
inst r ument s. These a r e cont a ined in t he mat r ix x. Ma ke t his t he same size as
t he out put , i.e., t he fir st column(s) of z. The inst r ument s used ar e t hen
ana logous t o t he r egr ession vect or it self, except t ha t y is r eplaced by x.
Not e t hat ivx does not r et ur n any est imat ed covar iance mat r ix for th, since
t hat r equir es addit ional infor mat ion.
Use iv4 as t he basic IV r out ine for ARX model st r uct ur es. The ma in int er est in
ivx lies in it s use for nonst a ndar d sit uat ions; for example when t her e is
feedba ck pr esent in t he dat a , or when ot her inst r ument s need t o be t r ied out .
Not e t ha t t her e is also an IV ver sion t hat aut omat ica lly gener a t es inst r ument s
fr om cer t ain filt er s you define (t ype help iv).
See Also iv4, ivar
References Ljung (1987), page 198.
iv4
4-56
iv4
Purpose Est imat e t he pa r amet er s of an ARX model using a n appr oximat ely opt imal
four -st age inst r ument al var iable (IV) pr ocedur e.
Syntax th = iv4(z,nn)
th = iv4(z,nn,maxsize,T)
Description This r out ine is an alt er nat ive t o arx and t he use of t he ar gument s ar e ent ir ely
analogous t o t he arx funct ion. The main differ ence is t hat t he pr ocedur e is not
sensit ive t o t he color of t he noise t er m in t he model equat ion.
For an int er pr et at ion of t he loss funct ion (innova t ions covar iance mat r ix),
consult Some Special Topics on pa ge 3-68.
Examples Her e is an example of a t wo-input one-out put syst em wit h differ ent delays on
t he input s and :
z = [y u1 u2];
nb = [2 2];
nk = [0 2];
th = iv4(z,[2 nb nk]);
Algorithm The fir st st age uses t he arx funct ion. The r esult ing model gener at es t he
inst r ument s for a second-st age IV est imat e. The r esiduals obt ained fr om t his
model ar e modeled as a high-or der AR model. At t he four t h st age, t he
input -out put dat a ar e filt er ed t hr ough t his AR model a nd t hen subject ed t o t he
IV funct ion wit h t he same inst r ument -filt er s a s in t he second st a ge.
For t he mult i-out put case, opt imal inst r ument s ar e obt a ined only if t he noise
sour ces at t he differ ent out put s have t he same color . The est ima t es obt ained
wit h t he r out ine ar e r easonably accur at e t hough even in ot her cases.
See Also arx, oe
References Ljung (1987), equat ions (15.21)-(15.26).
e t ( )
u
1
u
2
mf2th
4-57
mf2t h
Purpose Package model st r uct ur es you define int o t he t het a model for mat .
Syntax th = mf2th(model,cd,parval)
th = mf2th(model,cd,parval,aux,lambda,T)
Description th is r et ur ned as a model st r uct ur e in t he t het a for mat . model is t he name of
an M-file t ha t defines how t he st at e-spa ce ma t r ices depend on t he par amet er s
t o be est imat ed. The for mat of t his M-file is given below. The ar gument cd must
be a ssigned eit her t he value 'c' which designat es t hat t he under lying
par a met er izat ion r efer s t o a cont inuous-t ime model, or t he va lue 'd',
indicat ing t ha t t he model par amet er izat ion is inher ent ly a discr et e-t ime one.
The a r gument parval cont ains t he nominal values of t he par amet er s. This is a
r ow vect or of t he same lengt h as t he number of fr ee par amet er s in t he model
st r uct ur e. The a r gument aux is a mat r ix of auxiliar y var iables t ha t t he M-file
ca n use for var ious pur poses.
T denot es t he sampling int er val of t he dat a, for which t he model is going t o be
est imat ed (and t he sampling int er va l t hat is used when t he model is used for
simulat ion and pr edict ion). Give T a posit ive value even if t he under lying model
is defined t o be cont inuous t ime.
The model st r uct ur e cor r esponds t o t he gener al linea r st at e-spa ce st r uct ur e
The mat r ices in t his t ime-discr et e model can be par a met er ized in an ar bit r ar y
way by t he vect or . Wr it e t he for mat for t he M-file a s follows:
[A,B,C,D,K,x0] = mymfile(pars,T,aux)
Her e t he r ow vect or pars cont ains t he par amet er s , and t he out put
ar gument s A, B, C, D, K, and x0 ar e t he mat r ices in t he discr et e-t ime model
descr ipt ion t hat cor r espond t o t his value of t he par amet er s.
x t T + ( ) A ( )x t ( ) B ( )u t ( ) K ( )e t ( ) + + =
x 0 ( ) x
0
( ) =
y t ( ) C ( )x t ( ) D ( )u t ( ) e t ( ) + + =

mf2th
4-58
T is t he sa mpling int er val, and aux is any mat r ix of auxiliar y var iables wit h
which you want t o wor k. (In t hat wa y you can change cer t ain const ant s and
ot her aspect s in t he model st r uct ur e wit hout having t o edit t he M-file.) Not e
t hat t he t wo ar gument s T and aux must be included in t he funct ion head of t he
M-file, even if t hey ar e not ut ilized wit hin t he M-file.
If t he under lying pa r amet er izat ion is a cont inuous-t ime one, it is st ill t he
discr et e-t ime model mat r ices, cor r esponding t o t he sampling int er val T t ha t
should be deliver ed by t he M-file. However . it is desir able t hat if t he M-file
myfile is called wit h a negat ive value of T, it out put s t he mat r ices of t he
cor r esponding cont inuous-t ime st at e-space model. If such a feat ur e is included
in t he M-file, use cd = 'c'. This allows for easy t r a nsfor ma t ions bet ween
cont inuous and discr et e t ime using t he nor mal funct ions thc2thd and thd2thc.
Defining Model St r uct ur es on page 3-29 cont ains sever al examples of t ypical
M-files t hat define model st r uct ur es.
Examples Use t he M-file 'mynoise' given in Sect ion 6 t o obt ain a physica l
par amet r iza t ion of t he Ka lman gain:
thn = mf2th('mynoise','d',[0.1,2,1,3,0.2],1)
th = pem(z,thn)
midprefs
4-59
midpr efs
Purpose Select a dir ect or y for idprefs.mat, a file t hat st or es t he gr aphica l user
int er faces st ar t -up infor mat ion.
Syntax midprefs
midprefs(path)
Description The gr a phica l user int er face ident allows a lar ge number of var iables for
cust omized choices. These include t he window layout , t he defa ult choices of
plot opt ions, and names and dir ect or ies of t he four most r ecent sessions wit h
ident. This infor mat ion is st or ed in t he file idprefs.mat, which should be
placed on t he user s MATLABPATH. The default , aut omat ic locat ion for t his file is
in t he sa me dir ect or y as t he user s startup.m file.
midprefs is used t o select or change t he dir ect or y wher e you st or e
idprefs.mat. Eit her t ype midprefs, and follow t he inst r uct ions, or give t he
dir ect or y name as t he ar gument . Include all dir ect or y delimit er s as in t he PC
ca se
midprefs('c:\matlab\toolbox\local\')
or in t he UNIX case
midprefs('/home/ljung/matlab/')
Warning The file idprefs.mat cont ains a var iable wit h t he dir ect or y name, which also
needs t o be updat ed. Ther efor e, do not just move it using t he file syst em.
Alwa ys use midprefs t o cha nge t he dir ect or y for idprefs.mat.
modstruc
4-60
modst r uc
Purpose Define st a t e-space st r uct ur e wit h unknown element s.
Syntax ms = modstruc(A,B,C,D,K)
ms = modstruc(A,B,C,D,K,x0)
Description modstruc is, like canform, a funct ion t hat defines model par amet er iza t ions in
st a t e-space for m, which ar e used in ms2th t o cr ea t e model st r uct ur es in t he
t het a for mat . The only use of t he r esult ing ma t r ix ms is as an input t o ms2th.
The model consider ed is in st at e-spa ce for m:
The funct ion applies bot h t o t he cont inuous and discr et e-t ime cases; which one
is det er mined only when t he st r uct ur e is for med wit h ms2th.
The input ar gument s A, B, C, D, K, and x0 ar e t he ma t r ices of t he above
st a t e-space model. Numer ical values in t hese mat r ices indicat e fixed (known)
ent r ies, while t he symbol NaN ma r ks an element t hat is not known and you
need t o est imat e.
The default value of t he init ial st at e vect or x0 is t he zer o vect or , but it may a lso
cont ain par amet er s you need t o est imat e.
Examples Define a cont inuous-t ime model st r uct ur e in diagonal for m wit h t he t wo
(r eal) poles a nd t he numer at or unknown:
A = [NaN,0;0,NaN];
B = [NaN;NaN];
C = [1,1];
D = 0;
K = [0;0];
ms = modstruc(A,B,C,D,K)
th = ms2th(ms,'c');
See Also canform, fixpar, ms2th, thinit, unfixpar
x

t ( ) A ( )x t ( ) B ( )u t ( ) K ( )e t ( ) + + =
x 0 ( ) x
0
( ) =
y t ( ) C ( )x t ( ) D ( )u t ( ) e t ( ) + + =
ms2th
4-61
ms2t h
Purpose Package st a ndar d st at e-space par amet er izat ions int o t he t het a model for mat .
Syntax th = ms2th(ms)
th = ms2th(ms,cd,parval,lambda,T)
Description The funct ion r et ur ns th as a model st r uct ur e in t he t het a for mat for fur t her use
in est ima t ing, simulat ing, and a nalyzing models. The ar gument ms defines
which par a met er s ar e fixed and which ones you need t o est ima t e. It is t ypically
for med by modstruc or canform.
The ar gument cd indicat es whet her t he st at e-space mat r ices in ms r efer t o a
cont inuous-t ime model (cd = 'c') or a discr et e-t ime model (cd = 'd').
cd = 'd' is t he defa ult .
For a cont inuous-t ime model t her e ar e t wo opt ions for how t o sa mple it , as it is
fit t ed t o obser ved sample dat a (in pem): By select ing cd = czoh (cont inuous,
zer o or der hold) t he input is assumed t o be piecewise const a nt over t he
sampling int er val. By select ing cd = cfoh (cont inuous, fir st or der hold), t he
input is supposed t o be piecewise linear bet ween t he samples. This means t hat
t he cont inuous-t ime input u(t ) is obt ained by linea r int er polat ion bet ween t he
sampled values. Use cd = czoh (which is t he default for cont inuous-t ime
models) if t he syst em has been cont r olled using a piece-wise const ant input .
Use cd = 'cfoh' if t he input has been a cont inuous funct ion dur ing t he dat a
acquisit ion.
The r ow vect or parval cont a ins t he nominal values of t he fr ee par amet er s
(t hose t hat cor r espond t o NaN in ms). These nominal va lues ar e used as init ial
est imat es when t he par amet er s in th ar e ident ified wit h pem. They ar e also
used whenever t he model th is simulat ed or analyzed. The default value of
parval is all zer os.
The number ing of t he par amet er s in parval (as well as in all ot her cont ext s
in which t he model par a met er s ar e list ed) is as follows. The mat r ix A is fir st
scanned, r ow by r ow, for fr ee par amet er s, t hen t he mat r ix B is scanned, again
r ow by r ow, and t hen C, D, K, a nd X0 ea ch of t hem r ow by r ow. The or der in
which t he fr ee par amet er s ar e found by t his scanning defines t he or der ing in
parval.
ms2th
4-62
Not e t hat set t ing all init ial est imat es equal t o zer o is not a good st ar t ing point
for t he it er a t ive sear ch for par amet er est imat es in pem, since t his case oft en
cor r esponds t o a nonobser vable/noncont r olla ble model. It is bet t er t o give mor e
r ealist ic values of parval or t o r andomize t hem using thinit.
The a r gument lambda gives t he covar iance ma t r ix of t he innovat ion for t he
sampling int er val indicat ed in T. The default value of lambda is t he unit mat r ix.
T denot es t he sampling int er val of t he dat a, for which t he model is going t o be
est ima t ed (and t he sampling int er va l t hat is used when t he model is used for
simulat ion and pr edict ion). Give T a posit ive value even if t he under lying model
is defined t o be cont inuous t ime.
Examples Define a cont inuous-t ime model st r uct ur e cor r esponding t o
wit h init ial values
and est ima t e t he fr ee par a met er s:
A = [NaN,0;0,NaN];
B = [NaN;NaN];
C = [1,1];
ms = modstruc(A,B,C,0,[0;0]);
th = ms2th(ms,'c',[0.2,0.3,2,4]);
th = pem(z,th);
See Also canform, fixpar, modstruc, pem, thinit, unfixpar
e t ( )
x


1
0
0
2
x

3

4
u + =
y
1 1
x e + =

0.2 0.3 2 4
=
nuderst
4-63
nuder st
Purpose Select t he st ep size for numer ica l differ ent iat ion.
Syntax nds = nuderst(pars)
Description The funct ion pem uses numer ica l differ ent iat ion wit h r espect t o t he model
par a met er s when a pplied t o st at e-space st r uct ur es. The same is t r ue for t he
funct ions th2ff and th2zp when t he par amet er covar iance infor mat ion is
t r anslat ed t o fr equency funct ion and zer o-pole accur acy (again only for
st a t e-space st r uct ur es). Finally, t he comma nd thd2thc uses numer ical
differ ent iat ion when t r anslat ing t he covar iance infor mat ion for any model
st r uct ur e.
The st ep size used in t hese numer ical der ivat ives is det er mined by t he M-file
nuderst. The out put ar gument nds is a r ow vect or whose k-t h ent r y gives t he
incr ement t o be used when differ ent iat ing wit h r espect t he k-t h element of t he
par a met er vect or pars.
The default ver sion of nuderst uses a ver y simple met hod. The st ep size is t he
maximum of and t imes t he absolut e value of t he cur r ent pa r amet er .
You can adjust t his t o t he act ual va lue of t he cor r esponding par amet er by
edit ing nuderst. Not e t ha t t he nominal va lue, for example 0, of a par amet er
may not r eflect it s nor ma l size.
10
7
10
4
nyqplot
4-64
nyqplot
Purpose Plot Nyquist cur ve of fr equency funct ion.
Syntax nyqplot(g)
nyqplot([g1 g2 ... gn])
nyqplot(g,sd,mode)
Description nyqplot is an alt er na t ive t o bodeplot and ffplot t o gr aph fr equency funct ions
in t he fr eqfunq for ma t . The Nyquist diagr am of a fr equency funct ion is a gr aph
of it s imaginar y par t against it s r eal par t .
The ar gument g is t he fr equency funct ion in quest ion, given in t he fr eqfunc
for mat , t ypically as t he out put of th2ff, spa, or etfe. Sever al plot s ar e
obt ained in t he same diagr am by simply list ing t he differ ent fr equency
funct ions aft er each ot her . These need not be specified at t he same fr equencies
(alt hough t hey have t o be of t he same lengt h).
If t he fr equency funct ion(s) cont ains infor mat ion about sever al differ ent
input -out put pair s, t he default is t hat t he Nyquist plot for each pair is gr a phed
separ at ely. Pr essing t he Re t urn key advances fr om one pair t o t he next . Wit h
mode = 'same' all plot s cor r esponding t o t he same input ar e given in t he same
diagr am.
If sd is given a value lar ger t han 0, a confidence r egion ar ound t he nominal
Nyquist plot is mar ked wit h dash-dot t ed lines. This r egion cor r esponds t o sd
st a ndar d deviat ions. (The infor mat ion in g does not cont ain t he cor r elat ion
bet ween t he magnit ude and phase est imat es. The confidence r egion is
t her efor e only appr oximat e. It is comput ed by plot t ing t he t wo cur ves ,
wher e is t he st a ndar d deviat ion (ma gnit ude a nd phase) of g.)
Examples g = th2ff(thmod)
nyplot(g,3)
See Also bodeplot, etfe, ffplot, freqfunc, spa, th2ff
g sd g t
g
n4sid
4-65
n4sid
Purpose Est imat e st at e-space models using a subspace met hod.
Syntax TH = n4sid(z)
[TH,AO] = n4sid(z,order,ny,auxord,dkx,maxsize,T,'trace')
Description The funct ion n4sid est imat es models in st at e-space for m, and r et ur ns t hem in
t he t het a for mat . It handles an ar bit r ar y number of input and out put s,
including t he t ime ser ies case (no input ). The st a t e-space model is in t he
innovat ions for m:
x(t+1) = A x(t) + B u(t) + K e(t)
y(t) = C x(t) + D u(t) + e(t)
TH: The r esult ing model in t het a for mat . No covar iance infor mat ion a bout t he
uncer t aint y of t he model is cont ained in TH.
AO: See under auxord below.
z: A ma t r ix t hat cont ains t he out put -input dat a: z = [y u], wher e y and u ar e
column vect or s. In t he mult i-var iable case, u a nd y cont ain one column for each
out put a nd input . In t he t ime ser ies ca se z = y.
order: The desir ed or der of t he st at e-space model. If order is ent er ed as a r ow
vect or (like order = [1:10], which is t he default choice), pr elimina r y
ca lculat ions for all t he indicat ed or der s ar e car r ied out . A plot will t hen be
given t hat shows t he r ela t ive impor t ance of t he dimension of t he st a t e vect or .
Mor e pr ecisely, t he singular values of t he Hankel mat r ices of t he impulse
r esponse for differ ent or der s ar e gr a phed. You will be pr ompt ed t o select t he
or der , based on t his plot . The idea is t o choose an or der such t hat t he singular
values for higher or der s ar e compar a t ively small. If order = 'best', a model
of best (default choice) or der is comput ed, among t he or der s 1:10.
ny: The number of out put s in t he dat a set z. Default is ny = 1.
auxord: An auxiliar y or der used by t he algor it hm. This can be seen as a
pr edict ion hor izon, and it should be lar ger t ha n t he or der . The default value is
auxord = 1.2order+3. The choice of auxord could ha ve a subst ant ial influence
on t he model qualit y, and t her e ar e no simple r ules for how t o choose it . If you
ent er auxord as a r ow vect or (like auxord = [5:15]), models for all t hese values
will be comput ed. The pr edict ion er r or for each of t he models ar e comput ed
using t he dat a z, and t hat va lue of auxord t hat minimizes t he fit will be
select ed. This value is r et ur ned a s t he out put ar gument AO. If t he last given
n4sid
4-66
ar gument t o n4sid is 'trace', infor mat ion a bout t he differ ent choices of
auxord will be given t o t he scr een. Not e t hat auxord can be chosen a s a vect or ,
only if order is a given value (no vect or ).
dkx: The ar gument dkx det er mines some addit iona l st r uct ur e of t he mat r ices
of t he st at e-space model t o be est imat ed. It is a r ow vect or wit h t hr ee ent r ies:
dkx = [d, k, x]
The ent r ies r efer t o t he mat r ices K, D, and t he init ia l st at e X(0) of t he
st a t e-space model given above.
k = 1 indicat es t hat t he K-mat r ix in t he model (t he Kalman Gain) will be
est ima t ed, while k = 0 means t ha t t his mat r ix will be fixed t o zer o. This will
give a so called out put er r or model.
d = 1 indicat es t hat D-mat r ix in t he model (t he dir ect t er m fr om input t o
out put ) will be est imat ed, while d = 0 mea ns t hat t his mat r ix is fixed t o zer o.
This also implies t ha t t her e will be a delay of (at least ) one sa mple bet ween t he
input and t he out put .
x = 1 indicat es t hat t he init ial st at e x(0) will be est imat ed and st or ed in t he
model TH, while x = 0 means t hat t he init ial st at e will be t a ken as zer o. Not e
t hat t he init ial st at e is somet hing t ha t r elat es t o t he par t icula r da t a set for
which t he model was est imat ed, and may not be r elevant when t he model is
evaluat ed on a new set of da t a.
Default is
dkx = [0, 1, 0]
The opt ional var iables maxsize a nd T ar e explained under AUXVAR.
trace: Let t ing t he last input ar gument be 'trace', gives infor mat ion t o t he
command line a bout t he choice of auxiliar y or der , in case t his is given as a
vect or .
Algorithm The funct ion implement s t he met hods descr ibed in P. Van Over schee a nd B. De
Moor : N4SID:Subspace algor it hms for t he ident ica t ion of combined
det eminist ic-st ochast ic syst ems. Automat ica, Vol. 30, No 1, pp. 75-93, 1994.
The algor it hm is complement ed wit h a separ at e linear lea st -squar es st ep t o
r e-est imat e t he ma t r ices B, D, and X(0), which ent er linear ly.
n4sid
4-67
Examples Build a fift h or der model fr om dat a wit h t hr ee input s and t wo out put s. Tr y
sever al choices of auxiliar y or der s. Look a t t he fr equency r esponse of t he model.
(Not e t hat t her e will be no confidence int er vals!)
z = [y1 y2 u1 u2 u3];
th = n4sid(z,5,2,7:15,trace);
bodeplot(trf(th))
Use t he r esult ing model as init ial values for est imat ing a st at e-space model of
t he same or der using t he pr edict ion er r or met hod:
thi = ss2th(th);
thp = pem(z,thi);
See Also auxvar, canstart, pem, theta
oe
4-68
oe
Purpose Est imat e t he pa r amet er s of an Out put -Er r or model.
Syntax th = oe(z,nn)
th = oe(z,nn,trace)
[th, iter_info] = oe(z,nn,maxiter,tol,lim,maxsize,T,'trace')
Description The pa r amet er s of t he Out put -Er r or model st r uct ur e
ar e est ima t ed using a pr edict ion er r or met hod.
Mat r ix z cont ains t he out put -input da t a z = [y u] wher e y and u a r e column
vect or s. nn can be given eit her as
nn = [nb nf nk]
or as
nn = thi
In t he for mer case, nb, and nf a r e t he or der s of t he Out put -Er r or model and nk
is t he delay. In t he lat t er case, t his is an init ial value for t he est imat e, given in
t het a for mat . See The Syst em Ident ificat ion Pr oblem on page 3-8 for an exact
definit ion of t he or der s and delay.
th is r et ur ned wit h t he r esult ing pa r amet er est imat es and est imat ed
covar ia nces, st or ed in t het a for mat .
The opt ional var iables iter_info, lim, maxiter, maxsize, tol, and T ar e
explained under auxvar.
For mult i-input models, nb, nf, and nk ar e r ow vect or s, such t hat ent r y number
i gives t he or der s and delays associat ed wit h t he i-t h input .
oe does not suppor t mult i-out put models. Use st at e-space model for t his case
(see canstart, n4sid, and pem)
If a last ar gument 'trace' is supplied, infor mat ion about t he pr ogr ess of t he
it er at ive sear ch for t he model will be fur nished t o t he MATLAB comma nd
window.
y t ( )
B q ( )
F q ( )
----------- u t nk ( ) e t ( ) + =
oe
4-69
Algorithm oe uses essent ially t he same algor it hm a s armax wit h modificat ions t o t he
comput at ion of pr edict ion er r or s and gr adient s.
See Also armax, auxvar, bj, pem, theta
pe
4-70
pe
Purpose Comput e t he pr edict ion er r or s associat ed wit h a model and a dat a set .
Syntax e = pe(z,th)
Description Mat r ix z is t he out put -input dat a set , z = [y u], a nd th is a model specified in
t het a for mat . e is r et ur ned cont aining t he pr edict ion er r or s t hat r esult when
model th is applied t o t he dat a,
See Also resid, theta
e t ( ) H
1
q ( ) y t ( ) G q ( )u t ( ) [ ] =
pem
4-71
pem
Purpose Est imat e t he par amet er s of gener al linear models.
Syntax th = pem(z,nn)
th = pem(z,nn,'trace')
[th, iter_info] = pem(z,nn,index,maxiter,tol,lim,...
maxsize,T,'trace')
Description The funct ion pem handles all model st r uct ur es, including t he gener a l
mult i-input -single-out put st r uct ur e
and gener al st r uct ur es defined by fixpar, mf2th, ms2th, thinit, and
unfixpar. Mult ivar iable ARX st r uct ur es defined by arx2th ar e also cover ed.
The mat r ix z cont ains t he out put -input dat a z = [y u], wher e y a nd u ar e
column vect or s (in t he mult i-var iable case u and y cont ain one column for each
input and out put ).
nn is given eit her as
nn = [na nb nc nd nf nk]
or as
nn = thi
In t he for mer case, na, nb, nc, nd, and nf ar e t he or der s of t he model a nd nk is
t he delay(s). For mult i-input syst ems, nb, nf, and nk a r e r ow vect or s giving t he
or der s and delays of each input . (See Sect ion 3 of t he Tutorial for exact
definit ions of t he or der s).
In t he lat t er case, thi defines a model st r uct ur e and an init ial value for t he
est imat e, given in t het a for mat .
th is r et ur ned wit h t he r esult ing par amet er est ima t es a nd est imat ed
covar iances, st or ed in t het a for mat .
The opt ional ar gument index is a r ow vect or t hat cont ains t he indices of t he
par a met er s t hat ar e t o be est imat ed. The ot her s r emain fixed t o t heir nominal
values. The or der ing of t he par amet er s is defined under th2par. The default
A q ( )y t ( )
B
1
q ( )
F
1
q ( )
--------------u
1
t nk
1
( )
B
nu
q ( )
F
nu
q ( )
----------------- u
nu
t nk
nu
( )
C q ( )
D q ( )
------------e t ( ) + + + =
pem
4-72
value of index is t ha t all fr ee par amet er s ar e est ima t ed. The opt ional var iables
iter_info, lim, maxiter, maxsize, tol, and T ar e explained under auxvar.
If a last ar gument trace is supplied, infor mat ion about t he pr ogr ess of t he
it er at ive sear ch for t he model will be fur nished t o t he MATLAB comma nd
window.
For t he special cases of single-input models of Out put -Er r or , ARMAX, and
Box-J enkins t ype, it is mor e efficient t o use oe, armax, and bj.
Examples Her e is an example of a syst em wit h t hr ee input s and t wo out put s. A canonical
for m st at e-spa ce model of or der 5 is sought .
z = [y1 y2 u1 u2 u3];
thc = canstart(z,5,3)
th = pem(z,thc);
Algorithm pem uses essent ially t he same algor it hm as armax wit h modificat ions t o t he
comput at ion of pr edict ion er r or s and gr adient s.
See Also armax, auxvar, bj, oe, theta
poly2th
4-73
poly2t h
Purpose Const r uct t het a for mat ma t r ix for input -out put models.
Syntax th = poly2th(A,B)
th = poly2th(A,B,C,D,F,lam,T)
Description poly2th cr eat es a mat r ix cont aining par a met er s t hat descr ibe t he gener al
mult i-input -single-out put model st r uct ur e:
A, B, C, D, and F specify t he polynomial coefficient s.
For single-input syst ems, t hese ar e all r ow vect or s in t he st andar d MATLAB
for mat :
A = [1 a1 a2 ... ana]
A, C, D, and F all st ar t wit h 1, while B cont ains leading zer os t o indicat e t he
delays. See Defining Model St r uct ur es on page 3-29.
For mult i-input syst ems, B and F ar e mat r ices wit h one r ow for each input .
For t ime ser ies, B a nd F ar e ent er ed as empt y mat r ices:
B = []; F = [];
lam is t he va r iance of t he whit e noise sequence , while T is t he sampling
int er val.
A negat ive value of T indicat es t hat t he model is a cont inuous-t ime one. Then
t he int er pr et a t ion of t he ar gument s is t ha t
A = [1 2 3 4]
cor r esponds t o t he polynomia l in t he Laplace var ia ble s, and so
on. For cont inuous-t ime syst ems lam indicat es t he level of t he spect r al densit y
of t he innova t ions. (A sa mpled ver sion of t he model has t he innovat ions
var iance lam/T, wher e T is t he sa mpling int er val. The cont inuous-t ime model
must ha ve a whit e noise component in it s noise descr ipt ion. See Some Special
Topics on page 3-68.
A q ( )y t ( )
B
1
q ( )
F
1
q ( )
--------------u
1
t nk
1
( ) =
B
nu
q ( )
F
nu
q ( )
-----------------u
nu
t nk
nu
( )
C q ( )
D q ( )
------------e t ( ) + +
e t ( )
s
3
2s
2
3s 4 + + +
poly2th
4-74
Tr ailing ar gument s C, D, F, lam, and T can be omit t ed, in which case t hey ar e
t aken as 1. (If B=[], t hen F is t aken as [].)
For discr et e-t ime models (T>0), not e t he following: poly2th st r ips a ny t r ailing
zer os fr om t he polynomials when det er mining t he or der s. It also st r ips leading
zer os fr om t he B polynomial t o det er mine t he delays. Keep t his in mind when
you use poly2th and th2poly t o modify ear lier est ima t es t o ser ve a s init ia l
condit ions for est ima t ing new st r uct ur es. See Some Special Topics on page
3-68.
Examples To cr eat e a syst em of ARMAX t ype (t he st r m syst em):
A = [1 1.5 0.7];
B = [0 1 0.5];
C = [1 1 0.2];
th0 = poly2th(A,B,C);
This gives a syst em wit h one delay (nk = 1).
Cr eat e t he cont inuous-t ime model
Sample it wit h T=0.1 and t hen simulat e it wit hout noise:
B=[0 1;1 3];
F=[1 1 0;1 2 4]
th=poly2th(1,B,1,1,F,1,1)
thd=thc2thd(th,0.1)
y=idsim([u1 u2],thd);
See Also idsim, theta

y(t )
1
s(s+ 1)
u
1
t ( ) +
s+ 3
s
2
+ 2s+ 4
u
2
(t) + e(t )
predict
4-75
pr edict
Purpose Pr edict t he out put k-st ep ahead.
Syntax p = predict(z,th)
[yp,thpred] = predict(z,th,k)
Description z is t he out put -input dat a in t he usual for mat
z = [y u]
wher e y is a mat r ix whose r-t h column is t he r-t h out put signal a nd
cor r espondingly for t he input u.
The ar gument k indicat es t hat t he k -st ep ahead pr edict ion of y accor ding t o t he
model th (in t he t het a for mat ) is comput ed. In t he calculat ion of yp(t) t he model
ca n use out put s up t o t ime
: ,
and input s up t o t he cur r ent t ime t . The default value of k is 1.
The out put yp is a mat r ix of t he same size a s y, and it s i,j element cont ains t he
pr edict ed va lue of t he cor r esponding element in y. The out put ar gument
thpred cont ains t he k-st ep a head pr edict or in t he t het a for mat , in t he case t hat
th cor r esponds t o a n input -out put model. (The pr edict or is a syst em wit h
input s and out put s, being t he number of out put s and t he
number of input s t o th.)
An impor t ant use of predict is t o eva luat e a models pr oper t ies in t he
mid-fr equency r ange. Simula t ion wit h idsim (which concept ua lly cor r esponds
t o k = inf) can lead t o levels t ha t dr ift apar t , since t he low fr equency behavior
is emphasized. One st ep ahead pr edict ion is not a power ful t est of t he models
pr oper t ies, since t he high fr equency beha vior is st r essed. The t r ivial pr edict or
can give good pr edict ions in ca se t he sampling of t he da t a is fast .
Anot her impor t ant use of predict is t o evaluat e models of t ime ser ies. The
nat ur al way of st udying a t ime ser ies models abilit y t o r epr oduce obser va t ions
is t o compar e it s k-st ep ahead pr edict ions wit h act ual dat a.
Not e t hat for out put -er r or models, t her e is no differ ence bet ween t he k-st ep
ahead pr edict ions a nd t he simulat ed out put , since, by definit ion, out put -er r or
models only use past input s t o pr edict fut ur e out put s.
t k y s ( ) s , t k = t k 1 ,
ny nu + ny ny nu
y t ( ) y t 1 ( ) =
predict
4-76
Algorithm For a model th t hat is an input -out put model, t he for mula (3.31) in Ljung
(1987) is applied t o comput e t he pr edict or . For st at e-space models, t he st at e
equa t ions ar e simulat ed k-st eps ahead wit h init ial value ,
wher e is t he Kalman filt er st a t e est imat e.
Examples Simulat e a t ime ser ies, est imat e a model based on t he fir st half of t he dat a, and
evaluat e t he four st ep ahead pr edict ions on t he second half:
th0 = poly2th([1 0.99],[],[1 1 0.2]);
y = idsim(randn(400,1),th0);
th = armax(y(1:200),[1 2]);
yp = predict(y,th,4);
plot([y(201:400),yp(201:400)])
Not e t hat t he last t wo commands also ar e achieved by
compare(y,th,4,201:400);
See Also compare, idsim, pe
x t k ( ) x t k ( ) =
x t k ( )
present
4-77
pr esent
Purpose Display t he infor mat ion in a t het a mat r ix.
Syntax present(th)
Description This funct ion displays t he polynomials of t he model th, t oget her wit h t heir
st a ndar d deviat ions, loss funct ion, a nd Akaikes Final Pr edict ion Er r or
Cr it er ion (FPE) (which essent ially equals t he AIC). It also displa ys infor mat ion
about how th was cr ea t ed.
Lea ding zer os in B cor r espond t o dela ys; t her efor e, t he delay is nk if B st ar t s
wit h nk exact zer os.
For input -out put models, t he est imat ed st anda r d deviat ions ar e given just
below t he est imat ed par a met er s. (Not e t hat leading zer os and ones ar e exact
and ha ve zer o st andar d devia t ion.)
For st at e-space models and mult ivar iable ARX models, t he st a ndar d
deviat ions ar e given a s fake, imagina r y par t s of t he par a met er est imat es.
See Also theta
rarmax
4-78
r a r max
Purpose Est imat e r ecur sively t he par a met er s of an ARMAX or ARMA model.
Syntax thm = rarmax(z,nn,adm,adg)
[thm,yhat,P,phi,psi] = ...
rarmax(z,nn,adm,adg,th0,P0,phi0,psi0)
Description The pa r amet er s of t he ARMAX model st r uct ur e
ar e est ima t ed using a r ecur sive pr edict ion er r or met hod.
Mat r ix z cont ains t he out put -input da t a z = [y u] wher e y and u a r e column
vect or s. nn is given a s
nn = [na nb nc nk]
wher e na, nb, a nd nc ar e t he or der s of t he ARMAX model, and nk is t he delay.
See equa t ions (3.16)-(3.18) in Chapt er 3, "Tut or ial" for an exact definit ion of t he
or der s.
If z = y and nn = [na nc], rarmax est imat es t he par amet er s of an ARMA
model for y:
Only single-input , single-out put models ar e handled by rarmax. Use rpem for
t he mult i-input case.
The est imat ed par a met er s ar e r et ur ned in t he mat r ix thm. The k-t h r ow of thm
cont ains t he par amet er s associat ed wit h t ime k, i.e., t hey ar e based on t he da t a
in t he r ows up t o and including r ow k in z. Each r ow of thm cont ains t he
est ima t ed par amet er s in t he following or der :
thm(k,:) = [a1,a2,...,ana,b1,...,bnb,c1,...,cnc]
See equat ions (3.16),(3.18) in Chapt er 3, "Tut or ial" for mor e infor mat ion.
yhat is t he pr edict ed value of t he out put , accor ding t o t he cur r ent model, i.e.,
r ow k of yhat cont ains t he pr edict ed value of z(k,1) based on all past dat a.
A q ( )y t ( ) B q ( )u t nk ( ) C q ( )e t ( ) + =
A q ( )y t ( ) C q ( )e t ( ) =
rarmax
4-79
The act ual algor it hm is select ed wit h t he t wo ar gument s adm a nd adg. These
ar e descr ibed under rarx.
The input ar gument th0 cont ains t he init ial value of t he par amet er s, a r ow
vect or , consist ent wit h t he r ows of thm. The default va lue of th0 is all zer os.
The ar gument s P0 and P ar e t he init ial and final values, r espect ively, of t he
scaled covar iance mat r ix of t he par amet er s. See rarx. The default value of P0
is 10
4
t imes t he unit mat r ix. The a r gument s phi0, psi0, phi, and psi cont ain
init ial and final values of t he dat a vect or and t he gr adient vect or , r espect ively.
The sizes of t hese depend in a r at her complica t ed wa y on t he chosen model
or der s. The nor mal choice of phi0 a nd psi0 is t o use t he out put s fr om a
pr evious call t o rarmax wit h t he same model or der s. (This call could of cour se
be a dummy call wit h default input ar gument s.) The default values of phi0 a nd
psi0 ar e all zer os.
Not e t ha t t he funct ion r equir es t hat t he delay nk be lar ger t han 0. If you want
nk=0, shift t he input sequence appr opr iat ely and use nk=1.
Algorithm The gener a l r ecur sive pr edict ion er r or algor it hm (11.44), (11.47)-(11.49) of
Ljung (1987) is implement ed. See Recur sive Par amet er Est ima t ion on page
3-61 for mor e infor mat ion.
Examples Comput e a nd plot , as funct ions of t ime, t he four par amet er s in a second or der
ARMA model of a t ime ser ies given in t he vect or y. The for get t ing fa ct or
algor it hm wit h a for get t ing fact or of 0.98 is a pplied.
thm = rarmax(y,[2 2],'ff',0.98);
plot(thm)
rarx
4-80
r a r x
Purpose Est imat e r ecur sively t he par a met er s of an ARX or AR model.
Syntax thm = rarx(z,nn,adm,adg)
[thm,yhat,P,phi] = rarx(z,nn,adm,adg,th0,P0,phi0)
Description The pa r amet er s of t he ARX model st r uct ur e
ar e est ima t ed using differ ent var iant s of t he r ecur sive lea st -squar es met hod.
Mat r ix z cont ains t he out put -input da t a z = [y u] wher e y and u ar e column
vect or s. nn is given as
nn = [na nb nk]
wher e na and nb ar e t he or der s of t he ARX model, and nk is t he delay. See
equa t ion (3.16) in t he Tut orial for an exact definit ion of t he or der s.
If z = y and nn = na, rarx est imat es t he par amet er s of an AR model for y:
Models wit h sever al input s
ar e ha ndled by a llowing u t o cont ain ea ch input as a column vect or ,
u = [u1 ... unu]
and by allowing nb and nk t o be r ow vect or s defining t he or der s and delays
associat ed wit h each input .
Only single-out put models ar e handled by rarx.
The est imat ed par amet er s ar e r et ur ned in t he mat r ix thm. The k-t h r ow of thm
cont ains t he par amet er s associat ed wit h t ime k, i.e., t hey ar e based on t he da t a
A q ( )y t ( ) B q ( )u t nk ( ) e t ( ) + =
A q ( )y t ( ) e t ( ) =
A q ( )y t ( ) B
1
q ( )u
1
t nk
1
( ) B
nu
u
nu
t nk
nu
( ) e t ( ) + + =
rarx
4-81
in t he r ows up t o and including r ow k in z. Each r ow of thm cont ains t he
est imat ed par amet er s in t he following or der :
thm(k,:) = [a1,a2,...,ana,b1,...,bnb]
See equat ion (3.16) in Chapt er 3, "Tut or ial". In t he case of a mult i-input model,
all t he b par amet er s associat ed wit h input number 1 ar e given fir st , a nd t hen
all t he b par amet er s associat ed wit h input number 2, and so on.
yhat is t he pr edict ed value of t he out put , accor ding t o t he cur r ent model, i.e.,
r ow k of yhat cont ains t he pr edict ed va lue of z(k,1) based on a ll past da t a.
The act ual algor it hm is select ed wit h t he t wo ar gument s adg and adm. These
ar e descr ibed in Recur sive Par amet er Est imat ion on page 3-61. The opt ions
ar e as follows:
Wit h adm ='ff' and adg = lam t he forgett ing fact or algor it hm (10.6abd)+(10.8)
is obt ained wit h for get t ing fact or = lam. This is what is oft en r efer r ed t o as
Recur sive Least Squar es, RLS. In t his case t he mat r ix P (see below) has t he
following int er pr et at ion: /2 P is appr oximat ely equal t o t he cova r iance
mat r ix of t he est imat ed pa r amet er s. Her e is t he var iance of t he innovat ions
(t he t r ue pr edict ion er r or s e(t) in (10.3)).
Wit h adm ='ug' and adg = gam t he unnormalized gradient algor it hm
(10.6abc)+(10.9) is obt ained wit h gain gamma= gam. This algor it hm is
commonly known as unnor malized Least Mean Squar es, LMS. Similar ly
adm ='ng' a nd adg = gam gives t he normalized gradient or Nor malized Least
Mean Squar es, NLMS algor it hm (10.6abc) + (10.10). In t hese cases P is not
defined or applicable.
Wit h adm ='kf' and adg = R1 t he Kalman Filt er Based algor it hm (10.6) is
obt ained wit h R
2
=

1 a nd R
1
= R1. If t he var iance of t he innovat ions e(t ) is not
unit y but , t hen P is t he covar iance mat r ix of t he par amet er est imat es,
while =R1 / is t he covar ia nce ma t r ix of t he par a met er changes in (10.4).
The input ar gument th0 cont ains t he init ial value of t he par amet er s; a r ow
vect or , consist ent wit h t he r ows of thm. (See above.) The default value of th0 is
all zer os.
The ar gument s P0 and P ar e t he init ial and final values, r espect ively, of t he
scaled covar iance mat r ix of t he par amet er s. The default value of P0 is 10
4
t imes
t he ident it y mat r ix.

R
2
R
2
R
2
R
2
R
1
R
2
rarx
4-82
The ar gument s phi0 and phi cont a in init ial and final values, r espect ively, of
t he dat a vect or :
Then, if
z = [y(1),u(1); ... ;y(N),u(N)]
you have phi0 = and phi = . The default value of phi0 is all zer os. For
online use of rarx, use phi0, th0, and P0 a s t he pr evious out put s phi, thm (last
r ow), and P.
Not e t hat t he funct ion r equir es t hat t he dela y nk be la r ger t han 0. If you wa nt
nk=0, shift t he input sequence appr opr iat ely and use nk=1.
Examples Adapt ive noise canceling: The signal y cont ains a component t ha t has it s
or igin in a known signal r. Remove t his component by est imat ing, r ecur sively,
t he syst em t hat r ela t es r t o y using a sixt h or der FIR model t oget her wit h t he
NLMS algor it hm:
z = [y r];
[thm,noise] = rarx(z,[0 6 1],'ng',0.1);
%noise is the adaptive estimate of the noise
%component of y
plot(ynoise)
t ( ) y t 1 ( ) y t na ( ) u t 1 ( ) u t nb nk 1 + ( ) , , , , [ ] =
1 ( ) N ( )
rarx
4-83
If t he above applicat ion is a t r ue online one, so t hat you want t o plot t he best
est imat e of t he signal y noise at t he same t ime as t he dat a y and u become
ava ilable, pr oceed as follows:
phi = zeros(6,1); P=1000eye(6);
th = zeros(1,6); axis([0 100 2 2]);
plot(0,0,''), hold
%The loop:
while ~abort
[y,r,abort] = readAD(time);
[th,ns,P,phi] = rarx([y r],'ff',0.98,th,P,phi);
plot(time,yns,'')
time = time +Dt
end
This example uses a for get t ing fact or algor it hm wit h a for get t ing fact or of 0.98.
readAD r epr esent s an M-file t ha t r eads t he value of an A/D conver t er at t he
indicat ed t ime inst a nce.
rbj
4-84
r bj
Purpose Est imat e r ecur sively t he par a met er s of a Box-J enkins model.
Syntax thm = rbj(z,nn,adm,adg)
[thm,yhat,P,phi,psi] = ...
rbj(z,nn,adm,adg,th0,P0,phi0,psi0)
Description The pa r amet er s of t he ARMAX model st r uct ur e
ar e est ima t ed using a r ecur sive pr edict ion er r or met hod.
Mat r ix z cont ains t he out put -input da t a z = [y u] wher e y and u a r e column
vect or s. nn is given as
nn = [nb nc nd nf nk]
wher e nb, nc, nd, and nf ar e t he or der s of t he Box-J enkins model, a nd nk is t he
delay. See equa t ions (3.21) and (3.14),(3.18), (3.22) and (3.29) in t he Tutorial
for an exact definit ion of t he or der s.
Only single-input , single-out put models ar e handled by rbj. Use rpem for t he
mult i-input case.
The est imat ed par amet er s ar e r et ur ned in t he mat r ix thm. The k-t h r ow of thm
cont ains t he par amet er s associat ed wit h t ime k, i.e., t hey ar e based on t he da t a
in t he r ows up t o and including r ow k in z. Each r ow of thm cont ains t he
est ima t ed par amet er s in t he following or der :
thm(k,:) = [b1,...,bnb,c1,...,cnc,d1,...,dnd,f1,...,fnf]
(See equat ions (3.14),(3.18),(3.22) a nd (3.20) in t he Tut orial.)
yhat is t he pr edict ed value of t he out put , accor ding t o t he cur r ent model, i.e.,
r ow k of yhat cont ains t he pr edict ed value of z(k,1) based on all past dat a.
The act ual algor it hm is select ed wit h t he t wo ar gument s adm and adg. These
ar e descr ibed under rarx.
y t ( )
B q ( )
F q ( )
----------- u t nk ( )
C q ( )
D q ( )
------------e t ( ) + =
rbj
4-85
The input ar gument th0 cont ains t he init ial value of t he par amet er s, a r ow
vect or , consist ent wit h t he r ows of thm. (See above.) The default value of th0 is
all zer os.
The ar gument s P0 and P ar e t he init ial and final values, r espect ively of t he
scaled covar iance mat r ix of t he par amet er s. See rarx. The default value of P0
is 10
4
t imes t he unit mat r ix. The a r gument s phi0, psi0, phi, and psi cont ain
init ial and final values of t he dat a vect or and t he gr adient vect or , r espect ively.
The sizes of t hese depend in a r at her complica t ed wa y on t he chosen model
or der s. The nor mal choice of phi0 a nd psi0 is t o use t he out put s fr om a
pr evious call t o rbj wit h t he same model or der s. (This call could, of cour se, be
a dummy ca ll wit h default input ar gument s.) The defa ult values of phi0 and
psi0 ar e all zer os.
Not e t hat t he funct ion r equir es t hat t he dela y nk is lar ger t ha n 0. If you want
nk=0, shift t he input sequence appr opr iat ely and use nk=1.
Algorithm The gener a l r ecur sive pr edict ion er r or algor it hm (11.44) of Ljung (1987) is
implement ed. See also Recur sive Par amet er Est imat ion on page 3-61.
resid
4-86
r esi d
Purpose Comput e and t est t he r esiduals (pr edict ion er r or s) of a model.
Syntax [e,r] = resid(z,th)
[e,r] = resid(z,th,M,maxsize)
resid(r);
Description Mat r ix z cont a ins t he out put -input da t a z = [y u], wher e y a nd u ar e column
vect or s. In t he mult ivar iable case, y a nd u ar e mat r ices, wit h columns
cor r esponding t o t he differ ent input s and out put s.
th is t he model t o be evaluat ed on t he given dat a set , defined in t het a for mat .
e is r et ur ned wit h t he r esiduals (pr edict ion er r or s) associat ed wit h t he model
and t he dat a.
The aut ocor r ela t ion funct ion of e and t he cr oss cor r elat ion bet ween e and t he
input (s) u ar e comput ed and displayed. The 99% confidence int er vals for t hese
values ar e also comput ed and displayed as dot t ed (r ed) cur ves. The
comput at ion of t hese values is done assuming e t o be whit e and independent of
u. The funct ions ar e displa yed up t o lag M, which is 25 by default .
The cor r elat ion infor mat ion is r et ur ned wit h r. The plot s can t hen be r eviewed
by
resid(r);
See Model St r uct ur e Select ion and Va lidat ion on page 3-49 for mor e
infor mat ion.
The ar gument maxsize is explained under auxvar.
Examples Her e a r e some t ypical model va lidat ion comma nds:
e = resid(z,th);
plot(e)
compare(z,th);
See Also auxvar, compare, pem, theta
References Ljung (1987), Sect ion 16.5.
roe
4-87
r oe
Purpose Est imat e r ecur sively t he par amet er s of an Out put -Er r or model.
Syntax thm = roe(z,nn,adm,adg)
[thm,yhat,P,phi,psi] = roe(z,nn,adm,adg,th0,P0,phi0,psi0)
Description The pa r amet er s of t he Out put -Er r or model st r uct ur e
ar e est ima t ed using a r ecur sive pr edict ion er r or met hod.
Mat r ix z cont ains t he out put -input dat a z = [y u] wher e y and u a r e column
vect or s. nn is given as
nn = [nb nf nk]
wher e nb and nf ar e t he or der s of t he Out put -Er r or model, and nk is t he delay.
See equat ions (3.14) and (3.19)-(3.20) in t he Tutorial for an exa ct definit ion of
t he or der s.
Only single-input , single-out put models ar e handled by roe. Use rpem for t he
mult i-input case.
The est imat ed par amet er s ar e r et ur ned in t he mat r ix thm. The k-t h r ow of thm
cont ains t he par amet er s associat ed wit h t ime k, i.e., t hey ar e based on t he da t a
in t he r ows up t o and including r ow k in z.
Each r ow of thm cont ains t he est ima t ed par amet er s in t he following or der :
thm(k,:) = [b1,...,bnb,f1,...,fnf]
See equat ions (3.14), (3.20) in t he Tutorial.
yhat is t he pr edict ed value of t he out put , accor ding t o t he cur r ent model, i.e.,
r ow k of yhat cont ains t he pr edict ed va lue of z(k,1) based on a ll past da t a.
The act ual algor it hm is select ed wit h t he t wo ar gument s adg and adm. These
ar e descr ibed under rarx.
The input ar gument th0 cont ains t he init ial value of t he par amet er s, a r ow
vect or , consist ent wit h t he r ows of thm. (See above.) The default value of th0 is
all zer os.
y t ( )
B q ( )
F q ( )
-----------u t nk ( ) =
roe
4-88
The ar gument s P0 and P ar e t he init ia l and final values, r espect ively, of t he
scaled covar iance mat r ix of t he par amet er s. See rarx. The default va lue of P0
is 10
4
t imes t he unit mat r ix. The ar gument s phi0, psi0, phi, and psi cont ain
init ial and final values of t he dat a vect or and t he gr adient vect or , r espect ively.
The sizes of t hese depend in a r at her complicat ed way on t he chosen model
or der s. The nor mal choice of phi0 and psi0 is t o use t he out put s fr om a
pr evious call t o roe wit h t he same model or der s. (This call could be a dummy
ca ll wit h default input ar gument s.) The defa ult values of phi0 a nd psi0 ar e all
zer os.
Not e t hat t he funct ion r equir es t hat t he dela y nk is lar ger t han 0. If you want
nk=0, shift t he input sequence a ppr opr iat ely a nd use nk=1.
Algorithm The gener al r ecur sive pr edict ion er r or algor it hm (11.44) of Ljung (1987) is
implement ed. See also Recur sive Par amet er Est imat ion on page 3-61.
See Also oe, rarx, rbj, rplr,
rpem
4-89
r pem
Purpose Est imat e r ecur sively t he par amet er s of a gener al mult i-input single-out put
linea r model.
Syntax thm = rpem(z,nn,adm,adg)
[thm,yhat,P,phi,psi] = rpem(z,nn,adm,adg,th0,P0,phi0,psi0)
Description The pa r amet er s of t he gener al linear model st r uct ur e
ar e est ima t ed using a r ecur sive pr edict ion er r or met hod.
Mat r ix z cont ains t he out put -input dat a z = [y u] wher e y and u a r e column
vect or s (in t he mult i-input case u cont ains one column for each input ). nn is
given as
nn = [na nb nc nd nf nk]
wher e na, nb, nc, nd, a nd nf ar e t he or der s of t he model, and nk is t he dela y.
For mult i-input syst ems nb, nf, and nk ar e r ow vect or s giving t he or der s and
delays of each input . See equat ions (3.13)-(3.23) in t he Tutorial for an exact
definit ion of t he or der s.
The est imat ed par amet er s ar e r et ur ned in t he mat r ix thm. The k-t h r ow of thm
cont ains t he par amet er s associat ed wit h t ime k, i.e., t hey ar e based on t he da t a
in t he r ows up t o and including r ow k in z. Each r ow of thm cont ains t he
est imat ed par amet er s in t he following or der :
thm(k,:) = [a1,a2,...,ana,b1,...,bnb,...
c1,...,cnc,d1,...,dnd,f1,...,fnf]
See equa t ions (3.13)-(3.23) in t he Tutorial. For mult i-input syst ems t he B par t
in t he above expr ession is r epeat ed for each input befor e t he C par t begins, and
also t he F par t is r epeat ed for each input . This is t he same or der ing as in
th2par.
yhat is t he pr edict ed value of t he out put , accor ding t o t he cur r ent model, i.e.,
r ow k of yhat cont a ins t he pr edict ed value of z(k,1) based on all past dat a.
A q ( )y t ( )
B
1
q ( )
F
1
q ( )
--------------u
1
t nk
1
( )
B
nu
q ( )
F
nu
q ( )
----------------- u
nu
t nk
nu
( )
C q ( )
D q ( )
------------e t ( ) + + + =
rpem
4-90
The act ual algor it hm is select ed wit h t he t wo ar gument s adg and adm. These
ar e descr ibed under rarx
The input ar gument th0 cont ains t he init ial value of t he par amet er s;, a r ow
vect or , consist ent wit h t he r ows of thm. (See above.) The default value of th0 is
all zer os.
The ar gument s P0 and P ar e t he init ia l and final values, r espect ively, of t he
scaled covar iance mat r ix of t he par amet er s. See rarx. The default va lue of P0
is 10
4
t imes t he unit ma t r ix. The a r gument s phi0, psi0, phi, and psi cont ain
init ial and final values of t he dat a vect or and t he gr adient vect or , r espect ively.
The sizes of t hese depend in a r at her complicat ed way on t he chosen model
or der s. The nor mal choice of phi0 and psi0 is t o use t he out put s fr om a
pr evious call t o rpem wit h t he same model or der s. (This call could be a dummy
ca ll wit h default input ar gument s.) The defa ult values of phi0 a nd psi0 ar e all
zer os.
Not e t hat t he funct ion r equir es t hat t he dela y nk is lar ger t han 0. If you want
nk=0 , shift t he input sequence appr opr iat ely and use nk=1.
Algorithm The gener al r ecur sive pr edict ion er r or algor it hm (11.44) of Ljung (1987) is
implement ed. See also Recur sive Par amet er Est imat ion on page 3-61.
For t he special cases of ARX/AR models, and of single-input ARMAX/ARMA,
Box-J enkins, and Out put -Er r or models, it is mor e efficient t o use rarx,
rarmax, rbj, and roe.
See Also pem, rarmax, rarx, rbj, roe, rplr
rplr
4-91
r plr
Purpose Est imat e r ecur sively t he par amet er s of a gener al mult i-input single-out put
linea r model.
Syntax thm = rplr(z,nn,adm,adg)
[thm,yhat,P,phi] = rplr(z,nn,adm,adg,th0,P0,phi0)
Description This is a dir ect a lt er nat ive t o rpem and has essent ially t he sa me synt ax. See
rpem for a n explana t ion of t he input and out put a r gument s.
rplr differ s fr om rpem in t hat it uses anot her gr adient appr oximat ion. See
Sect ion 11.5 in Ljung (1987). Sever al of t he special cases ar e well known
algor it hms.
When applied t o ARMAX models, (nn = [na nb nc 0 0 nk]), rplr gives t he
Ext ended Least Squar es, ELS met hod. When applied t o t he out put er r or
st r uct ur e (nn = [0 nb 0 0 nf nk]) t he met hod is known as HARF in t he adm
= 'ff' case and SHARF in t he adm = 'ng' case.
rplr can also be applied t o t he t ime ser ies case in which an ARMA model is
est imat ed wit h
z = y
nn = [na nc]
You can t hus use rplr as an alt er nat ive t o rarmax for t his case.
See Also pem, rarmax, rarx, rbj, roe, rpem
segment
4-92
segment
Purpose Segment da t a a nd est imat e models for each segment .
Syntax segm = segment(z,nn)
[segm,V,thm,R2e] = segment(z,nn,R2,q,R1,M,th0,P0,ll,mu)
Description segment builds models of AR, ARX, or ARMAX/ARMA,
assuming t hat t he model pa r amet er s a r e piece-wise const ant over t ime. It
r esult s in a model t hat has split t he dat a r ecor d int o segment s over which t he
model r emains const a nt . The funct ion models signals and syst ems t hat may
under go abr upt changes.
The ar gument z is t he out put -input dat a
z = [y u]
wher e y is a column vect or cont aining t he out put s and u is a column vect or
cont aining t he input s. If t he syst em ha s sever al input s, u ha s t he cor r esponding
number of columns.
The ar gument nn defines t he model or der . For t he ARMAX model
nn = [na nb nc nk]
wher e na, nb, and nc ar e t he or der s of t he cor r esponding polynomials. See
(3.13)-(3.18) in Chapt er 3, "Tut or ial". Mor eover nk is t he delay. If t he model has
sever al input s, nb and nk ar e r ow vect or s, giving t he or der s and delays for ea ch
input .
For an ARX model (nc = 0) ent er
nn = [na nb nk]
For an ARMA model of a t ime ser ies
z = y
nn = [na nc]
and for an AR model
nn = na
A q ( )y t ( ) B q ( )u t nk ( ) C q ( )e t ( ) + =
segment
4-93
The out put ar gument segm is a mat r ix, whose k-r ow cont ains t he par amet er s
cor r esponding t o t ime k. This is analogous t o t he out put ar gument thm in rarx
and rarmax. The out put ar gument thm of segment cont ains t he cor r esponding
model par amet er s t hat have not yet been segment ed. That is, t hey ar e not
piecewise const a nt , a nd t her efor e cor r espond t o t he out put s of t he funct ions
rarmax and rarx. In fact , segment is an alt er nat ive t o t hese t wo algor it hms,
and ha s a bet t er capabilit y t o deal wit h t ime var iat ions t hat may be a br upt .
The out put ar gument V cont ains t he sum of t he squa r ed pr edict ion er r or s of t he
segment ed model. It is a measur e of how successful t he segment at ion ha s been.
The input ar gument R2 is t he a ssumed var iance of t he innovat ions e(t ) in t he
model. The default value of R2 is t ha t it is est imat ed. Then t he out put
ar gument R2e is a vect or whose k-t h element cont a ins t he est imat e of R2 at t ime
k.
The ar gument q is t he pr obabilit y t hat t he model under goes at an abr upt
change at any given t ime. The default value is 0.01.
R1 is t he a ssumed covar ia nce mat r ix of t he par a met er jumps when t hey occur .
The default value is t he ident it y ma t r ix wit h dimension equal t o t he number
of est imat ed par amet er s.
M is t he number of par allel models used in t he algor it hm (see below). It s default
value is 5.
th0 is t he init ial value of t he par amet er s. It s default is zer o. P0 is t he init ia l
covar iance mat r ix of t he par amet er s. The default is 10 t imes t he ident it y
mat r ix.
ll is t he gua r ant eed life of each of t he models. That is, a ny cr eat ed candida t e
model is not abolished unt il a ft er at lea st ll t ime st eps. The default is ll = 1.
Mu is a for get t ing par amet er t hat is used in t he scheme t hat est imat es R2. The
defa ult is 0.97.
The most cr it ical par amet er for you t o choose is R2. It is usually mor e r obust
t o have a r easonable guess of R2 t han t o est imat e it . Typically, you need t o t r y
differ ent va lues of R2 and evaluat e t he r esult s. (See t he example below.)
sqrt(R2) cor r esponds t o a cha nge in t he value y(t ) t hat is nor mal, giving no
indicat ion t hat t he syst em or t he input might have changed.
segment
4-94
Algorithm The algor it hm is based on M par allel models, each r ecur sively est imat ed by an
algor it hm of Kalman filt er t ype. Each is updat ed independent ly, and it s
post er ior pr obabilit y is comput ed. The t ime var ying est imat e thm is for med by
weight ing t oget her t he M differ ent models wit h weight s equal t o t heir post er ior
pr obabilit y. At ea ch t ime st ep t he model (among t hose t hat have lived at least
ll samples) t hat has t he lowest post er ior pr obabilit y is abolished. A new model
is st ar t ed, assuming t hat t he syst em par a met er s have jumped, wit h pr obabilit y
q, a r andom jump fr om t he most likely among t he models. The cova r iance
mat r ix of t he par amet er change is set t o R1.
Aft er a ll t he dat a ar e exa mined, t he sur viving model wit h t he highest post er ior
pr obabilit y is t r acked back and t he t ime inst ances wher e it jumped ar e mar ked.
This defines t he differ ent segment s of t he dat a. (If no models had been
abolished in t he algor it hm, t his would have been t he maximum likelihood
est ima t es of t he jump inst ances.) The segment ed model segm is t hen for med by
smoot hing t he par amet er est imat e, assuming t hat t he jump inst ances ar e
cor r ect . In ot her wor ds, t he last est imat e over a segment is chosen t o r epr esent
t he whole segment .
Examples Check how t he a lgor it hm segment s a sinusoid int o segment s of const ant levels.
Then use a ver y simple model y(t ) = b
1
* 1, wher e 1 is a faked input a nd
descr ibes t he piecewise const ant level of t he signal y(t ) (which is simula t ed as
a sinusoid).
y = sin([1:50]/3)';
thm = segment([y,ones(y)],[0 1 1],0.1);
plot([thm,y])
By t r ying var ious values of R2 (0.1 in t he above example), mor e levels ar e
cr eat ed a s R2 decr eases.
b
1
selstruc
4-95
selst r uc
Purpose Select model or der (st r uct ur e).
Syntax [nn,vmod] = selstruc(v)
[nn,vmod] = selstruc(v,c)
Description selstruc is a funct ion t o help choose a model st r uct ur e (or der ) fr om t he
infor mat ion cont ained in t he mat r ix v obt ained as t he out put fr om arxstruc or
ivstruc.
The default va lue of c is 'plot'. This gr aphs t he values of t he loss funct ions in
v against t he t ot al number of par amet er s in t he cor r esponding model st r uct ur e.
If v was gener at ed by ivstruc, so t hat it also cont ains t he condit ion number s
of t he IV mat r ices, t hen t hese ar e also gr aphed aga inst t he number of
par a met er s. Ba sed on inspect ion of t hese plot s, you can choose a suit able
number of par amet er s, and nn r et ur ns t he best st r uct ur e wit h t his number of
par a met er s.
If c = 'log', t he logar it hms of t he loss funct ions ar e gr aphed inst ead.
c = 'aic' gives no plot s, but r et ur ns in nn t he st r uct ur e t hat minimizes
Akaikes Infor ma t ion Theor et ic Cr it er ion (AIC),
wher e V is t he loss funct ion, d is t he t ot al number of par amet er s in t he
st r uct ur e in quest ion, and N is t he number of dat a point s used for t he
est imat ion.
c = 'mdl' r et ur ns in nn t he st r uct ur e t hat minimizes Rissanens Minimum
Descr ipt ion Lengt h (MDL) cr it er ion.
When c equals a numer ical va lue, t he st r uct ur e t hat minimizes
is select ed.
The out put ar gument vmod has t he same for mat as v, but it cont ains t he
logar it hms of t he accor dingly modified cr it er ia.
V
mod
V

1 2

d N ( ) + ( ) =
V
mod
V

1 N ( ) log

d N + ( ) =
V
mod
V

1 c

d n + ( ) =
selstruc
4-96
The for mal gr ounds for applying AIC or MDL r equir e t hat v be gener a t ed by
arxstruc wit h ze = zv. When cr oss-validat ion is used (ze differ ent fr om zv),
t he logical choice is c = 0.
When select ing model st r uct ur es, it is impor t a nt t o assess ca r efully whet her
t he benefit of a bet t er fit is wor t h t he addit ional complexit y of a higher or der
model. See Chapt er 3, "Tut or ial" for mor e infor mat ion.
Examples Her e is a t ypical sequence of commands for finding a suit able model st r uct ur e:
NN = struc(2,2,1:8);
v = arxstruc(z(1:200,:),z(201:400,:),NN);
nn = selstruc(v,0);
nk = nn(3);
NN = struc(1:4,1:4,nk);
va = arxstruc(z(1:200,:),z(201:400,:),NN);
vi = ivstruc(z(1:200,:),z(201:400,:),NN);
nna = selstruc(va);
nni = selstruc(vi);
See Also arxstruc, ivstruc, struc
sett
4-97
set t
Purpose Set t he sampling int er val dir ect ly.
Syntax modn = sett(mod,T)
Description All funct ions t hat cr eat e model descr ipt ions in t he t het a or fr eqfunc for mat set
t he sampling int er val T in t heir last ar gument . For convenience sett offer s an
alt er nat ive t o set it dir ect ly. It can be applied bot h t o t he case wher e mod is a
model in t he t het a for mat and t o t he ca se wher e mod is a fr equency funct ion or
spect r um in t he fr eqfunc for mat , wit h a default choice of fr equencies.
th = armax(z,nn);
th = sett(th,T);
is equivalent t o
th = armax(z,nn,[],[],[],[],T)
Simila r ly,
g = spa(z);
g = sett(g,T);
is equivalent t o
g = spa(z,[],[],[],T)
Not e t hat you cannot use sett t o r ecalculat e models t o a new sampling
int er val. Use thc2thd or thd2thc inst ead.
See Also freqfunc, theta
spa
4-98
spa
Purpose Est imat e fr equency r esponse and spect r um by spect r al ana lysis.
Syntax [g,phiv] = spa(z)
[g,phiv,z_spe] = spa(z,M,w,maxsize,T)
Description spa est imat es t he t r a nsfer funct ion g and t he noise spect r um phiv = of t he
gener al linear model
wher e is t he spect r um of (t).
Mat r ix z cont ains t he out put -input dat a z = [y u], wher e y and u ar e column
vect or s. If t her e ar e sever al input s, u is a ma t r ix wit h one column for each
input . The dat a may be complex-valued.
g is r et ur ned in t he fr equency funct ion for mat (see freqfunc) wit h t he
est ima t e of at t he fr equencies specified by r ow vect or w. The default
value of w is
w = [1:128]/128pi/T
phiv is r et ur ned wit h t he aut ospect r um est imat e of at t he same
fr equencies. Bot h out put s ar e r et ur ned wit h est imat ed st a ndar d deviat ions
(see freqfunc).
M is t he lengt h of t he lag window used in t he calculat ions. The default value is
M = min(30,length(z)/10)
Cha nging t he va lue of M exchanges bias for var iance in t he spect r al est imat e.
As M is incr ea sed, t he est imat ed funct ions show mor e det ail, but ar e mor e
cor r upt ed by noise. The shar per pea ks a t r ue fr equency funct ion has, t he
higher M it needs. See etfe as an alt er nat ive for nar r owband signals and
syst ems.
T is t he sa mpling int er val a nd maxsize cont r ols t he memor y-speed t r ade-off
(see auxvar).

v
y t ( ) G q ( )u t ( ) v t ( ) + =

v
( )
G e
i
( )

v
( )
spa
4-99
For t ime ser ies z = y, g is r et ur ned wit h t he est imat ed out put spect r um and
it s est imat ed st andar d devia t ion.
IMPORTANT: For mult i-out put dat a t he ar gument M must be ent er ed as a r ow
vect or of t he same lengt h as t he number of out put s. This is t he way t he
dist inct ion bet ween input s and out put s in z is clar ified. For default window
size use in t he mult i-out put case
M = [1, 1, ..., 1]
The opt ional t hir d out put ar gument z_spe gives dir ect ly t he spect r um mat r ix
of z as follows:
reshape(z_spe(:,k),nz,nz) = The spect r um S at fr equency W(k)
wher e nz is t he number of channels in t he dat a mat r ix z a nd
Her e win(m) is weight at lag m of a n M-size Hamming window and W(k ) is t he
fr equency value i r ad/s. Not e t hat ' denot es complex-conjugat e t r anspose.
The nor malizat ion of t he spect r um differ s fr om t he one used by spectrum in t he
Signal Pr ocessing Toolbox . See Some Special Topics on pa ge 3-68 for a mor e
pr ecise definit ion.
Examples Wit h default fr equencies
g = spa(z);
bodeplot(g)
Wit h loga r it hmica lly spaced fr equencies
w = logspace(2,pi,128);
[g,phiv] = spa(z,[],w);
% (empty matrix gives default)
bodeplot([g phiv],3)
plot s t he est imat ed spect r um t oget her wit h confidence int er vals of t hr ee
st a ndar d deviat ions.
S Ez t m + ( )z t ( ) iW k ( )mT ( ) exp win m ( )
m M =
M

=
spa
4-100
Algorithm The covar iance funct ion est ima t es a r e comput ed using covf. These ar e
mult iplied by a Hamming window of lag size M and t hen Four ier t r ansfor med.
The r elevant r at ios and differ ences ar e t hen for med. For t he default
fr equencies, t his is done using FFT, which is mor e efficient t han for
user -defined fr equencies. For mult i-var iable syst ems, a st r aight for war d
for -loop is used.
Not e t hat M = is in Table 6.1 of Ljung (1987). The st andar d deviat ions a r e
comput ed as on pages 155-156 a nd 264 of Ljung (1987).
See Also auxvar, bodeplot, etfe, ffplot, freqfunc, th2ff
References Ljung (1987), Sect ion 6.4.

ss2th
4-101
ss2t h
Purpose Cr eat e a model st r uct ur e pa r amet r ized in canonical for m.
Syntax THS = ss2th(TH)
THS = ss2th(TH,orders)
Description This funct ion conver t s any model in t het a for mat t o a canonically
par a met er ized st at e-space model, also in t het a for mat . It is useful when a
model has been obt a ined in some wa y, and you want t o use it as an init ial model
for pr edict ion er r or est imat ion using pem.
TH: The given model, which can be any model in t het a for mat .
THS: The r esult ing model, also in t het a for mat . A ca nonical pa r amet r izat ion in
obser ver for m, based on t he pseudo-obser vabilit y indices orders.
orders: The pseudo-obser vabilit y indices. A r ow vect or , wit h as many element s
as t her e ar e out put s in t he model TH. Their sum must be equal t o t he or der of
t he model TH. See canform for mor e det ails. If orders is omit t ed, a default
choice of indices is made.
If t he model TH is an out put er r or model (it s Ka lman gain equal t o zer o), t hen
so is THS. Also if t her e is a delay fr om input t o out put in TH (cor r esponding t o a
st a t e-space r epr esent at ion (3.27) in t he Tutorial wit h D=0) t hen THS will also
have such a st r uct ur e.
Ex amples Make a par amet r ized st a t e-space model fr om given ma t r ices A, B, C, D, and K
and use it as init ial condit ion for pem est imat ion:
th1 = ms2th(modstruc(A,B,C,D,K),d);
thi = ss2th(th1);
th = pem(z,thi);
Let t he model obt ained fr om n4sid be used a s t he init ia l value for pr edict ion
er r or est imat ion:
thn = n4sid(z,3);
thp = pem(z,ss2th(thn));
See Also canform, canstart, ms2th, n4sid
struc
4-102
st r uc
Purpose Gener at e model st r uct ur e ma t r ices.
Syntax NN = struc(NA,NB,NK)
Description struc r et ur ns in NN t he set of model st r uct ur es compr ised of all combinat ions
of t he or der s and delays given in r ow vect or s NA, NB, a nd NK. The for mat of NN
is consist ent wit h t he input for mat used by arxstruc and ivstruc. The
command is int ended for single-input syst ems only.
Examples The st at ement
NN = struc(1:2,1:2,4:5);
pr oduces
NN =
1 1 4
1 1 5
1 2 4
1 2 5
2 1 4
2 1 5
2 2 5
thc2thd
4-103
t h c2t hd
Purpose Conver t a model fr om cont inuous t ime t o discr et e t ime.
Syntax thd = thc2thd(thc,T)
Description thc is a cont inuous-t ime model in t he t het a for mat . thd is what is obt ained
when it is sampled wit h sampling int er val T. If thc is of input -out put t ype, t he
covar iance mat r ix of t he par amet er s is not t r anslat ed.
Not e t hat t he innovat ions var iance of t he cont inuous-t ime model is
int er pr et ed as t he int ensit y of t he spect r al densit y of t he noise spect r um. The
innovat ions var iance in thd will t hus be given as /T.
Examples Define a cont inuous-t ime syst em and st udy t he poles and zer os of t he sampled
count er pa r t :
thc = poly2th(1,1,1,1,[1 1 0],1,1);
thd = thc2thd(thc,0.5);
zpplot(th2zp(thd))
See Also thd2thc

thd2thc
4-104
t h d2t hc
Purpose Conver t a model fr om discr et e t o cont inuous t ime.
Syntax thc = thd2thc(thd)
thc = thd2thc(thd,delay,NoP)
Description The discr et e-t ime model thd, given in t he t het a for mat , is conver t ed t o a
cont inuous-t ime count er par t thc. The covar iance ma t r ix of t he par amet er s in
t he model is also t r anslat ed using Gauss a ppr oximat ion for mula and
numer ical der ivat ives of t he t r ansfor mat ion. The st ep sizes in t he numer ica l
der ivat ives ar e det er mined by t he funct ion nuderst. To inhibit t he t r anslat ion
of t he covar iance mat r ix and sa ve t ime, ent er NoP = 1.
If t he discr et e-t ime model cont a ins pur e t ime delays, i.e., , t hen t hese ar e
fir st r emoved befor e t he t r ansfor mat ion is made. These delays should t hen be
appended as pur e t ime-dela y (deadt ime) t o t he cont inuous-t ime model. This is
done aut omat ically by th2ff. To have t he t ime delay appr oxima t ed by a
finit e-dimensiona l cont inuous syst em, ent er delay = 'del'. The default is
delay = 'nodel'.
If t he innovat ions var iance is in thd, a nd it s sa mpling int er val is T, t hen t he
cont inuous-t ime model has an indicat ed level of innovat ions spect r al densit y
equa l t o T .
IMPORTANT: The t r ansfor mat ion fr om discr et e t o cont inuous t ime is not
unique. thd2thc select s t he cont inuous-t ime count er par t wit h t he slowest
t ime const ant s, consist ent wit h t he discr et e-t ime model. The lack of
uniqueness also means t hat t he t r ansfor mat ion may be ill-condit ioned or even
singular. In par t icular, poles on t he negat ive r ea l a xis, in t he or igin, or in t he
point 1, ar e likely t o cause pr oblems. Int er pr et t he r esult s wit h car e.
Examples Tr ansfor m an ident ified model t o cont inuous t ime and compar e t he fr equency
r esponses of t he t wo models:
gd = th2ff(th);
thc = thd2thc(th);
gc = th2ff(thc);
bodeplot([gd, gc],3)
See Also nuderst, thc2thd
References See Some Special Topics on pa ge 3-68.
nk 1 >

theta
4-105
t h et a
Purpose Descr ibe t he t het a for mat .
Syntax help theta
help thss
Description theta is a packed mat r ix cont aining infor ma t ion a bout bot h a model st r uct ur e
and it s nominal or est imat ed par a met er s. It also cont ains ot her r elevant
infor mat ion about t he ident ifica t ion r esult .
This model for mat is t he basic for ma t wit h t he Syst em Ident ificat ion Toolbox.
It is used by a ll par amet r ic ident ificat ion met hods and it can be t r ansfor med t o
many ot her model r epr esent a t ions. See t he t ables in t he beginning of t his
chapt er for mor e det a ils.
The int er nal for mat of t he t het a for mat is int ended t o be t r anspar ent t o t he
user . The basic wa y t o display t he infor mat ion is t o use t he present command.
Some specific infor mat ion is r et r ieved fr om t he for mat by t he funct ions
getmfth, getncap, gett, a nd th2par. This ent r y gives t he det ails of t he int er na l
r epr esent at ion, but t his infor mat ion is not necessar y for most user s of t he
Syst em Ident ificat ion Toolbox. The for ma t s differ whet her t he under lying
model is in st at e-space for m or of t he input -out put black box char act er .
I. For t he general mult i-input single-out put linear model struct ure
A, B, C, D, and F a r e polynomials in t he delay oper at or of or der s na, nb, nc, nd,
and nf, r espect ively. If t he syst em has nu input s, nb, nf and nk ar e r ow vect or s
of dimension nu cont aining infor ma t ion about t he or der s and delays associat ed
wit h ea ch of t he input s. In t he ca se of a t ime ser ies (no u), B and F ar e not
defined.
Let n be t he sum of a ll t he or der s (t he number of est imat ed par amet er s) and let
r = max(n, 7, 6 + 3 nu )
A q ( )y t ( )
B
1
q ( )
F
1
q ( )
--------------u
1
t nk
1
( )
B
nu
q ( )
F
nu
q ( )
----------------- u
nu
t nk
nu
( )
C q ( )
D q ( )
------------e t ( ) + + + =
theta
4-106
Then theta is a (3+n) r mat r ix or ganized as follows:
Row 1 has ent r ies: est imat ed var iance of e, sampling int er val T, nu, na, nb,
nc, nd, nf, and nk .
Row 2 has ent r ies: FPE (Akaikes Final Pr edict ion Er r or ), yea r , mont h,
dat e, hour , minut e and command by which t he model was gener at ed. The
mat r ix ent r y (2,7) t hus cont a ins t he coded number of which command gener -
at ed t he model. This number is less t han 20 for t he black-box models of t he
t ype above.
Row 3 is t he vect or of est imat ed par amet er s, A, B ,C, D, a nd F, (excluding
leading 1s a nd 0s).
Rows 4 t o 3+n cont ain t he est imat ed covar iance mat r ix.
For cont inuous-t ime models, a possible element (4+n,1) cont ains a dead-t ime
for t he syst em. This is used when comput ing fr equency funct ions in th2ff.
II. For models t hat ar e defined as st at e-space st r uct ur es t her e is an under lying
M-file t hat defines t he st r uct ur e. This M-file is ca lled by
[A,B,C,D,K,X0] = mfname(par,T,aux)
(See mf2th.) For model st r uct ur es t hat ar e defined by ms2th, t he name of t his
M-file is ssmodx9 or ssmodx8 and t he a r gument aux is t he act ua l model
st r uct ur e ms cr eat ed by modstruc. Not ice in par t icular t hat mult i-out put ARX
models ar e int er nally r epr esent ed as st a t e-space models wit h t he aid of
ssmodx9.
Suppose t hat t he number of est imat ed par a met er s is n and t hat t he lengt h of
t he name of your M-file mfname is r. Suppose also t hat t he model has ny out put s
and t hat t he size of t he ar gument aux above is nr t imes nc. Then theta is a
mat r ix of dimension
max(n, ny, nc, 7 + r) by 3+ n + nr + ny)
or ganized as follows:
Row 1 has ent r ies: det er mina nt of innovat ions covar ia nce, sampling int er -
val, number of input s, number of out put s, number of est imat ed par amet er s,
number of r ows of aux, number of columns of aux, and name of
M-file t hat defines t he st r uct ur e.
theta
4-107
Row 2 cont ains t he ent r ies: FPE (Akaikes Fina l Pr edict ion Er r or ), year ,
mont h, dat e, hour , minut e, and command by which t he model was gener at ed.
This last one is a number lar ger t han 20 for st a t e-space st r uct ur es.
Ent r y (2,8) is int er pr et ed as follows: 1 means t hat t he under lying par am-
et er izat ion is in cont inuous t ime, using ssmodx9. ll means t hat t he under -
lying pa r amet er izat ion is in cont inuous t ime, t o be sampled by
fir st -or der -hold, using ssmodx8. 2 mea ns t hat it is in discr et e t ime, again
using ssmodx9. 3 means t hat t he model is a mult iva r iat e ARX model. 4
mea ns t hat t he under lying par amet er izat ion is in discr et e t ime and user de-
fined. 5 means t hat t he model is a user -defined cont inuous-t ime par ame-
t er izat ion, equipped wit h sampling inhibit ion when called wit h a negat ive
value of T.
Row 3 cont ains t he est imat ed (nominal) values of t he par amet er s.
Rows 4 t o 3 + n cont ain t he est ima t ed covar ia nce mat r ix of t he par amet er s.
Rows 4 + n t o 3 + n + nr cont ain t he mat r ix aux.
Rows 4 +n + nr t o 3+n + nr + ny cont ain t he covar iance ma t r ix of t he inno-
vat ions of t he model.
thinit
4-108
t h init
Purpose Set init ial values for t he par amet er s t o be est imat ed.
Syntax th = thinit(th0)
th = thinit(th0,R,pars,sp)
Description This funct ion r andomizes init ial par amet er est imat es for model st r uct ur es th0
in t he t het a for mat t hat cor r espond t o st at e-space models. th is t he same model
st r uct ur e a s th0, but wit h a differ ent nomina l par amet er vect or . This vect or is
used as t he init ial est ima t e by pem.
The par amet er s a r e r a ndomized ar ound pars wit h var iances given by t he r ow
vect or R. Par amet er number k is r andomized as pars(k) + e*sqrt(R(k)),
wher e e is a nor mal r a ndom va r iable wit h zer o mean and a va r iance of 1. The
default va lue of R is a ll ones, and t he default value of pars is t he nominal
par amet er vect or in th0.
Only models t hat give st able pr edict or s ar e accept ed. If sp = 'b', only models
t hat ar e bot h st able and have st able pr edict or s ar e accept ed.
sp = 's' r equir es st abilit y only of t he model, and sp = 'p' r equir es st abilit y
only of t he pr edict or . Sp = 'p' is t he default .
A maximum of 100 t r ials ar e made by thinit. It may be difficult t o find a st able
pr edict or for high or der syst ems just by t r ia l and er r or . An alt er na t ive is t hen
t o comput e t he Kalman filt er pr edict or for a r andomized model.
See Also canstart, mf2th, ms2th, pem
th2arx
4-109
t h 2ar x
Purpose Ext r act t he ARX pa r amet er s fr om a t het a for mat model.
Syntax [A,B] = th2arx(th)
[A,B,dA,dB] = th2arx(th)
Description th is t he model in t he t het a for mat . A and B ar e r et ur ned a s t he ma t r ices t hat
define t he ARX st r uct ur e:
A = [I A1 A2 ... Ana]
B = [B0 B1 ... Bnb]
wher e
Delays in t he syst em ar e indica t ed by leading zer os in t he B mat r ices. See
Sect ion 6 in t he Tut orial.
dA and dB ar e t he st anda r d deviat ions of A and B.
See Also arx2th
y t ( ) A
1
y t 1 ( ) A
na
y t na ( ) + + + B
0
u t ( ) B
1
u t 1 ( ) B
nb
u t nb ( ) + + + =
th2ff, trf
4-110
t h 2ff, t r f
Purpose Comput e t he fr equency r esponse and st a ndar d deviat ions of a t het a for ma t
model.
Syntax [g,phiv] = th2ff(th)
[g,phiv] = th2ff(th,ku,w,ky)
Description th2ff comput es t he fr equency funct ions of th, wher e th is a mat r ix in t het a
for mat cont aining a gener al model.
g is r et ur ned wit h t he t r ansfer funct ion est ima t e (see (3.4), (3.23), and (3.25) in
t he Tut orial)
comput ed at t he fr equencies given in r ow vect or w. If th has sever al input s
and out put s, g is comput ed for t he input and out put number s specified in r ow
vect or s ku and ky, r espect ively. The for mat of g is det ailed under freqfunc.
The default values of ku a nd ky ar e all input and out put pair s cont ained in th.
For a t ime cont inuous model t he fr equency funct ion is obt ained inst ead.
Phiv ( ) is r et ur ned wit h t he est imat ed noise spect r um for each of t he out put s
wher e is t he est imat ed var iance of e(t) (t he loss funct ion) specified by th.
phiv is comput ed at t he same fr equencies as g. The nor malizat ion of t he
spect r um differ s fr om t he one used by spectrum in t he Signal Pr ocessing
Toolbox. See Some Special Topics on page 3-68, for a pr ecise definit ion. Not e
t hat no cr oss-spect r a bet ween differ ent out put s ar e comput ed.
The st andar d deviat ions of t he fr equency funct ion(s) and t he spect r a ar e also
comput ed, using t he Ga uss appr oximat ion for mula. For models wit h
complicat ed par amet er dependencies, numer ica l differ ent iat ion is applied. The
st ep sizes for t he numer ica l der ivat ives ar e det er mined by nuderst.
G e
i
( )

G i ( )

v
( )

H e
i wt
( )
2
=

th2ff, trf
4-111
The default values of t he fr equencies ar e in t he discr et e-t ime ca se ar e
w = [1:128]/128pi/T
wher e T is t he sampling int er val specified by th (default = 1) and for t he
cont inuous-t ime ca se
w = logspace(log10(pi/abs(T)/100),log10(10*pi/ abs(T)),128)
wher e abs(T)is t he under lying sampling int er val for t he cont inuous-t ime
model.
The fr equency funct ions can be gr aphed wit h bodeplot, ffplot, and
nyqplot.
IMPORTANT: The command trf has t he same synt ax as th2ff but does not
ca lculat e t he st anda r d deviat ions, and can be consider ably fast er.
Examples Compar e t he r esult s fr om spect r al ana lysis and a n ARMAX model
(input -out put dynamics only).
th = armax(z,[2 2 2 1]);
gp = th2ff(th);
gs = spa(z);
bodeplot([gs gp])
Plot , but dont st or e, t he fr equency funct ion g associat ed wit h th:
bodeplot(th2ff(th))
See Also bodeplot, etfe, ffplot, nyqplot, sett, spa
th2par
4-112
t h 2pa r
Purpose Ext r act t he pa r amet er s fr om t he t het a for mat .
Syntax [par,P,lam] = th2par(th)
Description th is a model, defined in t he t het a for ma t . par is r et ur ned as t he nominal or
est ima t ed va lues of t he fr ee par amet er s in th. The covar iance mat r ix of t he
par amet er s is obt ained as P, and lam is t he var iance (covar ia nce mat r ix) of t he
innovat ions.
The or der ing for t he par amet er s is as follows. For t he gener al input -out put
model (7.2), you have
Her e, super scr ipt r efer s t o t he input number .
For a st at e-space st r uct ur e, defined by ms2th, t he par amet er s in pars ar e
obt ained in t he following or der : The A mat r ix is fir st scanned r ow by r ow for
fr ee par amet er s. Then t he B ma t r ix is sca nned r ow by r ow, and so on for t he C,
D, K, and X0 mat r ices. (See ms2th.)
For a st at e-space mat r ix t hat is defined by mf2th, t he or der ing of t he
par amet er s is t he same as in your M-file.
Mult ivar iat e ARX models ar e int er nally r epr esent ed in st at e-space for m. The
or der ing of t he par amet er s may not be t r anspa r ent in t his ca se; it is bet t er t o
use th2arx.
pars a
1
a
na
b
1
1
b
nb1
1
b
1
2
b
nb2
2
, , , , , , , , , , [ =
b
1
nu
b
nbnu
nu
c
1
c
nc
d
1
d
nc
f
1
1
f
nf 1
1
f
1
nu
f
nf nu
nu
] , , , , , , , , , , , , , , , ,
th2poly
4-113
t h 2poly
Purpose Conver t t het a mat r ix int o it s component polynomials.
Syntax [A,B,C,D,F,LAM,T] = th2poly(th)
Description This is essent ially t he inver se of t he poly2th funct ion. It r et ur ns t he
polynomia ls of t he gener al model
as cont ained by t he mat r ix th in t het a for mat . See Examining Models on page
3-40.
LAM is t he noise var iance and T is t he sampling int er va l.
See Also poly2th, th2tf, theta
A q ( )y t ( )
B
1
q ( )
F
1
q ( )
--------------u
1
t nk
1
( )
B
nu
q ( )
F
nu
q ( )
-----------------u
nu
t nk
nu
( )
C q ( )
D q ( )
------------e t ( ) + + + =
th2ss
4-114
t h 2ss
Purpose Tr ansfor m a model t o st at e-space for m.
Syntax [A,B,C,D,K,X0] = th2ss(th)
[A,B,C,D,K,X0,dA,dB,dC,dD,dK,dX0] = th2ss(th)
Description th is t he model given in t he t het a for mat . A, B, C, D,K, and X0 ar e t he mat r ices
in t he st at e-space descr ipt ion
wher e is or depending on whet her th is a cont inuous or
discr et e-t ime model.
dA, dB, dC, dD, dK, and dX0 a r e t he st andar d deviat ions of t he st at e-space
mat r ices.
If t he under lying model it self is a st at e-space model, t he mat r ices cor r espond
t o t he same basis. If t he under lying model is a n input -out put model, an
obser ver canonical for m r epr esent at ion is obt ained.
Algorithm The comput at ion of t he st andar d deviat ions in t he input -out put case assumes
t hat an A polynomial is not used t oget her wit h a F or D polynomial in (7.2). For
t he comput at ion of st anda r d deviat ions in t he case t hat t he st at e-space
par amet er s ar e complicat ed funct ions of t he par amet er s, Gauss appr oximat ion
for mula is used t oget her wit h numer ical der ivat ives. The st ep sizes for t his
differ ent iat ion ar e det er mined by nuderst.
See Also mf2th, ms2th, nuderst
x

t ( ) Ax t ( ) Bu t ( ) Ke t ( ) + + =
x 0 ( ) x0 =
y t ( ) Cx t ( ) Dx t ( ) e t ( ) + + =
x

t ( ) x

x t 1 + ( )
th2tf
4-115
t h 2t f
Purpose Tr ansfor m a model t o t r ansfer funct ion for m.
Syntax [num,den] = th2tf(th)
[num,den] = th2tf(th,iu)
Description th is a model given in t he t het a for mat . num is a mat r ix whose r ow number k gives
t he numer at or polynomial associat ed wit h t he t r ansfer funct ion fr om input
number iu t o out put number k. den is a r ow vect or giving t he (common)
denominat or polynomial for t hese t r ansfer funct ions. The default value of iu is 1.
The for mat s of num and den ar e t he same as t hose used by t he Signal Pr ocessing
Toolbox and t he Cont r ol Syst ems Toolbox, bot h for cont inuous-t ime and
discr et e-t ime models. See Examining Models on page 3-40.
To obt ain t he t r ansfer funct ion fr om noise sour ce number k, ent er iu = k.
Ex amples For a cont inuous-t ime model
num = [1 2]
den = [1 3 0]
cor r esponds t o t he t r ansfer funct ion
For a discr et e-t ime model
num = [2 4 0]
den = [1 2 3 5]
cor r esponds t o t he t r ansfer funct ion
which is t he same as
See Also th2poly
G s ( )
s 2 +
s
2
3s +
---------------- - =
H z ( )
2z
2
4z +
z
3
2z
2
3z 5 + + +
----------------------------------------- =
H q ( )
2q
1
4q
2
+
1 2q
1
3q
2
5q
3
+ + +
-------------------------------------------------------- =
th2zp, zp
4-116
t h 2zp, zp
Purpose Comput e zer os, poles, and st at ic gains of a t het a for mat model.
Syntax [zepo,k] = th2zp(th)
[zepo,k] = th2zp(th,ku,ky,thresh)
Description For any model descr ibed in t het a for mat by th, t he poles and zer os and st at ic
gains, along wit h t heir st a ndar d deviat ions ar e comput ed. The poles and zer os
ar e st or ed in coded for m in t he mat r ix zepo, while t he st at ic gains a r e r et ur ned
in k.
The best wa y t o display t he infor mat ion in zepo is t o plot it using zpplot. The
infor mat ion can also be r et r ieved wit h getzp.
The fir st r ow of k cont ains t he int eger (jy-1)1000+ju, wher e jy is t he out put
number and ju is t he input number for t he gain in quest ion. The second r ow of
k cont ains t he cor r esponding gains, and t he t hir d r ow t he st anda r d deviat ion
of t he gain in quest ion.
NOTE: The gain her e is t he st at ic gain, i.e., t he st eady st at e gain fr om a st ep in
input number ju t o out put number jy. It is t hus t he same for a discr et e-t ime
and a cont inuous-t ime r epr esent at ion of t he same model. This is differ ent
fr om t he r out ines ss2zp and zp2ss in t he Signal Pr ocessing Toolbox, which
use t he t ransfer function gain, i.e., t he coefficient of t he highest power in t he
numer at or.
Row vect or s ku and ky cont ain t he indices of t he input s and out put s,
r espect ively, for which t he zer os, poles and gains a r e t o be comput ed. In t his
cont ext , t he noise e(t ) is count ed as input s wit h negat ive number s. Tha t is,
noise sour ce number ju (t he ju-t h component of e(t) is count ed as input
number ju. The value 0 in t he vect or ku is t he default for all noise sour ces.
The default values of ku and ky ar e all input s and a ll out put s (no noise input s).
The opt ional a r gument thresh is a t hr eshold for t he comput a t ion of t he zer os.
Zer os a t infinit y may, due t o t he numer ical pr ocedur e, end up a s lar ge, finit e
values. To a void t his, any zer o whose absolut e value is la r ger t han thresh is
r egar ded t o be at infinit y. The default va lue of thresh is 100000.
The pr ocedur e handles bot h models in cont inuous and discr et e t ime.
th2zp, zp
4-117
For t he gener al discr et e-t ime mult i-input , single-out put model
t he zer os ar e t he r oot s of (wit h z r eplacing t he for wa r d shift
oper at or q), and t he poles ar e t he r oot s of . The st at ic gain is
k =B(1)/ (A(1)F(1)).
For models t hat ar e int er nally r epr esent ed in st at e-space for m, t he poles ar e
t he eigenvalues of t he syst em mat r ix. The zer os ar e t he zer os of t he
cor r esponding t r ansfer funct ion. These zer os may t hus differ fr om t he
t ransmission zeros associat ed wit h t he mult iva r iable syst em. To find t he
t r ans-mission zer os, fir st use th2ss and t hen apply tzero fr om t he Cont r ol
Syst em Toolbox.
Not e t hat you cannot r ely on infor mat ion a bout zer os and poles a t t he or igin
and at infinit y. (This is a somewhat confusing issue anyway.)
zepo is r et ur ned in a for ma t t hat a llows ea sy plot t ing wit h zpplot. (Then zer os
and poles at t he or igin and at infinit y ar e ignor ed.) The r out ine zpform is useful
when compar ing differ ent models.
The alt er nat ive r out ine zp has t he same synt ax as th2zp but does not comput e
st a ndar d deviat ions. This can be a useful alt er nat ive, when t he st a ndar d
deviat ions ar e not of int er est , and comput at ion t ime for th2zp is long.
Mor eover , zp uses ss2zp fr om t he Signa l Pr ocessing Toolbox, which may give
bet t er numer ical accur acy in difficult cases.
Not e : Alt hough zp comput es zer os and poles for all combinat ions of noise
sour ces and out put s, pr esent in t he indices ky, ku, t he command th2zp only
gives infor mat ion about poles and zer os fr om noise sour ce number ju t o out put
number ju (if ku cont ains t he number -ju).
Algorithm The st anda r d deviat ions a r e comput ed using Gausss appr oximat ion for mula,
using t he par amet er cova r iance mat r ix cont ained in th. When t he t r ansfer
funct ion depends on t he par a met er s in a complicat ed way, numer ical
A q ( )y t ( )
B
1
q ( )
F
1
q ( )
--------------u
1
t nk
1
( )
B
nu
q ( )
F
nu
q ( )
-----------------u
nu
t nk
nu
( )
C q ( )
D q ( )
------------e t ( ) + + + =
z
nb nk +
B z ( )
z
na nf +
A z ( )F z ( )
th2zp, zp
4-118
differ ent iat ion is applied. The st ep sizes for t he differ ent iat ion ar e det er mined
in t he M-file nuderst.
Not e t hat Gausss appr oximat ion for mula gives infinit e var iance t o poles a nd
zer os t hat ar e exact ly r epeat ed.
Examples The st at ement
zpplot(th2zp(th))
plot s, but does not st or e, t he poles and zer os.
To compa r e t he zer os a nd poles of second and t hir d or der ARX models
(input -out put dynamics only), use
th2 = arx(z,[2 2 1]);
th3 = arx(z,[3 3 1]);
zp2 = th2zp(th2);
zp3 = th2zp(th3);
zpplot(zpform(zp2,zp3))
See Also getzp, theta, zepo, zpform, zpplot
unfix par
4-119
unfixpar
Purpose Fr ee par amet er s in st r uct ur es defined by ms2th and arx2th.
Syntax thn = unfixpar(tho,matrix)
thn = unfixpar(tho,matrix,elements)
Description This funct ion is t he inver se of fixpar. The int er pr et at ion of t he ar gument s is
t he same. unfixpar makes t he indicat ed par amet er s fr ee par amet er s t o be
est imat ed. The nominal/init ial values of t hese par a met er s ar e t aken t o be
equal t o t heir a ct ual values in t he st r uct ur e tho.
See Also fixpar, ms2th, theta, thinit
zepo
4-120
zepo
Purpose Descr ibe t he zer os and pole for mat .
Syntax help zepo
Description The zepo for mat is cr eat ed by th2zp and zp and used by zpplot. It cont a ins
infor mat ion about zer os and poles and t heir st andar d devia t ions. The int er na l
for mat is int ended t o be t r anspar ent t o t he user . The basic way t o display t he
infor mat ion is t o use t he zpplot command. Some specific infor -ma t ion is
r et r ieved fr om t he for ma t by t he funct ion getzp. This ent r y gives t he det ails of
t he int er nal r epr esent at ion, but t his infor mat ion is not necessar y for most
user s of t he Syst em Ident ificat ion Toolbox.
The fir st r ow of t he mat r ix consist s of int eger s t hat give infor mat ion a bout
what t he column below cont ains. The int eger s a r e coded in t he following way:
The zer os associa t ed wit h input number ku and out put number ky cor r e-
spond t o t he number (ky - 1)*1000 + ku.
The st andar d deviat ions of t hese zer os cor r espond t o t he number
(ky-1)*1000 + ku +60.
The poles associat ed wit h input number ku a nd out put number ky cor r e-
spond t o t he number (k y - 1)*1000 + ku + 20.
The st andar d deviat ion of t hese poles cor r espond t o t he number
(ky - 1)*1000 + ku + 80.
The zer os associat ed wit h noise input number ky and out put number ky (only
t hese ar e nor mally r epr esent ed) cor r espond t o t he number 500 + ky.
The st andar d deviat ion of t hese, t he cor r esponding poles, and t heir st andar d
deviat ions ar e obt ained by adding 60, 20, and 80, r espect ively t o t his num-
ber .
Posit ions cor r esponding t o nonexist ing zer os and poles (as well as zer os and
poles a t infinit y) ar e r epr esent ed by inf.
If any of t he a bove number s is negat ive, it indicat es t hat t he pole or zer o r ep-
r esent at ion cor r esponds t o a cont inuous-t ime model. Then t he absolut e val-
ue of t he number has t he int er pr et at ion a bove.
zepo
4-121
For complex conjugat ed pair s, t he fir st r ow in t he cor r esponding ent r y for t he
st andar d deviat ion cont ains a complex number whose r eal and imagina r y
pa r t s ar e t he st andar d deviat ions of t he r eal and imaginar y pa r t s, r espec-
t ively, of t he pole or zer o in quest ion. The next r ow ent r y (cor r es-ponding t o
t he conjugat e pole or zer o) cont ains a r eal number t ha t is t he cor r elat ion be-
t ween t he r eal and imagina r y par t s.
See Also getzp, th2zp, zpform, zpplot
zpform
4-122
zpfor m
Purpose Mer ge zer o-pole infor ma t ion fr om differ ent models.
Syntax zepo = zpform(zepo1,zepo2,...,ku)
Description The zer os a nd poles in zepo1, zepo2, ... fr om differ ent models ar e mer ged int o
one ma t r ix t o be used by zpplot. zepo1, zepo2, ... have t he for mat as pr oduced
by th2zp. ku is an opt ional r ow vect or cont aining t he input number s t o be
picked out when for ming zepo. The default value is ku is equal t o all input s
pr esent in zepo1, zepo2, ... A ma ximum of five input ar gument s t o
zpform is possible.
Examples The st at ement
zpplot(zpform(zpbj2,zpbj4,zpax2,zpax4,0))
compar es t he noise char act er ist ics fr om four differ ent models.
See Also th2zp, zpplot
zpplot
4-123
zpplot
Purpose Plot zer os a nd poles.
Syntax zpplot(zepo)
zpplot(zpform(zepo1,zepo2, ..., zepon))
zpplot(zepo,sd,mode,axis)
Description The zer os and poles specified by zepo (see zepo for t he for mat ) ar e gr aphed,
wit h o denot ing zer os and x denot ing poles. Poles and zer os associat ed wit h t he
same input , but differ ent models, a r e always gr a phed in t he same dia gr a m, and
pr essing t he Re t urn key advances t he plot fr om one model t o t he next . On
color scr eens poles, zer os and t heir confidence r egions, cor r esponding t o t he
same model all have t he same color . Poles and zer os at infinit y ar e ignor ed. For
discr et e-t ime models, zer os and poles a t t he or igin ar e also ignor ed.
If sd ha s a va lue lar ger t han zer o, confidence r egions ar ound t he poles and
zer os ar e also gr aphed. The r egions cor r esponding t o sd st a ndar d deviat ions
ar e ma r ked. The default value is sd = 0. Not e t hat t he confidence r egions ma y
somet imes st r et ch out side t he plot , but t hey a r e always symmet r ic a r ound t he
indicat ed zer o or pole.
If t he poles and zer os a r e associat ed wit h a discr et e-t ime model, a unit cir cle is
also dr awn.
When zepo cont ains infor mat ion a bout sever al differ ent input s, t her e ar e some
opt ions:
mode = 'sub' split s t he scr een int o sever a l plot s.
mode = 'same' gives all plot s in t he sa me diagr am. Pr essing t he Re t urn key
advances t he plot s.
mode = 'sep' er ases t he pr evious plot befor e t he next input is t r eat ed.
The default value is mode = 'sub'.
axis = [x1 x2 y1 y2] fixes t he axis sca ling accor dingly. axis = m is t he same
as
axis = [m m m m]
zpplot
4-124
Examples zpbj = th2zp(thbj2);
zpax = th2zp(tharmax4);
zpoe = th2zp(thoe3);
zpplot(zpform(zpoe,zpax,zpbj),3)
show a ll zer os a nd poles of t hr ee models along wit h t he confidence r egions
cor r esponding t o t hr ee st a ndar d deviat ions.
See Also th2zp, zpform
I-125
I ndex
A
adapt ive noise cancelling 4-82
Akaikes Final Pr edict ion Er r or (FPE) 3-50
AR model 3-23
ARARMAX st r uct ur e 3-12
ARMAX model 2-22
ARMAX st r uct ur e 3-11
ARX model 1-6, 2-20, 3-6, 3-10, 3-17, 3-22, 3-29
B
basic t ools 3-3
Bode diagr am 2-29
Bode plot 1-9
Box-J enkins (BJ ) st r uct ur e 3-11
Box-J enkins model 2-22
Bur gs met hod 3-23
C
canonical for ms 3-35
communicat ion window ident 2-2
compar isons using compare 3-48
complex-valued dat a 3-79
cor r elat ion analysis 1-4, 2-14, 3-15, 3-20
covar iance funct ion 3-9
covar iance met hod 3-23
cr eat ing models fr om dat a 2-2
cr oss cor r elat ion funct ion 3-52
cr oss spect r um 3-16
D
Dat a Boar d 2-3
dat a handling checklist 2-12
dat a r epr esent at ion 2-7, 3-19
dat a views 1-4
delays 3-10, 3-31
det r ending t he dat a 2-10
dist ur bance 1-5
dr ift mat r ix 3-63
dynamic models, int r oduct ion 1-5
E
est imat ion dat a 1-4
est imat ion met hod
inst ument al var iables 3-17
pr edict ion er r or appr oach 2-18, 3-17
est imat ion met hods
dir ect 2-14
par amet r ic 2-14
subspace met hod 3-18, 3-25
expor t ing t o t he MATLAB wor kspace 2-32
ext ended least squar es (ELS) 3-66
F
fault det ect ion 3-67
feedback 1-13
fr eqfunc for mat 3-20
fr equencies 3-28
fr equency
funct ion 2-15
funct ions 3-8, 3-20
plot s 3-8
r ange 3-8
r esponse 2-15
scales 3-8
fr equency domain descr ipt ion 3-10
fr equency r esponse 1-9
In d e x
I-126
G
Gauss-Newt on minimizat ion 3-24
geomet r ic lat t ice met hod 3-23
gr aphical user int er face (GUI) 2-2
GUI 2-2
t opics 2-34
H
Hamming window 3-21
I
ident window 2-34
ident ificat ion pr ocess, basic st eps 1-10
impor t ing dat a int o t he GUI 2-9
impulse r esponse 1-9, 2-29, 3-8, 3-9, 3-15
Infor mat ion Theor et ic Cr it er ion (AIC) 3-50
init ial condit ion 3-24
init ial par amet er values 3-37
innovat ions for m 3-13, 3-33
input signals 1-5
inst r ument al var iable 3-17
(IV) met hod 3-22
t echnique 3-23
it er at ions 3-27
it er at ive sear ch 3-24
K
Kalman-gain mat r ix 3-33
L
lag widow 3-16
layout 2-35
M
main ident window 2-34
maximum likelihood
cr it er ion 3-26
met hod 3-17
memor y hor izon 3-63
model
out put -er r or 1-7
pr oper t ies 1-9
set 1-4
st at e-space 1-7
st r uct ur e 2-17, 3-3
st r uct ur e select ion 3-3
st r uct ur es 3-29
uncer t aint y 3-53
validat ion 1-4
view funct ions 2-27
views 1-4, 1-7, 2-4
Model Boar d 2-3
mult ivar iable ARX model 3-30
mult ivar iable syst ems 1-16, 3-23
N
noise 1-5
noise model 1-7
noise sour ce 1-7, 2-31
noise-fr ee simulat ion 1-8
noise-fr ee simulat ions 3-53
nonpar amet r ic 3-10, 3-19
nonpar amet r ic ident ificat ion 1-4
Nor malized Gr adient (NG) Appr oach 3-64
numer ical differ ent iat ion 3-37
O
offset s 3-58
In d e x
I-127
out lier s
signals 1-4
out put signals 1-5
Out put -Er r or (OE) st r uct ur e 3-11
Out put -Er r or model 1-7, 2-22
P
par amet r ic ident ificat ion 1-4
per iodogr am 3-21
poles 1-9
pr edict ion
er r or ident ificat ion 2-18
er r or met hod 3-17
pr efilt er ing 2-11
pr efilt er ing signals 2-11
Q
Quickst ar t menu it em 2-12
R
r ecur sive
ident ificat ion 3-4, 3-61
least squar es 3-64
par amet er est imat ion 3-61
r efer ences list 1-19
r esampling 2-11
r obust est imat ion t echniques 3-27
S
sampling int er val 3-30
select ing dat a r anges 2-11
Sessions 2-5
shift oper at or 3-8
simulat ing dat a 2-12
spect r a 3-8, 3-16
spect r al analysis 1-4, 3-16, 3-20
spect r um 3-9, 3-20
st ar t up ident ificat ion pr ocedur e 1-12
st at e vect or 3-13
st at e-space
for m 3-13
model 1-7, 2-24
modeling 3-4
models 3-33
st ep r esponse 1-9, 2-29
st r uct ur e 1-4
subspace met hod 3-18, 3-25
T
t het a for mat 3-22, 3-29
t ime domain descr ipt ion 3-9
t ime-cont inuous syst ems 3-30
t r ansfer funct ion 1-6
t r ansient r esponse 1-9, 2-29
U
Unnor malized Gr adient (UG) Appr oach 3-64
V
validat ion dat a 1-4
W
whit e noise 3-9
window sizes 3-21
Wor king Dat a set 2-3
wor kspace var iables 2-6
In d e x
I-128
Y
Yule-Walker appr oach 3-23
Z
zer os 1-9

You might also like