You are on page 1of 274

Computation

Visualization
Programming
User s Gui de
Lennart Ljung
System I denti fi cati on
Tool box
For Use with MATLAB

How to Conta ct The Ma thW orks:


508-647-7000 Phone
508-647-7001 Fax
The MathWorks, I nc. Mai l
24 Pri me Park Way
Nati ck, MA 01760-1500
ht t p: //www. mat hwor ks . com Web
f t p. mat hwor ks . com Anonymous FTP ser ver
c omp. s of t - s y s . mat l ab Newsgroup
s uppor t @mat hwor ks . com Techni cal support
s ugges t @mat hwor ks . com Product enhancement suggesti ons
bugs @mat hwor ks . com Bug r epor ts
doc@mat hwor ks . com Documentati on err or r epor ts
s ubs cr i be@mat hwor ks . com Subscr i bi ng user r egi strati on
s er v i ce@mat hwor ks . com Or der status, l i cense renewal s, passcodes
i nf o@mat hwor ks . com Sal es, pr i ci ng, and gener al i nformati on
System I dentification Toolbox Users Guide
COPYRI GHT 1988 - 1997 by The MathWor ks, I nc. Al l Ri ghts Reser ved.
The softwar e descr i bed i n thi s document i s fur ni shed under a l i cense agr eement. The softwar e may be used
or copied onl y under the ter ms of the l i cense agr eement. No par t of thi s manual may be photocopi ed or r epr o-
duced i n any for m wi thout pr i or wr i tten consent fr om The MathWorks, I nc.
U.S. GOVERNMENT: I f Li censee is acqui r i ng the Pr ogr ams on behal f of any uni t or agency of the U.S.
Gover nment, the fol l owi ng shal l appl y: (a) For uni ts of the Depar tment of Defense: the Gover nment shal l
have onl y the r i ghts speci fi ed i n the l i cense under whi ch the commer ci al computer softwar e or commer ci al
softwar e documentati on was obtained, as set for th in subpar agr aph (a) of the Ri ghts in Commerci al
Computer Softwar e or Commer ci al Softwar e Documentati on Cl ause at DFARS 227.7202-3, ther efor e the
r i ghts set for th her ei n shal l appl y; and (b) For any other unit or agency: NOTI CE: Notwi thstandi ng any
other l ease or l i cense agr eement that may per tai n to, or accompany the del i ver y of, the computer softwar e
and accompanyi ng documentati on, the r i ghts of the Gover nment r egar di ng i ts use, repr oducti on, and di scl o-
sur e ar e as set for th in Cl ause 52.227-19 (c)(2) of the FAR.
MATLAB, Si muli nk, Handle Gr aphi cs, and Real -Ti me Wor kshop ar e r egi ster ed trademar ks and Statefl ow
and Tar get Language Compi ler ar e tr ademar ks of The MathWor ks, I nc.
Other pr oduct or br and names are tr ademar ks or r egister ed tr ademar ks of thei r r espective hol ders.
Pr i nti ng Hi stor y: Apr i l 1988 Fi rst pri nti ng
Jul y 1991 Second pr i nti ng
May 1995 Thi r d pr i nti ng
August 1995 Repr i nt

FAX
u
@
iv
Contents
1
The System Identification Problem
What i s System I denti fi cati on? . . . . . . . . . . . . . . . . . . . . . . . 1-2
How i s that done? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
How do you know i f the model i s any good? . . . . . . . . . . . . . . 1-2
Can the qual i ty of the model be tested i n other ways? . . . . . 1-2
What model s are most common? . . . . . . . . . . . . . . . . . . . . . . 1-2
Do you have to assume a model of a par ti cul ar type? . . . . . . 1-2
What does the System I denti fi cati on Tool box contai n? . . . . 1-2
I snt i t a bi g l i mi tati on to wor k onl y wi th l i near model s? . . . 1-3
How do I get started? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
I s thi s r eal l y al l ther e i s to System I denti fi cati on? . . . . . . . . 1-3
The Si gnal s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5
The Basi c Dynami c Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6
Vari ants of Model Descr i pti ons . . . . . . . . . . . . . . . . . . . . . . . . . 1-6
How to I nter pret the Noi se Source . . . . . . . . . . . . . . . . . . . . . . . 1-7
Ter ms to Character i ze the Model Properti es . . . . . . . . . . . . . . . 1-9
I mpul se Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9
Step Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9
Fr equency Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9
Zeros and Pol es . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9
Model Unstabl e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13
Feedback i n Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13
Noi se Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13
Model Order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-14
Addi ti onal I nputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-14
Nonl i near Effects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-14
Sti l l Probl ems? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-14
Fi t Between Si mul ated and Measur ed Output . . . . . . . . . . 1-15
Resi dual Anal ysi s Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-15
Pol e Zer o Cancel l ati ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-15
What Model Structur es Shoul d be Tested? . . . . . . . . . . . . . 1-15
Mul ti var i abl e Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-16
Avai l abl e Model s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-16
Wor ki ng wi th Subsets of the I nput Output Channel s . . . . 1-17
Some Practi cal Advi ce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-17
v Contents
Reading More About System Identification . . . . . . . . . . . . . . . 1-19
2
The Graphical User Interface
The Model and Data Boar ds . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
The Worki ng Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3
The Vi ews . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3
The Val i dati on Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
The Work Fl ow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
Management Aspects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
Wor kspace Vari abl es . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
Hel p Texts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
Data Representati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7
Getti ng Data i nto the GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8
Taki ng a Look at the Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10
Pr eprocessi ng Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10
Detr endi ng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10
Sel ecti ng Data Ranges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11
Pr efi l teri ng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11
Resampl i ng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11
Qui ckstar t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12
Checkl i st for Data Handl i ng . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12
Si mul ati ng Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12
The Basi cs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-14
Di r ect Esti mati on of the I mpul se Response . . . . . . . . . . . . . . . 2-14
Di r ect Esti mati on of the Frequency Response . . . . . . . . . . . . . 2-15
Esti mati on of Parametri c Model s . . . . . . . . . . . . . . . . . . . . . . . 2-17
Esti mati on Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-18
Resul ti ng Model s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-19
How to Know Whi ch Structure and Method to Use . . . . . . . 2-19
ARX Model s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-20
The Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-20
Enter i ng the Order Parameter s . . . . . . . . . . . . . . . . . . . . . . 2-20
Esti mati ng Many Model s Si mul taneousl y . . . . . . . . . . . . . . 2-20
Esti mati on Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-21
Mul ti -Output Model s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-21
vi
ARMAX, Output-Er ror and Box-Jenki ns Model s . . . . . . . . . . . 2-22
The General Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-22
The Speci al Cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-22
Enter i ng the Model Str uctur e . . . . . . . . . . . . . . . . . . . . . . . . 2-23
Esti mati on Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-23
State-Space Model s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-24
The Model Str uctur e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-24
Enter i ng Bl ack-Box State-Space Model Str uctur es . . . . . . . 2-24
Esti mati ng Many Model s Si mul taneousl y . . . . . . . . . . . . . . 2-24
Esti mati on Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-25
User Defi ned Model Structures . . . . . . . . . . . . . . . . . . . . . . . . . 2-25
State-Space Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-25
Any Model Str uctur e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-26
Vi ews and Model s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-27
The Pl ot Wi ndows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-28
Fi l e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-28
Opti ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-28
Styl e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-29
Channel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-29
Hel p . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-29
Fr equency Response and Di sturbance Spectr a . . . . . . . . . . . . 2-29
Tr ansi ent Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-29
Pol es and Zer os . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-30
Compare Measured and Model Output . . . . . . . . . . . . . . . . . . . 2-30
Resi dual Anal ysi s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-31
Text I nfor mati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-32
Pr esent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-32
Modi fy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-32
Further Anal ysi s i n the MATLAB Workspace . . . . . . . . . . . . . 2-32
Mouse Buttons and Hotkeys . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-34
The Mai n i dent Wi ndow . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-34
Pl ot Wi ndows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-34
Tr oubl eshooti ng i n Pl ots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-35
Layout Questi ons and i dprefs.mat . . . . . . . . . . . . . . . . . . . . . . 2-35
Customi zed Pl ots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-36
I mpor t fr om and Export to Wor kspace . . . . . . . . . . . . . . . . . . . 2-36
What Cannot be Done Usi ng the GUI . . . . . . . . . . . . . . . . . . . 2-37
vii Contents
3
Tutorial
I mpul se Responses, Fr equency Functi ons, and Spectra . . . . . . 3-8
Pol ynomi al Representati on of Tr ansfer Functi ons . . . . . . . . . 3-10
State-Space Repr esentati on of Transfer Functi ons . . . . . . . . . 3-13
Conti nuous-Ti me State-Space Model s . . . . . . . . . . . . . . . . . . . 3-14
Esti mati ng I mpul se Responses . . . . . . . . . . . . . . . . . . . . . . . . . 3-15
Esti mati ng Spectra and Frequency Functi ons . . . . . . . . . . . . . 3-16
Esti mati ng Par ametri c Model s . . . . . . . . . . . . . . . . . . . . . . . . . 3-17
Subspace Methods for Esti mati ng State-Space Model s . . . . . . 3-18
Data Representati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-19
Correl ati on Anal ysi s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20
Spectr al Anal ysi s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20
ARX Model s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-22
AR Model s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-23
Gener al Pol ynomi al Bl ack-Box Model s . . . . . . . . . . . . . . . . . . . 3-23
State-Space Model s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-25
Opti onal Vari abl es . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-26
Pol ynomi al Bl ack-Box Model s . . . . . . . . . . . . . . . . . . . . . . . . . . 3-29
Mul ti var i abl e ARX Model s . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-30
State-Space Model s wi th Free Par ameters . . . . . . . . . . . . . . . 3-33
Di screte-Ti me I nnovati ons Form . . . . . . . . . . . . . . . . . . . . . 3-33
System Dynami cs Expr essed i n Conti nuous Ti me . . . . . . . 3-33
The Bl ack-Box, Di scr ete-Ti me Case . . . . . . . . . . . . . . . . . . . 3-34
State-Space Model s wi th Coupl ed Par ameters . . . . . . . . . . . . 3-36
State-Space Structures: I ni ti al Val ues and
Numeri cal Der i vati ves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-37
Some Exampl es of User-Defi ned Model Str uctur es . . . . . . . . . 3-38
Theta For mat: th . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-40
Fr equency Functi on Format: ff . . . . . . . . . . . . . . . . . . . . . . . . . 3-41
Zero-Pol e Format: zp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-43
State-Space Format: ss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-43
Tr ansfer Functi on For mat: tf . . . . . . . . . . . . . . . . . . . . . . . . . . 3-44
Pol ynomi al Format: pol y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-45
The ARX Format: ar x . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-45
Tr ansfor mati ons Between Di scr ete and Conti nuous Model s . 3-46
Conti nuous-Ti me Model s . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-46
Di screte-Ti me Model s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-46
Tr ansfor mati ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-47
Si mul ati on and Predi cti on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-47
viii
Compari ng Di fferent Structures . . . . . . . . . . . . . . . . . . . . . . . . 3-49
Checki ng Pol e-Zer o Cancel l ati ons . . . . . . . . . . . . . . . . . . . . . . . 3-51
Resi dual Anal ysi s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-52
Noi se-Fr ee Si mul ati ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-53
Assessi ng the Model Uncer tai nty . . . . . . . . . . . . . . . . . . . . . . . 3-53
Compari ng Di fferent Model s . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-54
Condi ti oni ng of the Pr edi cti on Er ror Gradi ent . . . . . . . . . . . . 3-55
Sel ecti ng Model Structures for Mul ti vari abl e Systems . . . . . . 3-55
Offset Level s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-58
Outl i ers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-58
Fi l teri ng Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-58
Feedback i n Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-59
Del ays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-59
The Basi c Al gor i thm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-61
Choosi ng an Adaptati on Mechani sm and Gai n . . . . . . . . . . . . 3-62
Avai l abl e Al gori thms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-65
Segmentati on of Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-67
Ti me Seri es Model i ng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-68
The Sampl i ng I nterval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-70
Out of Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-71
Memory-Speed Tr ade-Offs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-72
Regul ari zati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-72
Local Mi ni ma . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-73
I ni ti al Par ameter Val ues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-73
Li near Regr essi on Model s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-74
Spectr um Normal i zati on and the Sampl i ng I nter val . . . . . . . 3-75
I nter pr etati on of the Loss Functi on . . . . . . . . . . . . . . . . . . . . . 3-77
Enumer ati on of Esti mated Parameter s . . . . . . . . . . . . . . . . . . 3-78
Compl ex-Val ued Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-79
Str ange Resul ts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-79
4
Command Reference
ix Contents

1
The System I denti fi cati on
Probl em
Basic Questions About System Identification . . . . . . . . . . . 1-2
Common Terms Used in System Identification . . . . . . . . . . 1-4
Basic Information About Dynamic Models . . . . . . . . . . . . . . 1-5
The Basic Steps of System Identification . . . . . . . . . . . . . . 1-10
A Startup Identification Procedure . . . . . . . . . . . . . . . . . . . 1-12
Reading More About System Identification. . . . . . . . . . . . . 1-18
1 The System Identi fi cati on Problem
1-2
1. Basic Questions About System Identification
What is System Identification?
System I denti fi cati on al l ows you to bui l d mathemati cal model s of a dynami c
system based on measur ed data.
How is that done?
Essenti al l y by adjusti ng parameter s wi thi n a gi ven model unti l i ts output
coi nci des as wel l as possi bl e wi th the measured output.
How do you know if the model is any good?
A good test i s to take a cl ose l ook at the model s output compar ed to the
measured one on a data set that wasnt used for the fi t ( Val i dati on Data).
Can the quality of the model be tested in other ways?
I t i s al so val uabl e to l ook at what the model coul dnt r eproduce i n the data (the
r esi dual s). Thi s shoul d not be corr el ated wi th other avai l abl e i nfor mati on,
such as the system's i nput.
What models are most common?
The techni ques appl y to ver y gener al model s. Most common model s are
di fference equati ons descr i pti ons, such as ARX and ARMAX model s, as wel l as
al l types of l i near state-space model s.
Do you have to assume a model of a particular type?
For par ametri c model s, you have to speci fy the str uctur e. However , i f you just
assume that the system i s l i near, you can di r ectl y esti mate i ts i mpul se or step
r esponse usi ng Corr el ati on Anal ysi s or i ts fr equency response usi ng Spectr al
Anal ysi s. Thi s al l ows useful compari sons wi th other esti mated model s.
What does the System Identification Toolbox contain?
I t contai ns al l the common techni ques to adjust parameter s i n al l ki nds of
l i near model s. I t al so al l ows you to exami ne the model s pr oper ti es, and to
check i f they are any good, as wel l as to prepr ocess and pol i sh the measured
data.
1-3
Isnt it a big limitation to work only with linear models?
No, actual l y not. Most common model nonl i near i ti es are such that the
measured data shoul d be nonl i nearl y transformed (l i ke squari ng a vol tage
i nput i f you thi nk that i ts the power that i s the sti mul i ). Use physi cal i nsi ght
about the system you are model i ng and try out such transformati ons on model s
that are l i near i n the new var i abl es, and you wi l l cover a l ot!
How do I get started?
I f you are a begi nner , br owse thr ough Chapter and then tr y out a coupl e of the
data sets that come wi th the tool box. Use the graphi cal user i nter face (GUI )
and check out the bui l t-i n hel p functi ons to under stand what you are doi ng.
Is this really all there is to System Identification?
Actual l y, ther e i s a huge amount wri tten on the subject. Experi ence wi th r eal
data i s the dr i vi ng for ce to under stand more. I t i s i mpor tant to remember that
any esti mated model , no matter how good i t l ooks on your screen, has onl y
pi cked up a si mpl e refl ecti on of real i ty. Sur pr i si ngl y often, however , thi s i s
suffi ci ent for rati onal deci si on maki ng.
1 The System Identi fi cati on Problem
1-4
2. Common Terms Used in System Identification
Thi s secti on defi nes some of the terms that are frequentl y used i n System
I denti fi cati on.
Estimation Data i s the data set that i s used to fi t a model to data. I n the
GUI thi s i s the same as the Working Data.
Validation Data i s the data set that i s used for model val i dati on pur poses.
Thi s i ncl udes si mul ati ng the model for these data and computi ng the
resi dual s from the model when appl i ed to these data.
Model Views ar e var i ous ways of i nspecti ng the pr oper ti es of a model . They
i ncl ude l ooki ng at zer os and pol es, transi ent and fr equency r esponse, and
si mi l ar thi ngs.
Data Views are vari ous ways of i nspecti ng pr oper ti es of data sets. A most
common and useful thi ng i s just to pl ot the data and scruti ni ze i t.
So-cal l ed outliers coul d be detected then. These ar e unrel i abl e
measur ements, per haps ar i si ng from fai l ur es i n the measur ement
equi pment. The fr equency contents of the data si gnal s, i n terms of
per i odograms or spectr al esti mates, i s al so most r eveal i ng to study.
Model Sets or Model Structures are fami l i es of model s wi th adjustabl e
parameter s. Parameter Estimation amounts to fi ndi ng the best val ues
of these par ameters. The System I denti fi cati on pr obl em amounts to fi ndi ng
both a good model structure and good numer i cal val ues of i ts par ameters.
Parametric Identification Methods ar e techni ques to esti mate
parameter s i n gi ven model str uctur es. Basi cal l y i t i s a matter of fi ndi ng (by
numer i cal search) those numer i cal val ues of the parameter s that gi ve the
best agr eement between the model s (si mul ated or pr edi cted) output and the
measur ed one.
Nonparametric Identification Methods ar e techni ques to esti mate
model behavi or wi thout necessar i l y usi ng a gi ven parametri zed model set.
Typi cal nonparametri c methods i ncl ude Correlation analysis, whi ch
esti mates a systems i mpul se response, and Spectral analysis, whi ch
esti mates a systems fr equency response.
Model Validation i s the pr ocess of gai ni ng confi dence i n a model .
Essenti al l y thi s i s achi eved by twi sti ng and tur ni ng the model to scruti ni ze
al l aspects of i t. Of par ti cul ar i mportance i s the model s abi l i ty to repr oduce
the behavi or of the Val i dati on Data sets. Thus i t i s i mportant to i nspect the
properti es of the r esi dual s from the model when appl i ed to the Val i dati on
Data.
1-5
3. Basic Information About Dynamic Models
System I denti fi cati on i s about bui l di ng Dynamic Models. Some knowl edge
about such model s i s ther efor e necessary for successful use of the tool box.The
topi c i s tr eated i n several pl aces i n the Chapter and ther e i s a wi de range of
textbooks avai l abl e for i ntr oductor y and i n-depth studi es. For basi c use of the
tool box, i t i s suffi ci ent to have qui te super fi ci al i nsi ghts about dynami c model s.
Thi s secti on descr i bes such a basi c l evel of knowl edge.
The Signals
Model s descr i be r el ati onshi ps between measur ed si gnal s. I t i s conveni ent to
di sti ngui sh between input si gnal s and output si gnal s. The outputs ar e then
partl y deter mi ned by the i nputs. Thi nk for exampl e of an ai rpl ane wher e the
i nputs woul d be the di fferent contr ol surfaces, ai l er ons, el evator s, and the l i ke,
whi l e the outputs woul d be the ai r pl anes ori entati on and posi ti on. I n most
cases, the outputs ar e al so affected by mor e si gnal s than the measur ed i nputs.
I n the ai r pl ane exampl e i t woul d be wi nd gusts and tur bul ence effects. Such
unmeasur ed i nputs wi l l be cal l ed disturbance si gnal s or noise. I f we denote
i nputs, outputs, and di stur bances by u, y, and e, r especti vel y, the r el ati onshi p
can be depi cted i n the fol l owi ng fi gur e.
Figure 1-1: Input Signals u, Output Signals y, and Disturbances e
Al l these si gnal s are functi ons of ti me, and the val ue of the i nput at ti me t wi l l
be denoted by u(t). Often, i n the i denti fi cati on context, onl y di screte-ti me poi nts
ar e consi dered, si nce the measurement equi pment typi cal l y r ecor ds the si gnal s
just at di scr ete-ti me i nstants, often equal l y spr ead i n ti me wi th a
sampling interval of T ti me uni ts. The model i ng probl em i s then to descr i be
how the three si gnal s rel ate to each other .
y
e
u
1 The System Identi fi cati on Problem
1-6
The Basic Dynamic Model
The basi c r el ati onshi p i s the linear difference equation. An exampl e of such
an equati on i s the fol l owi ng one.
y(t)-1. 5y(t-T)+0.7y(t-2T)=0.9u(t-2T)+0.5u(t-3T)+e(t)(ARX)
Such a r el ati onshi p tel l s us, for exampl e, how to compute the output y(t) i f the
i nput i s known and the di stur bance can be i gnor ed:
y(t)=1.5y(t-T )-0.7y(t-2T)+0.9u(t-2T)+0.5u(t-3T)
The output at ti me t i s thus computed as a l i near combi nati on of past outputs
and past i nputs. I t fol l ows, for exampl e, that the output at ti me t depends on
the i nput si gnal at many pr evi ous ti me i nstants. Thi s i s what the wor d
dynamic r efer s to. The i denti fi cati on probl em i s then to use measurements of
u and y to fi gur e out
The coeffi ci ents i n thi s equati on (i .e., -1.5, 0.7, etc.)
How many del ayed outputs to use i n the descri pti on (two i n the exampl e:
y(t-T) and y(t-2T))
The time delay i n the system i s (2T i n the exampl e: you see from the second
equati on that i t takes 2T ti me uni ts befor e a change i n u wi l l affect y) and
How many del ayed i nputs to use (two i n the exampl e: u(t-2T) and u(t-3T))
Variants of Model Descriptions
The model gi ven above i s cal l ed an ARX model. There are a handful of
vari ants of thi s model known as Output-Error (OE) model s, ARMAX model s,
FIR model s, and Box-J enkins (BJ) model s. These ar e descri bed l ater on i n
the manual . At a basi c l evel i t i s suffi ci ent to thi nk of them as vari ants of the
ARX model al l owi ng al so a char acter i zati on of the properti es of the
di stur bances e.
General linear models can be descr i bed symbol i cal l y by
y=Gu+He
whi ch says that the measured output y(t) i s a sum of one contr i buti on that
comes fr om the measured i nput u(t) and one contr i buti on that comes fr om the
noi se He. The symbol G then denotes the dynami c properti es of the system, that
i s, how the output i s for med from the i nput. For l i near systems i t i s cal l ed the
tr ansfer functi on from i nput to output. The symbol H refers to the noi se
1-7
properti es, and i s cal l ed the noi se model . I t descri bes how the di sturbances at
the output are for med from some standardi zed noi se source e(t).
State-space models ar e common repr esentati ons of dynami cal model s. They
descr i be the same type of l i near di fference rel ati onshi p between the i nputs and
the outputs as i n the ARX model , but they are rear ranged so that onl y one
del ay i s used i n the expr essi ons. To achi eve thi s, some extra vari abl es, the
state variables, are i ntr oduced. They ar e not measur ed, but can be
reconstr ucted fr om the measured i nput-output data. Thi s i s especi al l y useful
when there ar e several output si gnal s, i .e., when y(t) i s a vector . Chapter gi ves
more detai l s about thi s. For basi c use of the tool box i t i s suffi ci ent to know that
the order of the state-space model rel ates to the number of del ayed i nputs and
outputs used i n the cor respondi ng l i near di ffer ence equati on. The state-space
repr esentati on l ooks l i ke
x(t+1)=Ax(t)+Bu(t)+K e(t)
y(t)=Cx(t)+Du(t)+e(t)
Her e x(t) i s the vector of state vari abl es. The matr i x K determi nes the noi se
properti es. Noti ce that i f K = 0, then the noi se source e(t) affects onl y the
output, and no speci fi c model of the noi se proper ti es i s bui l t. Thi s corr esponds
to H =1 i n the general descri pti on above, and i s usual l y r efer red to as an
Output-Error model. Noti ce al so that D = 0 means that ther e i s no di r ect
i nfl uence fr om u(t) to y(t). Thus the effect of the i nput on the output al l passes
vi a x(t) and wi l l thus be del ayed at l east one sampl e. The fi rst val ue of the state
var i abl e vector x(0) refl ects the i ni ti al condi ti ons for the system at the
begi nni ng of the data record. When deal i ng wi th model s i n state-space form, a
typi cal opti on i s whether to esti mate D, K, and x(0) or to l et them be zer o.
How to Interpret the Noise Source
I n many cases of system i denti fi cati on, the effects of the noi se on the output ar e
i nsi gni fi cant compar ed to those of the i nput. Wi th good si gnal -to-noi se r ati os
(SNR), i t i s l ess i mpor tant to have an accurate noi se model . Never thel ess i t i s
i mportant to understand the r ol e of the noi se and the noi se sour ce e(t), whether
i t appears i n the ARX model or i n the gener al descri pti ons gi ven above.
There are three aspects of the noi se that shoul d be stressed:
under standi ng whi te noi se
i nter pr eti ng the noi se sour ce
usi ng the noi se sour ce when worki ng wi th the model
1 The System Identi fi cati on Problem
1-8
These aspects are di scussed one by one.
How can we understand whi te noi se? From a formal poi nt of vi ew, the noi se
source e(t) wi l l nor mal l y be regar ded as white noise. Thi s means that i t i s
enti rel y unpredi ctabl e. I n other wor ds, i t i s i mpossi bl e to guess the val ue of e(t)
no matter how accur atel y we have measured past data up to ti me t-1.
How can we i nterpr et the noi se source? The actual noi se contr i buti on to the
output, H e(t), has r eal si gni fi cance. I t contai ns al l the i nfl uences on the
measured y, known and unknown, that are not contai ned i n the i nput u. I t
expl ai ns and captures the fact that even i f an experi ment i s r epeated wi th the
same i nput, the output si gnal wi l l typi cal l y be somewhat di fferent. However,
the noi se source e(t) need not have a physi cal si gni fi cance. I n the ai rpl ane
exampl e menti oned ear l i er, the noi se effects ar e wi nd gusts and turbul ence.
Descr i bi ng these as ar i si ng from a whi te noi se sour ce vi a a tr ansfer functi on H,
i s just a conveni ent way of captur i ng thei r character .
How can we deal wi th the noi se sour ce when usi ng the model ? I f the model i s
used just for si mul ati on, i .e., the responses to var i ous i nputs are to be studi ed,
then the noi se model pl ays no i mmedi ate r ol e. Si nce the noi se source e(t) for
new data wi l l be unknown, i t i s taken as zer o i n the si mul ati ons, so as to study
the effect of the i nput al one (a noi se-free si mul ati on). Maki ng another
si mul ati on wi th e(t) bei ng ar bi tr ary whi te noi se wi l l r eveal how rel i abl e the
r esul t of the si mul ati on i s, but i t wi l l not gi ve a more accurate si mul ati on r esul t
for the actual systems r esponse.
The need and use of the noi se model can be summar i zed as fol l ows:
I t i s, i n most cases, r equi r ed to obtai n a better esti mate for the dynami cs, G.
I t i ndi cates how rel i abl e noi se-fr ee si mul ati ons are.
I t i s r equi r ed for r el i abl e pr edi cti ons and stochasti c control desi gn.
1-9
Terms to Characterize the Model Properties
The pr oper ti es of an i nput-output rel ati onshi p l i ke the ARX model fol l ow fr om
the numeri cal val ues of the coeffi ci ents, and the number of del ays used. Thi s i s
however a fai r l y i mpl i ci t way of tal ki ng about the model proper ti es. I nstead a
number of di fferent ter ms are used i n practi ce:
Impulse Response
The i mpul se response of a dynami cal model i s the output si gnal that r esul ts
when the i nput i s an i mpul se, i .e., u(t) i s zero for al l val ues of t except t=0,
where u(0)=1. I t can be computed as i n the equati on fol l owi ng (ARX), by l etti ng
t be equal to 0, 1, 2, ... and taki ng y(-T)=y(-2T)=0 and u(0)=1.
Step Response
The step r esponse i s the output si gnal that resul ts fr om a step i nput, i .e., u(t)
i s zero for negati ve val ues of t and equal to one for posi ti ve val ues of t. The
i mpul se and step r esponses together are cal l ed the model s transient
response.
Frequency Response
The fr equency response of a l i near dynami c model descri bes how the model
reacts to si nusoi dal i nputs. I f we l et the i nput u(t) be a si nusoi d of a certai n
frequency, then the output y(t) wi l l al so be a si nusoi d of thi s fr equency. The
ampl i tude and the phase (rel ati ve to the i nput) wi l l however be di fferent. Thi s
frequency r esponse i s most often depi cted by two pl ots; one that shows the
ampl i tude change as a functi on of the si nusoi ds frequency and one that shows
the phase shi ft as functi on of fr equency. Thi s i s known as a Bode pl ot.
Zeros and Poles
The zer os and the pol es ar e equi val ent ways of descri bi ng the coeffi ci ents of a
l i near di ffer ence equati on l i ke the ARX model . The pol es rel ate to the
output-si de and the zeros r el ate to the i nput-si de of thi s equati on. The
number of pol es (zer os) i s equal to number of sampl i ng i nter val s between the
most and l east del ayed output (i nput). I n the ARX exampl e i n the begi nni ng of
thi s secti on, ther e ar e consequentl y two pol es and one zer o.
1 The System Identi fi cati on Problem
1-10
4. The Basic Steps of System Identification
The System I denti fi cati on pr obl em i s to esti mate a model of a system based on
obser ved i nput-output data. Several ways to descri be a system and to esti mate
such descri pti ons exi st. Thi s secti on gi ves a br i ef account of the most i mpor tant
appr oaches.
The procedure to determi ne a model of a dynami cal system fr om obser ved
i nput-output data i nvol ves thr ee basi c i ngredi ents:
The i nput-output data
A set of candi date model s (the model structure)
A cri ter i on to sel ect a parti cul ar model i n the set, based on the i nformati on
i n the data (the i denti fi cati on method)
The i denti fi cati on pr ocess amounts to r epeatedl y sel ecti ng a model str uctur e,
computi ng the best model i n the structure, and eval uati ng thi s model s
pr oper ti es to see i f they are sati sfactor y. The cycl e can be i temi zed as fol l ows:
1 Desi gn an experi ment and col l ect i nput-output data fr om the pr ocess to be
i denti fi ed.
2 Exami ne the data. Pol i sh i t so as to remove tr ends and outl i er s, sel ect useful
por ti ons of the or i gi nal data, and appl y fi l ter i ng to enhance i mpor tant
fr equency ranges.
3 Sel ect and defi ne a model structure (a set of candi date system descr i pti ons)
wi thi n whi ch a model i s to be found.
4 Compute the best model i n the model structure accordi ng to the
i nput-output data and a gi ven cri teri on of fi t.
5 Exami ne the obtai ned model s pr oper ti es
6 I f the model i s good enough, then stop; other wi se go back to Step 3 to try
another model set. Possi bl y al so try other esti mati on methods (Step 4) or
work further on the i nput-output data (Steps 1 and 2).
The System I denti fi cati on Tool box offer s several functi ons for each of these
steps.
1-11
For Step 2 ther e are r outi nes to pl ot data, fi l ter data, and r emove tr ends i n
data.
For Step 3 the System I denti fi cati on Tool box offer s a var i ety of nonparametri c
model s, as wel l as al l the most common bl ack-box i nput-output and state-space
str uctur es, and al so general tai l or -made l i near state-space model s i n di scr ete
and conti nuous ti me.
For Step 4 general predi cti on er ror (maxi mum l i kel i hood) methods as wel l as
i nstrumental vari abl e methods and sub-space methods are offered for
parametri c model s, whi l e basi c corr el ati on and spectr al anal ysi s methods ar e
used for nonpar ametr i c model structures.
To exami ne model s i n Step 5, many functi ons al l ow the computati on and
presentati on of frequency functi ons and pol es and zeros, as wel l as si mul ati on
and predi cti on usi ng the model . Functi ons are al so i ncl uded for
tr ansfor mati ons between conti nuous-ti me and di screte-ti me model
descr i pti ons and to formats that are used i n other MATLAB tool boxes, l i ke the
Contr ol System Tool box and the Si gnal Pr ocessi ng Tool box.
1 The System Identi fi cati on Problem
1-12
5. A Startup Identification Procedure
Ther e ar e no standar d and secur e r outes to good model s i n System
I denti fi cati on. Gi ven the number of possi bi l i ti es, i t i s easy to get confused about
what to do, what model structures to test, and so on. Thi s secti on descr i bes one
r oute that often wor ks wel l , but there are no guar antees. The steps r efer to
functi ons wi thi n the GUI , but you ca6n al so go thr ough them i n command
mode. See Chapter for the basi c commands.
Step 1 Looking at the Data
Pl ot the data. Look at them careful l y. Try to see the dynami cs wi th your own
eyes. Can you see the effects i n the outputs of the changes i n the i nput? Can
you see nonl i near effects, l i ke di fferent r esponses at di ffer ent l evel s, or
di fferent responses to a step up and a step down? Are there porti ons of the data
that appear to be messy or car ry no i nfor mati on. Use thi s i nsi ght to sel ect
porti ons of the data for esti mati on and val i dati on pur poses.
Do physi cal l evel s pl ay a r ol e i n your model ? I f not, detrend the data by
r emovi ng thei r mean val ues. The model s wi l l then descr i be how changes i n the
i nput gi ve changes i n output, but not expl ai n the actual l evel s of the si gnal s.
Thi s i s the normal si tuati on.
The defaul t si tuati on, wi th good data, i s that you detr end by r emovi ng means,
and then sel ect the fi r st hal f or so of the data recor d for esti mati on pur poses,
and use the r emai ni ng data for val i dati on. Thi s i s what happens when you
appl y Quickstart under the pop-up menu Preprocess i n the mai n ident
wi ndow.
Step 2 Getting a Feel for the Difficulties
Appl y Quickstart under pop-up menu Estimate i n the mai n ident wi ndow.
Thi s wi l l compute and di spl ay the spectr al anal ysi s esti mate and the
cor rel ati on anal ysi s esti mate, as wel l as a four th or der ARX model wi th a del ay
1-13
esti mated fr om the cor rel ati on anal ysi s and a defaul t order state-space model
computed by n4s i d. Thi s gi ves three pl ots. Look at the agr eement between the
Spectr al Anal ysi s esti mate and the ARX and state-space model s frequency
functi ons
Cor rel ati on Anal ysi s esti mate and the ARX and state-space model s
transi ent r esponses
Measur ed Val i dati on Data output and the ARX and state-space model s
si mul ated outputs
I f these agreements are r easonabl e, the probl em i s not so di ffi cul t, and a
rel ati vel y si mpl e l i near model wi l l do a good job. Some fi ne tuni ng of model
orders, and noi se model s have to be made and you can pr oceed to Step 4.
Otherwi se go to Step 3.
Step 3 Examining the Difficulties
There may be sever al r easons why the compar i sons i n Step 2 di d not l ook good.
Thi s secti on di scusses the most common ones, and how they can be handl ed:
Model Unstable
The ARX or state-space model may tur n out to be unstabl e, but coul d sti l l be
useful for control purposes. Change to a 5- or 10-step ahead predi cti on i nstead
of si mul ati on i n the Model Output View.
Feedback in Data
I f there i s feedback from the output to the i nput, due to some r egul ator, then
the spectral and cor rel ati ons anal ysi s esti mates ar e not rel i abl e. Di scr epanci es
between these esti mates and the ARX and state-space model s can therefore be
di sr egar ded i n thi s case. I n the Model Residuals View of the par ametri c
model s, feedback i n data can al so be vi si bl e as corr el ati on between r esi dual s
and i nput for negati ve l ags.
Noise Model
I f the state-space model i s cl earl y better than the ARX model at repr oduci ng
the measured output, thi s i s an i ndi cati on that the di stur bances have a
substanti al i nfl uence, and i t wi l l be necessary to model them careful l y.
1 The System Identi fi cati on Problem
1-14
Model Order
I f a four th order model does not gi ve a good Model Output pl ot, try ei ghth
order . I f the fi t cl earl y i mpr oves, i t fol l ows that hi gher order model s wi l l be
r equi r ed, but that l i near model s coul d be suffi ci ent.
Additional Inputs
I f the Model Output fi t has not si gni fi cantl y i mproved by the tests so far,
thi nk over the physi cs of the appl i cati on. Ar e there mor e si gnal s that have
been, or coul d be, measured that mi ght i nfl uence the output? I f so, i ncl ude
these among the i nputs and try agai n a four th order ARX model fr om al l the
i nputs. (Note that the i nputs need not at al l be control si gnal s, anythi ng
measurabl e, i ncl udi ng di sturbances, shoul d be tr eated as i nputs).
Nonlinear Effects
I f the fi t between measur ed and model output i s sti l l bad, consi der the physi cs
of the appl i cati on. Ar e there nonl i near effects i n the system? I n that case, for m
the nonl i near i ti es from the measured data. Thi s coul d be as si mpl e as for mi ng
the pr oduct of vol tage and curr ent measur ements, i f you r eal i ze that i t i s the
el ectri cal power that i s the dr i vi ng sti mul us i n, say, a heati ng pr ocess, and
temperatur e i s the output. Thi s i s of cour se appl i cati on dependent. I t does not
take very much wor k, however , to for m a number of addi ti onal i nputs by
r easonabl e nonl i near transformati ons of the measured ones, and just test i f
i ncl usi on of them i mpr oves the fi t.
Still Problems?
I f none of these tests l eads to a model that i s abl e to reproduce the Val i dati on
Data reasonabl y wel l , the concl usi on mi ght be that a suffi ci entl y good model
cannot be produced fr om the data. There may be many reasons for thi s. The
most i mportant one i s that the data si mpl y do not contai n suffi ci ent
i nfor mati on, e.g., due to bad si gnal to noi se r ati os, l arge and nonstati onar y
di stur bances, var yi ng system properti es, etc. The reason may al so be that the
system has some qui te compl i cated nonl i near i ti es, whi ch cannot be real i zed on
physi cal grounds. I n such cases, nonl i near , bl ack box model s coul d be a
sol uti on. Among the most used model s of thi s char acter are the Arti fi ci al
Neur al Networks (ANN).
Otherwi se, use the i nsi ghts of whi ch i nputs to use and whi ch model or ders to
expect and pr oceed to Step 4.
1-15
Step 4 Fine Tuning Orders and Noise Structures
For real data ther e i s no such thi ng as a corr ect model str uctur e. However ,
di ffer ent structures can gi ve qui te di ffer ent model qual i ty. The onl y way to fi nd
thi s out i s to tr y out a number of di ffer ent str uctur es and compar e the
properti es of the obtai ned model s. There ar e a few thi ngs to l ook for i n these
compar i sons:
Fit Between Simulated and Measured Output
Keep the Model Output View open and l ook at the fi t between the model s
si mul ated output and the measured one for the Val i dati on Data. For mal l y, you
coul d pi ck that model , for whi ch thi s number i s the l owest. I n practi ce, i t i s
better to be more pragmati c, and al so take i nto account the model compl exi ty,
and whether the i mpor tant features of the output response ar e captur ed.
Residual Analysis Test
You shoul d r equi r e of a good model , that the cross cor rel ati on functi on between
resi dual s and i nput does not go si gni fi cantl y outsi de the confi dence regi on. A
cl ear peak at l ag k shows that the effect fr om i nput u(t-k) on y(t) i s not pr oper l y
descr i bed. A rul e of thumb i s that a sl owl y varyi ng cross cor rel ati on functi on
outsi de the confi dence regi on i s an i ndi cati on of too few pol es, whi l e sharper
peaks i ndi cate too few zer os or wrong del ays.
Pole Zero Cancellations
I f the pol e-zero pl ot (i ncl udi ng confi dence i nterval s) i ndi cates pol e-zero
cancel l ati ons i n the dynami cs, thi s suggests that l ower or der model s can be
used. I n parti cul ar, i f i t tur ns out that the orders of ARX model s have to be
i ncreased to get a good fi t, but that pol e-zer o cancel l ati ons are i ndi cated, then
the extra pol es are just i ntr oduced to descri be the noi se. Then try ARMAX, OE,
or BJ model str uctur es wi th an A or F pol ynomi al of an or der equal to that of
the number of noncancel ed pol es.
What Model Structures Should be Tested?
Wel l , you can spend any amount of ti me to check out a ver y l arge number of
str uctur es. I t often takes just a few seconds to compute and eval uate a model
i n a cer tai n structure, so that you shoul d have a generous atti tude to the
testi ng. However , experi ence shows that when the basi c properti es of the
systems behavi or have been pi cked up, i t i s not much use to fi ne tune or der s
i n absur dum just to press the fi t by fr acti ons of percents.
1 The System Identi fi cati on Problem
1-16
Many ARX models: Ther e i s a ver y cheap way of testi ng many ARX str uctures
si mul taneousl y. Enter i n the Orders text fi el d many combi nati ons of order s,
usi ng the col on (: ) notati on. When you sel ect Estimate, model s for al l
combi nati ons (easi l y sever al hundreds) ar e computed and thei r (predi cti on
err or) fi t to Val i dati on Data i s shown i n a speci al pl ot. By cl i cki ng i n thi s pl ot
the best model s wi th any chosen number of par ameters wi l l be i nserted i nto the
Model Board, and eval uated as desi r ed.
Many State-space models: A si mi l ar feature i s al so avai l abl e for bl ack-box
state-space model s, esti mated usi ng n4s i d. When a good order has been found,
tr y the PEM esti mati on method, whi ch often i mproves on the accuracy.
ARMAX, OE, and BJ models: Once you have a feel for sui tabl e del ays and
dynami cs or der s, i f i s often useful to tr y out ARMAX, OE, and/or BJ wi th these
order s and test some di fferent or ders for the noi se tr ansfer functi ons (C and D).
Especi al l y for poor l y damped systems, the OE str uctur e i s sui tabl e.
Ther e i s a qui te extensi ve l i ter atur e on or der and structure sel ecti on, and
anyone who woul d l i ke to know more shoul d consul t the references.
Multivariable Systems
Systems wi th many i nput si gnal s and/or many output si gnal s are cal l ed
multivariable. Such systems ar e often mor e chal l engi ng to model . I n parti cul ar
systems wi th several outputs coul d be di ffi cul t. A basi c reason for the
di ffi cul ti es i s that the coupl i ngs between several i nputs and outputs l ead to
more compl ex model s. The str uctur es i nvol ved are ri cher and more par ameters
wi l l be r equi r ed to obtai n a good fi t.
Available Models
The System I denti fi cati on Tool box as wel l as the GUI handl es gener al , l i near
mul ti vari abl e model s. Al l earl i er menti oned model s ar e supported i n the si ngl e
output, mul ti pl e i nput case. For mul ti pl e outputs ARX model s and state-space
model s are cover ed. Mul ti -output ARMAX and OE model s are covered vi a
state-space r epresentati ons: ARMAX cor responds to esti mati ng the K-matri x,
whi l e OE corr esponds to fi xi ng K to zero. (These are pop-up opti ons i n the GUI
model or der edi tor .)
General l y speaki ng, i t i s pr efer abl e to wor k wi th state-space model s i n the
mul ti vari abl e case, si nce the model str uctur e compl exi ty i s easi er to deal wi th.
I t i s essenti al l y just a matter of choosi ng the model order .
1-17
Working with Subsets of the Input Output Channels
I n the process of i denti fyi ng good model s of a system, i t i s often useful to sel ect
subsets of the i nput and output channel s. Parti al model s of the systems
behavi or wi l l then be constr ucted. I t mi ght not, for exampl e, be cl ear i f al l
measured i nputs have a si gni fi cant i nfl uence on the outputs. That i s most
easi l y tested by r emovi ng an i nput channel fr om the data, bui l di ng a model for
how the output(s) depends on the r emai ni ng i nput channel s, and checki ng i f
ther e i s a si gni fi cant deteri or ati on i n the model outputs fi t to the measur ed
one. See al so the di scussi on under Step 3 above.
Gener al l y speaki ng, the fi t gets better when more i nputs ar e i ncl uded and
wor se when more outputs are i ncl uded. To understand the l atter fact, you
shoul d r eal i ze that a model that has to expl ai n the behavi or of sever al outputs
has a tougher job than one that just must account for a si ngl e output. I f you
have di ffi cul ti es obtai ni ng good model s for a mul ti -output system, i t mi ght be
wi se to model one output at a ti me, to fi nd out whi ch ar e the di ffi cul t ones to
handl e.
Model s that are just to be used for si mul ati ons coul d ver y wel l be bui l t up from
si ngl e-output model s, for one output at a ti me. However , model s for pr edi cti on
and control wi l l be abl e to pr oduce better r esul ts i f constructed for al l outputs
si mul taneousl y. Thi s fol l ows from the fact that knowi ng the set of al l previ ous
output channel s gi ves a better basi s for pr edi cti on, than just knowi ng the past
outputs i n one channel .
Some Practical Advice
The GUI i s parti cul arl y sui ted for deal i ng wi th mul ti vari abl e systems si nce i t
wi l l do useful bookkeepi ng for you, handl i ng di ffer ent channel s. You coul d
fol l ow the steps of thi s agenda:
I mpor t data and cr eate a data set wi th al l i nput and output channel s of
i nter est. Do the necessar y pr eprocessi ng of thi s set i n ter ms of detrendi ng,
pr efi l teri ng, etc., and then sel ect a Val i dati on Data set wi th al l channel s.
Then sel ect a Wor ki ng Data set wi th al l channel s, and esti mate state-space
model s of di ffer ent or der s usi ng n4s i d for these data. Exami ne the resul ti ng
model pri mar i l y usi ng the Model Output vi ew.
I f i t i s di ffi cul t to get a good fi t i n al l output channel s or you woul d l i ke to
i nvesti gate how i mpor tant the di fferent i nput channel s are, construct new
data sets usi ng subsets of the ori gi nal i nput/output channel s. Use the pop-up
menu Preprocess > Select Channels for thi s. Dont change the Val i dati on
1 The System Identi fi cati on Problem
1-18
Data. The GUI wi l l keep track of the i nput and output channel number s. I t
wi l l do the ri ght thi ng when eval uati ng the channel -r estr i cted model s
usi ng the Val i dati on Data. I t mi ght al so be appropri ate to see i f
i mprovements i n the fi t are obtai ned for var i ous model types, bui l t for one
output at a ti me.
I f you deci de for a mul ti -output model , i t i s often easi est to use state-space
model s. Use n4s i d as a pr i mar y tool and tr y out pe m when a good order has
been found. Note that n4s i d does not provi de confi dence i nter val s for the
model vi ews.
Readi ng M ore About System Identi fi cati on
1-19
Reading More About System Identification
There i s substanti al l i ter atur e on System I denti fi cati on. The fol l owi ng
textbook deal s wi th i denti fi cati on methods fr om a si mi l ar perspecti ve as thi s
tool box, and al so descri bes methods for physi cal model i ng.
Ljung L. and T. Gl ad. Modeling of Dynamic Systems, Pr enti ce Hal l , Engl ewood
Cl i ffs, N.J. 1994.
For mor e detai l s about the al gor i thms and theori es of i denti fi cati on:
Ljung L.. System Identification - Theory for the User, Prenti ce Hal l , Engl ewood
Cl i ffs, N.J. 1987.
Sder str m T. and P. Stoi ca. System Identification, Prenti ce Hal l I nternati onal ,
London. 1989.
For mor e about system and si gnal s:
Oppenhei m J. and A.S. Wi l l sky. Signals and Systems, Prenti ce Hal l , Engl ewood
Cl i ffs, N.J. 1985.
The fol l owi ng textbook deal s wi th the under l yi ng numer i cal techni ques for
parameter esti mati on.
Denni s, J.E. Jr . and R.B. Schnabel . Numerical Methods for Unconstrained
Optimization and Nonlinear Equations, Pr enti ce Hal l , Engl ewood Cl i ffs, N.J.
1983.
1 The System Identi fi cati on Problem
1-20

2
The Graphi cal User
I nterface
The Big Picture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Handling Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7
Estimating Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-14
Examining Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-27
Some Further GUI Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-34
2 The G raphi cal User Interface
2-2
1. The Big Picture
The System I denti fi cati on Tool box provi des a gr aphi cal user i nterface (GUI ) .
The GUI cover s most of the tool boxs functi ons and gi ves easy access to al l
vari abl es that ar e cr eated duri ng a sessi on. I t i s star ted by typi ng
i de nt
i n the MATLAB command wi ndow.
Figure 2-1: The Main ident Information Window
The Model and Data Boards
System I denti fi cati on i s about data and model s and cr eati ng model s from data.
The mai n i nfor mati on and communi cati on wi ndow ident, i s ther efor e
domi nated by two tabl es:
A tabl e over avai l abl e data sets, each r epresented by an i con.
A tabl e over created model s, each represented by an i con.
2-3
These tabl es wi l l be r efer red to as the Model Boar d and the Data Boar d i n
thi s chapter. You enter data sets i nto the Data Board by
Openi ng earl i er saved sessi ons.
I mpor ti ng them fr om the MATLAB wor kspace.
Creati ng them by detrendi ng, fi l teri ng, sel ecti ng subsets, etc., of another
data set i n the Data Boar d.
I mports ar e handl ed under the pop-up menu Data whi l e creati on of new data
sets i s handl ed under the pop-up menu Preprocess. Handl i ng Data on page
2-7 deal s wi th thi s i n more detai l .
The model s ar e enter ed i nto the summar y board by
Openi ng earl i er saved sessi ons.
I mpor ti ng them fr om the MATLAB wor kspace.
Esti mati ng them from data.
I mports ar e handl ed under the pop-up menu Models, whi l e al l the di fferent
esti mati on schemes are r eached under the pop-up menu Estimate. Mor e about
thi s i n Esti mati ng Model s on page 2-14.
The Data and Model Boards can be r earr anged by dr aggi ng and dr oppi ng.
Mor e boar ds open automati cal l y when necessary or when asked for (under
menu Options).
The Working Data
Al l data sets and model s are cr eated from the Worki ng Data set. Thi s i s the
data that i s gi ven i n the center of the ident wi ndow. To change the Worki ng
Data set dr ag and drop any data set fr om the Data Board on the Worki ng Data
i con.
The Views
Bel ow the Data and Model Boards ar e buttons for di fferent vi ews. These
control what aspects of the data sets and model s you woul d l i ke to exami ne, and
ar e descri bed i n more detai l i n Handl i ng Data on page 2-7 and i n Exami ni ng
Model s on page 2-27. To sel ect a data set or a model , so that i ts pr oper ti es ar e
di spl ayed, cl i ck on i ts i con. A sel ected object i s marked by a thi cker l i ne i n the
i con. To desel ect, cl i ck agai n. An ar bi tr ar y number of data/model objects can be
exami ned si mul taneousl y. To have mor e i nfor mati on about an object,
doubl e-cl i ck on i ts i con.
2 The G raphi cal User Interface
2-4
The Validation Data
The two model vi ews Model Output and Model Residuals i l l ustrate model
pr oper ti es when appl i ed to the Val i dati on Data set. Thi s i s the set mar ked i n
the box bel ow these two vi ews. To change the Val i dati on Data, dr ag and dr op
any data set fr om the Data Board on the Val i dati on Data i con.
I t i s good and common practi ce i n i denti fi cati on to eval uate an esti mated
model s pr oper ti es usi ng a fresh data set, that i s, one that was not used for
the esti mati on. I t i s thus good advi ce to l et the Val i dati on Data be di fferent
from the Worki ng Data, but they shoul d of course be compati bl e wi th these.
The Work Flow
You star t by i mporti ng data (under pop-up menu Data); you exami ne the data
set usi ng the Data Views. You probabl y r emove the means fr om the data and
sel ect subsets of data for esti mati on and val i dati on purposes usi ng the i tems i n
the pop-up menu Preprocess. You then conti nue to esti mate model s, usi ng the
possi bi l i ti es under the pop-up menu Estimate, per haps fi r st doi ng a
qui ckstart. You exami ne the obtai ned model s wi th respect to your favori te
aspects usi ng the di fferent Model Views. The basi c i dea i s that any checked
vi ew shows the pr oper ti es of al l sel ected model s at any ti me. Thi s functi on i s
l i ve so model s and vi ews can be checked i n and out at wi l l i n an onl i ne
fashi on. You sel ect/desel ect a model by cl i cki ng on i ts i con.
I nspi red by the i nfor mati on you gai n from the pl ots, you conti nue to tr y out
di fferent model structur es (model or der s) unti l you fi nd a model you ar e
sati sfi ed wi th.
Management Aspects
Diary: I t i s easy to for get what you have been doi ng. By doubl e-cl i cki ng on a
data/model i con, a compl ete di ary wi l l be gi ven of how thi s object was cr eated,
al ong wi th other key i nformati on. At thi s poi nt you can al so add comments and
change the name of the object and i ts col or.
Layout: To have a good overvi ew of the created model s and data sets, i t i s good
pr acti ce to tr y rear rangi ng the i cons by dr aggi ng and dr oppi ng. I n thi s way
model s cor respondi ng to a par ti cul ar data set can be grouped together, etc. You
can al so open new boards (Options menu Extra model/data boards) to
fur ther r earr ange the i cons. These can be dr agged across the scr een between
di fferent wi ndows. The extra boar ds ar e al so equi pped wi th notepads for your
comments.
2-5
Sessions: The Model and Data Boar ds wi th al l model s and data sets together
wi th thei r di ar i es can be saved (under menu i tem File) at any poi nt, and
rel oaded l ater. Thi s i s the counterpar t of save/l oad workspace i n the
command-dri ven MATLAB. The four most recent sessi ons ar e l i sted under File
for i mmedi ate open.
Cleanliness: The boar ds wi l l hol d an ar bi tr ary number of model s and data
sets (by cr eati ng cl ones of the board when necessary). I t i s however advi sabl e
to cl ear (del ete) model s and data sets that no l onger are of i nterest. Do that by
draggi ng the object to the Trash Can. (Doubl e-cl i cki ng on the trash can wi l l
open i t up, and i ts contents can be retr i eved.)
Window Culture: Di al og and pl ot wi ndows ar e best managed by the GUI s
cl os e functi on (submenu i tem under File menu, or sel ect Close, or check/
uncheck the cor respondi ng Vi ew box). They may al so be qui tted by the speci fi c
wi ndow systems qui t/cl ose functi on. Thi s does no harm, but qui t wi l l not be
properl y acknowl edged by the GUI , and the wi ndow wi l l have to be re-created
next ti me i t i s to be used.
I t i s gener al l y not sui tabl e to i coni fy the wi ndows the GUI s handl i ng and
wi ndow management system i s usual l y a better al ternati ve.
Workspace Variables
The model s and data sets created wi thi n the GUI ar e nor mal l y not avai l abl e i n
the MATLAB wor kspace. I ndeed, the wor kspace i s not at al l l i tter ed wi th
var i abl es dur i ng the sessi ons wi th the GUI . The vari abl es can however be
exported at any ti me to the workspace, by draggi ng and droppi ng the object
i con on the To Workspace box. They wi l l then car ry the name i n the
wor kspace that marked the object i con at the ti me of expor t. You can work wi th
the var i abl es i n the workspace, usi ng any MATLAB commands, and then
perhaps i mport modi fi ed ver si ons back i nto the GUI . Note that model s have a
speci fi c i nter nal str uctur e and shoul d be deal t wi th usi ng the MATLAB
commands pr e s ent , t h2f f , t h2s s , etc. See Model Conver si ons on page 4-5 of
the "Command Reference" chapter.
The GUI s names of data sets and model s are suggested by defaul t procedures.
Normal l y, you can enter any other name of your choi ce at the ti me of creati on
of the vari abl e. Names can be changed (after doubl e-cl i cki ng on the i con) at any
ti me. Unl i ke the wor kspace si tuati on, two GUI objects can car ry the same
name (i .e., the same str i ng i n thei r i cons).
2 The G raphi cal User Interface
2-6
The GUI produces a handful of gl obal workspace vari abl es for management
pur poses. They al l start wi th the prefi x XI D.
NOTE: Do not c l e ar al l or c l ear gl obal duri ng a GUI sessi on! Thi s woul d
mean that you l ose control over the objects that you have created. The same
di saster occur s i f you do cl g or qui t the mai n ident wi ndow. I t i s however
safe to c l ear (wi thout addi ng al l or gl obal ) the wor kspace at any ti me.
Help Texts
The GUI contai ns some 100 hel p texts that ar e accessi bl e i n a nested fashi on,
when r equi r ed. The mai n ident wi ndow contai ns general hel p topi cs under the
Help menu. Thi s i s al so the case for the vari ous pl ot wi ndows. I n addi ti on,
ever y di al og box has a Help push button for cur rent hel p and advi ce.
2-7
2. Handling Data
Data Representation
I n the System I denti fi cati on Tool box (SI TB), si gnal s and observed data are
repr esented as col umn vector s, e.g.,
The entr y i n row number k, i .e., u(k), wi l l then be the si gnal s val ue at sampl i ng
i nstant number k. I t i s gener al l y assumed i n the tool box that data ar e sampl ed
at equi di stant sampl i ng ti mes, and the sampl i ng i nterval T i s suppl i ed as a
speci fi c argument.
We gener al l y denote the i nput to a system by the l etter u and the output by y.
I f the system has several i nput channel s, the i nput data i s represented by a
matr i x, wher e the col umns ar e the i nput si gnal s i n the di ffer ent channel s:
The same hol ds for systems wi th sever al output channel s.
The observed i nput-output data recor d i s repr esented i n the SI TB by a matr i x,
where the fi r st col umn(s) i s the output, fol l owed by the i nput col umn(s):
z = [ y u] ;
When you wor k wi th the GUI , you onl y need to thi nk of these r epr esentati on
i ssues when you i nser t the data set i nto the summary board. The GUI wi l l then
handl e the data r epresentati on automati cal l y.
u
u 1 ( )
u 2 ( )

u N ( )
=
u u1 u2 um =
2 The G raphi cal User Interface
2-8
Getting Data into the GUI
The i nformati on about a data set that shoul d be suppl i ed to the GUI i s as
fol l ows:
1 The i nput and output si gnal s
2 The name you gi ve to the data set
3 The starti ng ti me
4 The sampl i ng i nterval
5 Data notes
NOTE: I tems 3 and 4 are used onl y to ensur e cor rect ti me and fr equency scal es
when you pl ot data and model characteri sti cs.
These are notes for your own i nfor mati on and bookkeepi ng that wi l l fol l ow the
data and al l model s cr eated fr om them.
2-9
As you sel ect the pop-up menu Data and choose the i tem Import..., a di al og
box wi l l open, where you can enter the i nfor mati on i tems 1 - 5, just l i sted. Thi s
box has si x fi el ds for you to fi l l i n:
Figure 2-2: The Dialog for Importing Data into the GUI
Input and Output: Enter the vari abl e names of the i nput and output
respecti vel y. These shoul d be var i abl es i n your MATLAB workspace, so you
may have to l oad some di sk fi l es fi r st.
Actual l y, you can enter any MATLAB expr essi ons i n these fi el ds, and they wi l l
be eval uated to compute the i nput and the output before i nser ti ng the data i nto
the GUI .
Data name: Enter the name of the data set to be used by the GUI . Thi s name
can be changed l ater on.
Starting time and Sampling interval: Fi l l these out for cor rect ti me and
frequency scal es i n the pl ots.
Note that you can enter any text you want to accompany the data for
bookkeepi ng pur poses.
2 The G raphi cal User Interface
2-10
Fi nal l y, sel ect Import to i nsert the data i nto the GUI . When no more data sets
ar e to be i nser ted, sel ect Close to cl ose the di al og box. Reset wi l l empty al l the
fi el ds of the box.
Taking a Look at the Data
The fi rst thi ng to do after havi ng i nserted the data set i nto the Data Boar d i s
to exami ne i t. By checki ng the Data View i tem Plot Data, a pl ot of the i nput
and output si gnal s wi l l be shown for the data sets that ar e sel ected. You sel ect/
desel ect the data sets by cl i cki ng on them. For mul ti var i abl e data, the di ffer ent
combi nati ons of i nput and output si gnal s are chosen under menu i tem
Channel i n the pl ot wi ndow. Usi ng the z oom functi on (drawi ng r ectangl es wi th
the l eft mouse button down) di ffer ent por ti ons of the data can be exami ned i n
more detai l .
To exami ne the frequency contents of the data, check the Data View i tem
Data Spectra. The functi on i s anal ogous to Plot Data, but the si gnal s spectr a
ar e shown i nstead. By defaul t the per i odograms of the data ar e shown, i .e., the
absol ute squar e of the Fouri er transforms of the data. The pl ot can be changed
to any chosen fr equency range and a number of di ffer ent ways of esti mati ng
spectra, by the Options menu i tem i n the spectr a wi ndow.
The pur pose of exami ni ng the data i n these ways i s to fi nd out i f ther e ar e
porti ons of the data that are not sui tabl e for i denti fi cati on, i f the i nfor mati on
contents of the data i s sui tabl e i n the i nteresti ng frequency regi ons, and i f the
data have to be preprocessed i n some way, before usi ng them for esti mati on.
Preprocessing Data
Detrending
Detrendi ng the data i nvol ves removi ng the mean val ues or l i near trends from
the si gnal s (the means and the l i near trends ar e then computed and r emoved
from each si gnal i ndi vi dual l y). Thi s functi on i s accessed under the pop-up
menu Preprocess, by sel ecti ng i tem Remove Means or Remove Trends.
Mor e advanced detrendi ng, such as removi ng pi ecewi se l i near tr ends or
seasonal var i ati ons cannot be accessed wi thi n the GUI . I t i s general l y
r ecommended that you al ways r emove at l east the mean val ues of the data
before the esti mati on phase, unl ess physi cal i nsi ght i nvol vi ng actual si gnal
l evel s i s bui l t i nto the model s.
2-11
Selecting Data Ranges
I t i s often the case that the whol e data recor d i s not sui tabl e for i denti fi cati on,
due to vari ous undesi red features (mi ssi ng or bad data, outbursts of
di sturbances, l evel changes etc.), so that onl y por ti ons of the data can be used.
I n any case, i t i s advi sabl e to sel ect one por ti on of the measured data for
esti mati on purposes and another porti on for val i dati on purposes. The pop-up
menu i tem Preprocess > Select Range... opens a di al og box, whi ch faci l i tates
the sel ecti on of di ffer ent data porti ons, by typi ng i n the r anges, or mar ki ng
them by drawi ng r ectangl es wi th the mouse button down.
For mul ti vari abl e data i t i s often advantageous to start by worki ng wi th just
some of the i nput and output si gnal s. The menu i tem Preprocess > Select
Channels... al l ows you to sel ect subsets of the i nputs and outputs. Thi s i s done
i n such a way that the i nput/output number i ng r emai ns consi stent when you
eval uate data and model pr oper ti es, for model s cover i ng di ffer ent subsets of the
data.
Prefiltering
By fi l teri ng the i nput and output si gnal s through a l i near fi l ter (the same fi l ter
for al l si gnal s) you can focus the model s fi t to the system to speci fi c frequency
ranges. Thi s i s done by sel ecti ng the pop-up menu i tem Preprocess > Filter...
i n the mai n wi ndow. The di al og i s qui te anal ogous to that of sel ecti ng data
ranges i n the ti me domai n. You mark wi th a r ectangl e i n the spectral pl ots the
i ntended passband or stop band of the fi l ter, you sel ect a button to check i f the
fi l teri ng has the desi red effect, and then you i nser t the fi l tered data i nto the
GUI s Data Boar d.
Prefi l ter i ng i s a good way of r emovi ng hi gh frequency noi se i n the data, and
al so a good al ter nati ve to detr endi ng (by cutti ng out l ow frequenci es fr om the
pass band). Dependi ng on the i ntended model use, you can al so make sure that
the model concentrates on the i mpor tant fr equency ranges. For a model that
wi l l be used for control desi gn, for exampl e, the frequency band around the
i ntended cl osed-l oop bandwi dth i s of speci al i mportance.
Resampling
I f the data turn out to be sampl ed too fast, they can be deci mated, i .e., ever y
k-th val ue i s pi cked, after pr oper pr efi l teri ng (anti al i as fi l teri ng). Thi s i s
obtai ned from menu i tem Preprocess > Resample.
2 The G raphi cal User Interface
2-12
You can al so resampl e at a faster sampl i ng r ate by i nter pol ati on, usi ng the
same command, and gi vi ng a r esampl i ng factor l ess than one.
Quickstart
The pop-up menu i tem Preprocess > Quickstart per for ms the fol l owi ng
sequence of acti ons: I t opens the Ti me pl ot Data vi ew, removes the means fr om
the si gnal s, and i t spl i ts these detr ended data i nto two hal ves. The fi rst one i s
made Wor ki ng Data and the second one becomes Val i dati on Data. Al l the thr ee
created data sets are i nser ted i nto the Data Boar d.
Checklist for Data Handling
I nser t data i nto the GUI s Data Board.
Pl ot the data and exami ne i t car eful l y.
Typi cal l y detrend the data by r emovi ng mean val ues.
Possi bl y prefi l ter the data to enhance and suppr ess vari ous fr equency bands.
Sel ect porti ons of the data for Esti mati on and for Val i dati on. Drag and dr op
these data sets to the corr espondi ng boxes i n the GUI .
Simulating Data
The GUI i s i ntended pri mari l y for wor ki ng wi th real data sets, and does not
i tsel f pr ovi de functi ons for si mul ati ng syntheti c data. That has to be done i n
command mode, and you can use your favor i te pr ocedur e i n SI MULI NK, the
Si gnal Processi ng Tool box, or any other tool box for si mul ati on and then i nsert
the si mul ated data i nto the GUI as descr i bed above.
The System I denti fi cati on Tool box al so has several commands for si mul ati on.
You shoul d check i di nput , i ds i m, pol y2t h, mods t r uc , and ms 2t h i n Chapter 4,
"Command Reference," for detai l s. The fol l owi ng exampl e shows how the
ARMAX model
y (t)-1.5y(t-1)+0.7y(t-2)=u(t-1)+0.5u(t-2)+e(t)-e(t-1)+0. 2e(t-2)
i s si mul ated wi th a bi nar y random i nput u:
model 1 = pol y2t h( [ 1 - 1. 5 0. 7] , [ 0 1 0. 5] , [ 1 - 1 0. 2] ) ;
u = i di nput ( 400, r bs , [ 0 0. 3] ) ;
e = r andn( 400, 1) ;
y = i ds i m( [ u e ] , model 1) ;
2-13
The i nput, u, and the output, y, can now be i mported i nto the Gr aphi cal User
I nter face as data, and the vari ous esti mati on routi nes can be appl i ed to them.
By al so i mporti ng the si mul ati on model , model 1, i nto the GUI , i ts pr oper ti es
can be compar ed to those of the di fferent esti mated model s.
To si mul ate a conti nuous-ti me state-space model :
y=Cx+e
wi th the same i nput, and a sampl i ng i nter val of 0.1 seconds, do the fol l owi ng
i n the System I denti fi cati on Tool box:
A=[ - 1 1; - 0. 5 0] ; B=[ 1; 0. 5] ; C=[ 1 0] ; D=0; K=[ 0. 5; 0. 5] ;
model 2=ms 2t h( mods t r uc( A, B, C, D, K) , ' c ' ) ;
model 2=s e t t ( mode l 2, 0. 1) ;
y =i ds i m( [ u e ] , mode l 2) ;
x

Ax Bu Ke + + =
2 The G raphi cal User Interface
2-14
3. Estimating Models
The Basics
Esti mati ng model s fr om data i s the central acti vi ty i n the System
I denti fi cati on Tool box. I t i s al so the one that offers the most vari ety of
possi bi l i ti es and thus i s the most demandi ng one for the user.
Al l esti mati on routi nes ar e accessed from the pop-up menu Estimate i n the
ident wi ndow. The model s are al ways esti mated usi ng the data set that i s
cur rentl y i n the Working Data box.
One can di sti ngui sh between two di fferent types of esti mati on methods:
Di r ect esti mati on of the I mpul se or the Frequency Response of the system.
These methods ar e often al so cal l ed nonpar ametri c esti mati on methods, and
do not i mpose any str uctur e assumpti ons about the system, other than that
i t i s l i near .
Parametr i c methods. A speci fi c model structure i s assumed, and the
parameter s i n thi s str uctur e ar e esti mated usi ng data. Thi s opens up a l ar ge
var i ety of possi bi l i ti es, corr espondi ng to di fferent ways of descri bi ng the
system. Domi nati ng ways are state-space and several vari ants of di ffer ence
equati on descri pti ons.
Direct Estimation of the Impulse Response
A l i near system can be descr i bed by the i mpul se response g
t
, wi th the pr oper ty
that
The name der i ves from the fact that i f the i nput u(t) i s an i mpul se, i .e., u(t)=1
when t=0 and 0 when t>0 then the output y(t) wi l l be y(t)=g
t
. For a
mul ti vari abl e system, the i mpul se r esponse g
k
wi l l be a p by m matri x, wher e
p i s the number of outputs and m i s the number of i nputs. I ts i -j el ement thus
descri bed the behavi or of the i -th output after an i mpul se i n the j-th i nput.
By choosi ng menu i tem Estimate > Correlation Model and then sel ecti ng
Estimate i n the di al og wi ndow that opens, i mpul se response coeffi ci ents ar e
esti mated di r ectl y fr om the i nput/output data usi ng so cal l ed correlation
y t ( ) g
k
u t k ( )
k 1 =

=
2-15
analysis. The actual method i s descri bed under the command c r a i n the
Command Reference chapter. An opti on that determi nes the or der of a
prewhi teni ng fi l ter can al so be set i n the di al og wi ndow. I t i s not very sensi ti ve
i n most cases, and the defaul t choi ce i s often good enough. To obtai n the defaul t
choi ce wi thout openi ng the di al og wi ndow, you can al so just type the l etter c i n
the ident wi ndow. Thi s i s the hotkey for cor rel ati on anal ysi s.
The resul ti ng i mpul se response esti mate i s pl aced i n the Model Boar d, under
the defaul t name c r a_d. (The name can be changed by doubl e-cl i cki ng on the
model i con and then typi ng i n the desi r ed name i n the di al og box that opens.)
The best way to exami ne the resul t i s to sel ect the Model View Transient
Response. Thi s gi ves a graph of the esti mated response. Thi s vi ew offers a
choi ce between di spl ayi ng the I mpul se or the Step r esponse. For a
mul ti var i abl e system, the di ffer ent channel s, i .e., the r esponses fr om a cer tai n
i nput to a cer tai n output, are sel ected under menu i tem Channel.
The number of l ags for whi ch the i mpul se response i s esti mated, i .e., the l ength
of the esti mated response, i s determi ned as one of the opti ons i n the Transi ent
Response Vi ew.
Direct Estimation of the Frequency Response
The fr equency response of a l i near system i s the Fouri er tr ansform of i ts
i mpul se r esponse. Thi s descri pti on of the system gi ves consi derabl e
engi neeri ng i nsi ght i nto i ts pr oper ti es. The rel ati on between i nput and output
i s often wri tten
y(t)=G(z)u(t)+v(t)
where G i s the tr ansfer functi on and v i s the addi ti ve di stur bance. The functi on
as a functi on of (angul ar) frequency i s then the frequency r esponse or
frequency functi on. T i s the sampl i ng i nterval . I f you need more detai l s on the
di ffer ent i nterpretati ons of the fr equency response, consul t See The System
I denti fi cati on Probl em on page 3-8. i n the Tutorial or any textbook on l i near
systems.
The systems frequency response i s di r ectl y esti mated usi ng Spectral Analysis
by the menu i tem Estimate > Spectral Model, and then sel ecti ng the
Estimate button i n the di al og box that opens. The resul t i s pl aced on the Model
G e
iT
( )
2 The G raphi cal User Interface
2-16
Boar d under the defaul t name s pa_d. The best way to exami ne i t i s to pl ot i t
usi ng the Model View Frequency Response. Thi s vi ew offer s a number of
di fferent opti ons on how to gr aph the cur ves. The frequenci es for whi ch to
esti mate the r esponse can al so be sel ected as an opti on under the Options
menu i n thi s View wi ndow.
The Spectr al Anal ysi s command al so esti mates the spectrum of the addi ti ve
di stur bance v(t) i n the system descr i pti on. Thi s esti mated di sturbance
spectrum i s exami ned under the Model View i tem Noise Spectrum.
The Spectral Anal ysi s esti mate i s stored i n the SI TBs f r e qf unc for mat. I f you
need to further work wi th the esti mates, you can expor t the model to the
MATLAB wor kspace and retr i eve the responses by the command ge t f f . See
f r e qf unc and get f f i n Chapter 4, "Command Refer ence," for mor e
i nfor mati on. (A model i s expor ted by dr aggi ng and dr oppi ng i t over the To
Workspace i con.)
Two opti ons that affect the spectr al anal ysi s esti mate can be set i n the di al og
box. The most i mpor tant choi ce i s a number , M, (the si ze of the l ag wi ndow)
that affects the frequency r esol uti on of the esti mates. Essenti al l y, the
frequency r esol uti on i s about 2 /M radi ans/(sampl i ng i nter val ). The choi ce of
M i s a trade-off between fr equency r esol uti on and vari ance (fl uctuati ons). A
l ar ge val ue of M gi ves good r esol uti on but fl uctuati ng and l ess r el i abl e
esti mates. The defaul t choi ce of M i s good for systems that do not have ver y
shar p resonances and may have to be adjusted for more r esonant systems.
The opti ons al so offer a choi ce between the Bl ackman-Tukey wi ndowi ng
method s pa (whi ch i s defaul t) and a method based on smoothi ng di r ect Fouri er
tr ansfor ms, e t f e. e t f e has an advantage for hi ghl y r esonant systems, i n that
i t i s more effi ci ent for l ar ge val ues of M. I t however has the drawbacks that i t
r equi r es l i nearl y spaced frequency val ues, does not esti mate the di stur bance
spectrum, and does not pr ovi de confi dence i nterval s. The actual methods ar e
descri bed i n more detai l i n Chapter 4, "Command Refer ence," under s pa and
e t f e. To obtai n the spectral anal ysi s model for the curr ent setti ngs of the
opti ons, you can just type the hotkey s i n the ident wi ndow.

2-17
Estimation of Parametric Models
The SI TB suppor ts a wi de range of model str uctures for l i near systems. They
ar e al l accessed by the menu i tem Estimate > Parametric Models... i n the
ident wi ndow. Thi s opens up a di al og box Parametric Models, whi ch
contai ns the basi c di al og for al l par ametri c esti mati on as shown on the
fol l owi ng page
Figure 2-3: The Dialog Box for Estimating Parametric Models
The basi c functi on of thi s box i s as fol l ows:
As you sel ect Estimate, a model i s esti mated from the Wor ki ng Data. The
str uctur e of thi s model i s defi ned by the pop-up menu Structure together wi th
the edi t box Orders. I t i s gi ven a name, whi ch i s wr i tten i n the edi t box Name.
The GUI wi l l al ways suggest a defaul t model name i n the Name box, but you
can change i t to any str i ng befor e sel ecti ng the Estimate button. (I f you i ntend
to expor t the model l ater , avoi d spaces i n the name.)
2 The G raphi cal User Interface
2-18
The i nter pretati on of the model structure i nformati on (typi cal l y i ntegers) i n
the Order box, depends on the sel ected Structure i n the pop-up menu. Thi s
covers, typi cal l y, si x choi ces:
ARX model s
ARMAX model
Output-Er ror (OE) model s
Box-Jenki ns (BJ) model s
State-space model s
Model structure defi ned by I ni ti al Model (User defi ned str uctures)
These ar e deal t wi th one by one shor tl y.
You can fi l l out the Order box your sel f at any ti me, but for assi stance you can
sel ect Order Editor... Thi s wi l l open up another di al og box, dependi ng on the
chosen Structure, i n whi ch the desi r ed model or der and str uctur e i nfor mati on
can be entered i n a si mpl er fashi on.
You can al so enter a name of a MATLAB wor kspace var i abl e i n the order edi t
box. Thi s var i abl e shoul d then have a val ue that i s consi stent wi th the
necessar y orders for the chosen str uctur e.
NOTE: For the state-space structur e and the ARX structure, several order s
and combi nati on of or ders can be enter ed. Then al l corr espondi ng model s wi l l
be compar ed and di spl ayed i n a speci al di al og wi ndow for you to sel ect
sui tabl e ones. Thi s coul d be a useful tool to sel ect good model order s. Thi s
opti on i s descr i bed i n more detai l l ater i n thi s secti on. When i t i s avai l abl e, a
button Order selection i s vi si bl e.
Estimation Method
A common and general method of esti mati ng the par ameters i s the prediction
error approach, wher e si mpl y the parameter s of the model ar e chosen so that
the di fference between the model s (predi cted) output and the measured output
i s mi ni mi zed. Thi s method i s avai l abl e for al l model str uctures. Except for the
ARX case, the esti mati on i nvol ves an i ter ati ve, numer i cal sear ch for the best
fi t.
2-19
To obtai n i nformati on fr om and i nter act wi th thi s search, sel ect Iteration
control... Thi s al so gi ves access to a number of opti ons that govern the sear ch
process. (See auxv ar i n the Chapter 4, "Command Refer ence,".)
For some model structures (the ARX model , and bl ack-box state-space model s)
methods based on cor rel ati on ar e al so avai l abl e: I nstr umental Vari abl e (I V)
and Sub-space (N4SI D) methods. The choi ce between methods i s made i n the
Parametric Models di al og box.
Resulting Models
The esti mated model i s i nserted i nto the GUI s Model Board. You can then
exami ne i ts vari ous properti es and compar e them wi th other model s pr oper ti es
usi ng the Model View pl ots. More about that i n Exami ni ng Model s on page
2-27.
To take a l ook at the model i tsel f, doubl e-cl i ck on the model s i con (mi ddl e/r i ght
mouse button or al t- doubl e-cl i ck). The Data/Model Info wi ndow that then
opens gi ves you i nfor mati on about how the model was esti mated. You can then
al so sel ect Present button, whi ch wi l l l i st the model , and i ts parameter s wi th
esti mated standar d devi ati ons i n the MATLAB command wi ndow.
I f you need to wor k fur ther wi th the model , you can expor t i t by dr aggi ng and
droppi ng i t over the To Workspace i con, and then appl y any MATLAB and
tool box commands to i t. (See, i n parti cul ar, the commands t h2s s , t h2t f ,
t h2par , and t hd2t hc i n Chapter 4, "Command Reference,".)
How to Know Which Structure and Method to Use
There i s no si mpl e way to fi nd out the best model structure; i n fact, for r eal
data, there i s no such thi ng as a best str uctur e. Some r outes to fi nd good and
acceptabl e model ar e descri bed i n A Startup I denti fi cati on Procedure on page
1-12 i n the i ntroductory chapter. I t i s best to be generous at thi s poi nt. I t often
takes just a few seconds to esti mate a model , and by the di fferent val i dati on
tool s descri bed i n the next secti on, you can qui ckl y fi nd out i f the new model i s
any better than the ones you had before. There i s often a si gni fi cant amount of
wor k behi nd the data col l ecti on, and spendi ng a few extra mi nutes tr yi ng out
sever al di ffer ent str uctur es i s usual l y wor th whi l e.
2 The G raphi cal User Interface
2-20
ARX Models
The Structure
The most used model str ucture i s the si mpl e l i near di fference equati on
whi ch rel ates the cur rent output y(t) to a fi ni te number of past outputs y(t-k)
and i nputs u(t-k).
The str uctur e i s thus enti rel y defi ned by the thr ee i ntegers na, nb, and nk. na
i s equal to the number of pol es and nb1 i s the number of zer os, whi l e nk i s the
pur e ti me-del ay (the dead-ti me) i n the system. For a system under
sampl ed-data contr ol , typi cal l y nk i s equal to 1 i f ther e i s no dead-ti me.
For mul ti -i nput systems nb and nk are row vectors, wher e the i -th el ement
gi ves the order/del ay associ ated wi th the i -th i nput.
Entering the Order Parameters
The orders na, nb, and nk can ei ther be di r ectl y enter ed i nto the edi t box
Orders i n the Parametric Models wi ndow, or sel ected usi ng the pop-up
menus i n the Order Editor.
Estimating Many Models Simultaneously
By enter i ng any or al l of the structure par ameters as vector s, usi ng MATLABs
col on notati on, l i ke na=1: 10, etc., you defi ne many di ffer ent str uctur es that
cor respond to al l combi nati ons of or ders. When sel ecti ng Estimate, model s
cor respondi ng to al l of these structures are computed. A speci al pl ot wi ndow
wi l l then open that shows the fi t of these model s to Val i dati on Data. By cl i cki ng
i n thi s pl ot, you can then enter any model s of your choi ce i nto the Model Board.
Multi-input models: For mul ti -i nput model s you can of course enter each of
the i nput orders and del ays as a vector. The number of model s r esul ti ng from
al l combi nati ons of order s and del ays can however be very l arge. As an
al ter nati ve, you may enter one vector (l i ke nb=1: 10) for al l i nputs and one
vector for al l del ays. Then onl y such model s are computed that have the same
order s and del ays from al l i nputs.
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
There are two methods to esti mate the coeffi ci ents a and b i n the ARX model
str uctur e:
Least Squares: Mi ni mi zes the sum of squares of the r i ght-hand si de mi nus
the l eft-hand si de of the expr essi on above, wi th r espect to a and b. Thi s i s
obtai ned by sel ecti ng ARX as the Method.
Instrumental Variables: Deter mi nes a and b so that the er ror between the
ri ght- and l eft- hand si des becomes uncor rel ated wi th certai n l i near
combi nati ons of the i nputs. Thi s i s obtai ned by sel ecti ng I V i n the Method box.
The methods are descri bed i n more detai l i n Chapter 4, "Command Reference,"
under ar x and i v 4.
Multi-Output Models
For a mul ti -output ARX str uctur e wi th NY outputs and NU i nputs, the
di ffer ence equati on above i s sti l l val i d. The onl y change i s that the coeffi ci ents
a are NY by NY matri ces and the coeffi ci ents b ar e NY by NU matri ces.
The or ders [NA NB NK] defi ne the model str uctur e as fol l ows:
NA: an NY by NY matr i x whose i -j entr y i s the or der of the pol ynomi al (i n the
del ay oper ator ) that rel ates the j-th output to the i -th output
NB: an NY by NU matri x whose i -j entr y i s the order of the pol ynomi al that
rel ates the j-th i nput to the i -th output
NK: an NY by NU matr i x whose i -j entr y i s the del ay from the j-th i nput to the
i -th output
The Order Editor di al og box al l ows the choi ces
NA = naones ( NY, NY)
NB = nbones ( NY, NU)
NK = nkones ( NY, NU)
wher e na, nb, and nk ar e chosen by the pop-up menus.
For tai l or-made order choi ces, construct a matr i x [ NA NB NK] i n the MATLAB
command wi ndow and enter the name of thi s matri x i n the Order edi t box i n
the Parametric Models wi ndow.
Note that the possi bi l i ty to esti mate many model s si mul taneousl y i s not
avai l abl e for mul ti -output ARX model s.
See Defi ni ng Model Structures on page 3-29 for mor e i nfor mati on on
mul ti -output ARX model s.
2 The G raphi cal User Interface
2-22
ARMAX, Output-Error and Box-J enkins Models
Ther e ar e sever al el aborati ons of the basi c ARX model , where di ffer ent noi se
model s are i ntr oduced. These i ncl ude wel l known model types, such as
ARMAX, Output-Err or , and Box-Jenki ns.
The General Structure
A gener al i nput-output l i near model for a si ngl e-output system wi th i nput u
and output y can be wri tten:
Here u
i
denotes i nput #i , and A, B
i
, C, D, and F
i
, are pol ynomi al s i n the shi ft
operator (z or q). (Dont get i nti mi dated by thi s: I t i s just a compact way of
wri ti ng di ffer ence equati ons; see bel ow.)
The general str uctur e i s defi ned by gi vi ng the ti me-del ays nk and the or der s of
these pol ynomi al s (i.e., the number of pol es and zer os of the dynami c model
from u to y, as wel l as of the noi se model from e to y).
The Special Cases
Most often the choi ces ar e confi ned to one of the fol l owi ng speci al 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) (Output-Err or)
BJ: y(t) = [B(q)/F(q)] u(t-nk) + [C(q)/D(q)] e(t) (Box-Jenki ns)
The shi ft operator pol ynomi al s are just compact ways of wri ti ng di fference
equati ons. For exampl e the ARMAX model i n l onghand woul d be:
y(t)+a
1
(t-1)+...+a
na
y(t-na)=b
1
u(t-nk)+...b
nb
u(t-nk-nb+1)+e(t)
+c
1
e(t-1)
+...+e
nc
e(t-nc)
Note that A(q) cor responds to pol es that ar e common between the dynami c
model and the noi se model (useful i f noi se enter s the system cl ose to the
i nput). Li kewi se F(q) determi nes the pol es that are uni que for the dynami cs
from i nput #i , and D(q) the pol es that are uni que for the noi se.
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 moti vati on for i ntroduci ng al l these model var i ants i s to pr ovi de for
fl exi bi l i ty i n the noi se descri pti on and to al l ow for common or di fferent pol es
(dynami cs) for the di ffer ent i nputs.
Entering the Model Structure
Use the Structure pop-up menu i n the Parametric Models di al og to choose
between the ARX, ARMAX, Output-Er ror , and Box-Jenki ns structur es. Note
that i f the Worki ng Data set has several outputs, onl y the fi rst choi ce i s
avai l abl e. For ti me seri es (data wi th no i nput si gnal ) onl y AR and ARMA ar e
avai l abl e among these choi ces. These are the ti me seri es counter parts of ARX
and ARMAX.
The or der s of the pol ynomi al s ar e sel ected by the pop-up menus i n the Order
Editor di al og wi ndow, or by di rectl y enteri ng them i n the edi t box Orders i n
the Parametric Models wi ndow. When the order edi tor i s open, the defaul t
orders, enter ed as you change the model str uctur e, are based on pr evi ousl y
used orders.
Estimation Method
The coeffi ci ents of the pol ynomi al s are esti mated usi ng a predi cti on er ror /
Maxi mum Li kel i hood method, by mi ni mi zi ng the si ze of the err or term e i n
the expr essi on above. Several opti ons gover n the mi ni mi zati on pr ocedur e.
These are accessed by acti vati ng Iteration Control i n the Parametric
Models wi ndow, and sel ecti ng Option.
The al gori thms ar e fur ther descri bed i n Chapter 4, "Command Reference,"
under ar max , aux var , bj , oe, and pe m. See al so Parametr i c Model Esti mati on
on page 3-22 and Defi ni ng Model Structures on page 3-29.
NOTE: These model structures are avai l abl e onl y for the scal ar output case.
For mul ti -output model s, the state-space structur es offer the same fl exi bi l i ty.
Al so note that i t i s not possi bl e to esti mate many di ffer ent str uctur es
si mul taneousl y for the i nput-output model s.
2 The G raphi cal User Interface
2-24
State-Space Models
The Model Structure
The basi c state-space model i n i nnovati ons for m can be wri tten
x(t+1) = A x(t) + B u(t) + K e(t)
y(t) = C x(t) + D u(t) + e(t)
The SI TB supports two ki nds of parametr i zati ons of state-space model s:
bl ack-box, free parametr i zati ons, and par ametr i zati ons tai l or-made to the
appl i cati on. The l atter i s di scussed bel ow under the headi ng User Defi ned
Model Str uctur es. Fi r st we wi l l di scuss the bl ack-box case.
Entering Black-Box State-Space Model Structures
The most i mportant str uctur e i ndex i s the model or der, i .e., the di mensi on of
the state vector x.
Use the pop-up menu i n the Order Editor to choose the model order, or enter
i t di rectl y i nto the Orders edi t box i n the Parametric Models wi ndow. Usi ng
the other pop-up menus i n the Order Editor, you can fur ther affect the chosen
model structure:
Fi xi ng K to zero gi ves an Output-Er ror method, i .e., the di ffer ence between
the model s si mul ated output and the measured one i s mi ni mi zed. Formal l y,
thi s corr esponds to an assumpti on that the output di sturbance i s whi te
noi se.
Fi xi ng D to zer o means that there i s a del ay of (at l east) one sampl e from the
i nput to the output. For physi cal systems that are dri ven by pi ece-wi se
constant i nputs, thi s i s a natur al assumpti on.
Fi xi ng the i ni ti al val ue x(0) to zer o means that the i ni ti al state i s not
esti mated. Otherwi se thi s i ni ti al state i s esti mated fr om the data. (Note that
the esti mated val ue of x(0) i s somethi ng that r el ates to the Worki ng Data,
and i s not necessar i l y a good val ue of x(0) for the Val i dati on Data.)
Estimating Many Models Simultaneously
By enter i ng a vector for the model or der , usi ng MATLABs col on notati on, (such
as 1:10 ) al l i ndi cated orders wi l l be computed usi ng a pr el i mi nar y method.
You can then enter model s of di fferent order s i nto the Model Board by cl i cki ng
i n a speci al graph that contai ns i nformati on about the model s.
2-25
Estimation Methods
There are two basi c methods for the esti mati on:
PEM: I s a standar d pr edi cti on er ror/maxi mum l i kel i hood method, based on
i ter ati ve mi ni mi zati on of a cr i ter i on. The i terati ons ar e started up at
parameter val ues that ar e computed from n4s i d. The par ametr i zati on of the
matr i ces A, B, C, D, and K fol l ows a defaul t canoni cal form. The sear ch for
mi ni mum i s control l ed by a number of opti ons. These ar e accessed from the
Option button i n the Iteration Control wi ndow.
N4SI D: I s a subspace-based method that does not use i terati ve search. The
qual i ty of the r esul ti ng esti mates may si gni fi cantl y depend on an auxi l i ar y
order (l i ke a predi cti on hor i zon). Thi s auxi l i ary order can be gi ven wi thi n
parenthesi s after the order i n the edi t box Orders (l i ke 4 (9) ). I f the auxi l i ary
order i s not gi ven, a defaul t val ue i s used.
I f the auxi l i ary or der i s gi ven as a vector (l i ke 4 (5:17) ), model s for al l these
auxi l i ar y or der s are computed and eval uated usi ng the Wor ki ng Data set. The
model that gi ves the best fi t i s chosen. A fi gur e i s shown that i l l ustr ates the fi t
as a functi on of auxi l i ary or der . (The fi t i s a si mul ati on err or fi t i f K=0 i s
chosen, otherwi se a one-step ahead predi cti on err or fi t.)
See n4s i d and pe m i n Chapter 4, "Command Reference," for more i nfor mati on.
User Defined Model Structures
State-Space Structures
The SI TB suppor ts user-defi ned l i near state-space model s of arbi trar y
str uctur e. Usi ng the command ms 2t h, known and unknown par ameters i n the
A, B, C, D, K, and X0 matr i ces can be easi l y defi ned both for di screte- and
conti nuous-ti me model s. The command mf 2t h al l ows you to use a compl etel y
ar bi trary str uctur e, defi ned by an M-fi l e. f i xpar and unf i x par can be used to
mani pul ate str uctur es. See Chapter 4, "Command Refer ence," and Defi ni ng
Model Structures on page 3-29
To use these structures i n conjuncti on wi th the GUI , just defi ne the
appropr i ate structure i n the MATLAB command wi ndow. Then use the
Structure pop-up menu to sel ect By Initial Model and enter the var i abl e
name of the structure i n the edi t box Initial Model i n the Parametric
Models wi ndow and sel ect Estimate.
2 The G raphi cal User Interface
2-26
Any Model Structure
Ar bi tr ary model structur es can be defi ned usi ng sever al commands i n the
System I denti fi cati on Tool box:
pol y 2t h: Creates I nput-output structur es for si ngl e-output model s
ms 2t h: Creates Li near State-space model s wi th arbi trar y, fr ee parameters
mf 2t h: Creates compl etel y arbi trar y parametr i zati ons of l i near systems
ar x2t h: Cr eates mul ti vari abl e ARX structur es
f i xpar /unf i xpar : Modi fi es str uctur es by fi xi ng or unfi xi ng par ameters
I n addi ti on, al l esti mati on commands create model structures i n ter ms of the
r esul ti ng model s.
Enter the name of any model structure i n the box Orders (or Initial model)
i n the wi ndow Parametric Models and then sel ect Estimate. Then the
par ameters of the model str uctur e ar e adjusted to the chosen Worki ng Data
set. The method i s a standard predi cti on err or /maxi mum l i kel i hood approach
that i terati vel y sear ches for the mi ni mum of a cr i ter i on. Opti ons that govern
thi s sear ch ar e accessed by the Option button i n the Iteration Control
wi ndow.
The name of the i ni ti al model must be a vari abl e ei ther i n the wor kspace or i n
the Model Board. I n the l atter case you can just drag and dr op i t over the
Orders/Initial model edi t box.
2-27
4. Examining Models
Havi ng esti mated a model i s just a fi r st step. I t must now be exami ned,
compar ed wi th other model s, and tested wi th new data sets. Thi s i s pri mar i l y
done usi ng the si x Model View functi ons, at the bottom of the mai n ident
wi ndow:
Fr equency response
Tr ansi ent response
Zeros and pol es
Noi se spectrum
Model output
Model r esi dual s
I n addi ti on, you can doubl e-cl i ck on the model s i con to get Text Information
about the model . Fi nal l y, you can export the model to the MATLAB wor kspace
and use any commands for fur ther anal ysi s and model use.
Views and Models
The basi c i dea i s that i f a cer tai n View wi ndow i s open (checked), then all
models i n the Model Summar y Board that ar e sel ected wi l l be r epr esented i n
the wi ndow. The curves i n the View wi ndow can be cl i cked i n and out by
sel ecti ng and desel ecti ng the model s i n an onl i ne fashi on. You sel ect and
desel ect a model by cl i cki ng on i ts i con. An sel ected model i s mar ked wi th a
thi cker l i ne i n i ts i con.
On col or scr eens, the cur ves ar e col or coded al ong wi th the model i cons i n the
Model Board. Befor e pr i nti ng a pl ot i t mi ght be a good i dea to separate the l i ne
styl es (menu i tem under Style). Thi s coul d al so be hel pful on bl ack and whi te
screens.
Note that model s that ar e obtai ned by spectral anal ysi s onl y can be
repr esented as fr equency response and noi se spectra, and that model s
esti mated by cor rel ati on anal ysi s onl y can be represented as tr ansi ent
response.
2 The G raphi cal User Interface
2-28
The Plot Windows
The si x vi ews al l gi ve si mi l ar pl ot wi ndows, wi th several common features.
They have a common menu bar , whi ch covers some basi c functi ons.
Fi r st of al l , note that ther e i s a zoom functi on i n the pl ot wi ndow. By dr aggi ng
wi th the l eft mouse button down, you can draw r ectangl es, whi ch wi l l be
enl arged when the mouse button i s r el eased. By doubl e-cl i cki ng, the ori gi nal
axi s scal es ar e restor ed. For pl ots wi th two axes, the x-axes scal es are l ocked to
each other. A si ngl e cl i ck on the l eft mouse button zooms i n by a factor of two,
whi l e the mi ddl e button zooms out. The zoom functi on can be deacti vated i f
desi r ed. Just sel ect the menu i tem Zoom under Style.
Second, by poi nti ng to any cur ve i n the pl ot, and pressi ng the r i ght mouse
button, the curve wi l l be i denti fi ed wi th model name and present coor di nates.
The common menu bar cover s the fol l owi ng functi ons:
File
Fi l e al l ows you to copy the curr ent fi gure to another, standar d MATLAB fi gur e
wi ndow. Thi s mi ght be useful , e.g., when you i ntend to pri nt a customi zed pl ot.
Other File i tems cover pr i nti ng the curr ent pl ot and cl osi ng the pl ot wi ndow.
Options
Opti ons fi rst of al l cover s acti ons for setti ng the axes scal i ng. Thi s menu i tem
al so gi ves a number of choi ces that are speci fi c for the pl ot wi ndow i n questi on,
l i ke a choi ce between step response or i mpul se response i n the Transient
response wi ndow.
A most i mportant opti on i s the possi bi l i ty to show confi dence i nter val s. Each
model pr oper ty has some uncer tai nty. Thi s can al so be esti mated fr om data. By
checki ng Show confidence intervals, a confi dence regi on ar ound the
nomi nal cur ve (model pr oper ty) wi l l be mar ked (by dash-dotted l i nes). The l evel
of confi dence can al so be set under thi s menu i tem.
NOTE: Confi dence i nter val s ar e supported for most model s and properti es,
except model s esti mated usi ng n4s i d and et f e, and the k-step ahead
pr edi cti on-pr oper ty.
2-29
Style
The styl e menu gi ves access to var i ous ways of affecti ng the pl ot. You can add
gr i dl i nes, tur n the zoom on and off, and change the l i nestyl es. The menu al so
cover s a number of other opti ons, l i ke choi ce of uni ts and scal e for the axi s.
Channel
For mul ti vari ate systems, you can choose whi ch i nput-output channel to
exami ne. The cur rent choi ce i s mar ked i n the fi gure ti tl e.
Help
The Help menu has a number of i tems, whi ch expl ai n the pl ot and i ts opti ons.
Frequency Response and Disturbance Spectra
Al l l i near model s that are esti mated can be wr i tten i n the for m
y(t)=G(z)u(t)+v(t)
where G(z) i s the (di scr ete-ti me) tr ansfer functi on of the system and v(t) i s an
addi ti ve di sturbance. The fr equency response or fr equency functi on of the
system i s the compl ex-val ued functi on G(e
iT
) vi ewed as a functi on of angul ar
frequency .
Thi s functi on i s often graphed as a Bode di agr am, i .e., the l ogari thm of the
ampl i tude (the absol ute val ue) G(e
iT
) as wel l as the phase ar g (the ar gument)
G(e
iT
) ar e pl otted agai nst the l ogari thm of fr equency i n two separate pl ots.
These pl ots ar e obtai ned by checki ng the Model View Frequency Response
i n the mai n ident wi ndow.
The esti mated spectr um of the di stur bance v i s pl otted as a power spectr um by
choosi ng the Model View Noise Spectrum.
I f the data i s a ti me ser i es y (wi th no i nput u), then the spectr um of y i s pl otted
under Noise Spectrum, and no fr equency functi ons are gi ven.
Transient Response
Good and si mpl e i nsi ght i nto a model s dynami c properti es i s obtai ned by
l ooki ng at i ts step response or i mpul se r esponse. Thi s i s the output of the model
when the i nput i s a step or an i mpul se. These r esponses ar e pl otted when the
Model View Transient Response i s checked.
2 The G raphi cal User Interface
2-30
I t i s qui te i nfor mati ve to compar e the tr ansi ent response of a par ametr i c
model , wi th the one that was esti mated usi ng cor rel ati on anal ysi s. I f ther e i s
good agr eement between the two, you can be qui te confi dent that some
essenti al l y corr ect featur es have been pi cked up. I t i s useful to check the
confi dence i nterval s around the r esponses to see what good agr eement coul d
mean quanti tati vel y.
Many model s pr ovi de a descri pti on of the addi ti ve di sturbance v(t):
v(t)=H(z)e(t)
Here H(z) i s a transfer functi on that descri bes how the di stur bance v(t) can be
thought of as gener ated by sendi ng whi te noi se e(t) thr ough i t. To di spl ay the
pr oper ti es of H, you can choose channel s (i n the Channel menu) that have
noi se components as i nputs.
Poles and Zeros
The pol es of a system are the roots of the denomi nator of the tr ansfer functi on
G(z), whi l e the zer os ar e the r oots of the numerator . I n parti cul ar the pol es
have a di r ect i nfl uence on the dynami c properti es of the system.
The pol es and zer os of G (and H ) ar e pl otted by choosi ng the Model View
Poles and Zeros.
I t i s useful to turn on the confi dence i nter val s i n thi s case. They wi l l cl earl y
r eveal whi ch pol es and zer os coul d cancel (thei r confi dence r egi ons over l ap).
That i s an i ndi cati on that a l ower or der dynami c model coul d be used.
For mul ti var i abl e systems i t i s the pol es and zeros of the i ndi vi dual i nput/
output channel s that ar e di spl ayed. To obtai n the so cal l ed transmi ssi on zer os,
you wi l l have to export the model , extr act a state-space descri pti on by t h2s s ,
and then appl y the command t z e r o fr om the Control System Tool box.
Compare Measured and Model Output
A very good way of obtai ni ng i nsi ght i nto the qual i ty of a model i s to si mul ate
i t wi th the i nput fr om a fr esh data set, and compar e the si mul ated output wi th
the measured one. Thi s gi ves a good feel for whi ch pr oper ti es of the system
have been pi cked up by the model , and whi ch havent.
Thi s test i s obtai ned by checki ng the Model View Model Output. Then the
data set curr entl y i n the Validation Data box wi l l be used for the compar i son.
2-31
The fi t wi l l al so be di spl ayed. Thi s i s computed as the root of the mean square
val ue of the di ffer ence between measured and si mul ated output.
I f the model i s unstabl e, or has i ntegrati on or very sl ow ti me constants, the
l evel s of the si mul ated and the measured output may dr i ft apart, even for a
model that i s qui te good (at l east for control pur poses). I t i s then a good i dea to
eval uate the model s predi cted output r ather than the si mul ated one. Wi th a
prediction horizon of k, the k-step ahead pr edi cted output i s then obtai ned as
fol l ows:
The pr edi cted val ue y(t) i s computed from al l avai l abl e i nputs (used
accordi ng to the model ) and al l avai l abl e outputs up to ti me t-k, .
The si mul ati on case, wher e no past outputs at al l ar e used, thus for mal l y
cor responds to k=. To check i f the model has pi cked up i nter esti ng dynami c
properti es, i t i s wi se to l et the predi cted ti me hori zon (kT, T bei ng the sampl i ng
i nter val ) be l arger than the i mpor tant ti me constants.
Note her e that di fferent model s use the i nfor mati on i n past output data i n thei r
predi ctors i n di ffer ent ways. Thi s depends on the noi se model . For exampl e, so
cal l ed Output-Err or model s (obtai ned by fi xi ng K to zero for state-space model s
and setti ng na=nc =nd=0 for i nput output model s, see the previ ous secti on) do
not use past outputs at al l . The si mul ated and the predi cted outputs, for any
val ue of k, thus coi nci de.
Residual Analysis
I n a model
the noi se source e(t) r epr esents that par t of the output that the model coul d not
repr oduce. I t gi ves the l eft-over s or , i n Lati n, the residuals. For a good model ,
the resi dual s shoul d be i ndependent of the i nput. Other wi se, there woul d be
more i n the output that ori gi nates fr om the i nput and that the model has not
pi cked up.
To test thi s i ndependence, the cr oss-cor rel ati on functi on between i nput and
resi dual s i s computed by checki ng the Model View Model Residuals. I t i s
wi se to al so di spl ay the confi dence regi on for thi s functi on. For an i deal model
the cor rel ati on functi on shoul d l i e enti rel y between the confi dence l i nes for
posi ti ve l ags. I f, for exampl e, there i s a peak outsi de the confi dence regi on for
l ag k, thi s means that ther e i s somethi ng i n the output y(t) that ori gi nates from
u(t-k) and that has not been pr oper l y descr i bed by the model . The test i s carr i ed
u s ( ) s t ( )
y s ( ) s t k ( )
y t ( ) G z ( )u t ( ) H z ( )e t ( ) + =
2 The G raphi cal User Interface
2-32
out usi ng the Val i dati on Data. I f these wer e not used to esti mate the model , the
test i s qui te tough. See al so Model Structure Sel ecti on and Val i dati on on page
3-49.
For a model al so to gi ve a corr ect descr i pti on of the noi se pr oper ti es (i .e., the
tr ansfer functi on H), the resi dual s shoul d be mutual l y i ndependent. Thi s test
i s al so carr i ed out by the vi ew Model Residuals, by di spl ayi ng the
auto-corr el ati on functi on of the resi dual s (excl udi ng l ag zero, for whi ch thi s
functi on by defi ni ti on i s one). For an i deal model , the corr el ati on functi on
shoul d be enti rel y i nsi de the confi dence r egi on.
Text Information
By doubl e-cl i cki ng (mi ddl e/r i ght mouse button or al t-doubl e-cl i ck) on the model
i con, a Data/model Info di al og box opens, whi ch contai ns some basi c
i nfor mati on about the model . I t al so gi ves a di ar y of how the model was cr eated,
al ong wi th the notes that ori gi nal l y wer e associ ated wi th the esti mati on data
set. At thi s poi nt you can do a number of thi ngs:
Present
Sel ecti ng the Present button di spl ays detai l s of the model i n the MATLAB
command wi ndow. The model s parameter s al ong wi th esti mated standard
devi ati ons ar e di spl ayed, as wel l as some other notes.
Modify
You can si mpl y type i n any text you want anywhere i n the Diary and Notes
edi tabl e text fi el d of the di al og box. You can al so change the name of the model
just by edi ti ng the text fi el d wi th the model name. The col or, whi ch the model
i s associ ated wi th i n al l pl ots, can al so be edi ted. Enter RGB-val ues or a col or
name (l i ke 'y' ) i n the corr espondi ng box.
Further Analysis in the MATLAB Workspace
Any model and data object can be expor ted to the MATLAB wor kspace by
dr aggi ng and droppi ng i ts i con over the To Workspace box i n the ident
wi ndow.
2-33
Once you have expor ted the model to the wor kspace, there are l ots of
commands by whi ch you can further transform i t, exami ne i t, and convert i t to
other formats for use i n other tool boxes. Some exampl es of such commands are
Al so, i f you need to pr epare speci al i zed pl ots that ar e not covered by the Views,
al l the SI TB commands for computi ng and extracti ng si mul ati ons, frequency
functi ons, zeros and pol es, etc., are avai l abl e. See Chapter 3, "Tutori al ," and
Chapter 4, "Command Reference,".
t hd2t hc Transfor m to conti nuous ti me.
t h2s s Convert to state-space r epresentati on.
t h2t f Convert to transfer functi on for m.
t h2pol y Convert to pol ynomi al i nput/output for m.
2 The G raphi cal User Interface
2-34
5. Some Further GUI Topics
Thi s secti on di scusses a number of di ffer ent topi cs.
Mouse Buttons and Hotkeys
The GUI uses three mouse buttons. I f you have fewer buttons on your mouse,
the acti ons associ ated wi th the mi ddl e and r i ght mouse buttons are obtai ned
by shi ft-cl i ck, al t-cl i ck or control -cl i ck, dependi ng on the computer .
The Main ident Window
I n the mai n ident wi ndow the mouse buttons are used to dr ag and drop, to
sel ect/desel ect model s and data sets, and to doubl e-cl i ck to get text i nformati on
about the object. You can use the l eft mouse button for al l of thi s. A cer tai n
speed-up i s obtai ned i f you use the l eft button for draggi ng and droppi ng, the
r i ght one for sel ecti ng model s and data sets, and the mi ddl e one for
doubl e-cl i cki ng. On a sl ow machi ne a doubl e-cl i ck from the l eft button mi ght
not be recogni zed.
The ident wi ndow al so has a number of hotkeys. By pr essi ng a keyboard l etter
when i t i s the curr ent wi ndow, some functi ons can be qui ckl y acti vated. These
ar e
s : Computes Spectral Analysis Model usi ng the cur rent opti ons setti ngs.
(These can be changed i n the di al og wi ndow that opens when you choose
Spectral Model i n the Estimate pop-up menu.)
c: Computes Correlation Analysis Model usi ng the cur rent opti ons
setti ngs. (These can be changed i n the di al og wi ndow that opens when you
choose Correlation Model i n the Estimate pop-up menu.)
q: Computes the model s associ ated wi th the Quickstart.
d: Opens a di al og wi ndow for i mporti ng Data that ar e i n the SI TB data
for mat.
Plot Windows
I n the vari ous pl ot wi ndows the acti on of the mouse buttons depends on
whether the zoom i s acti vated or not:
Zoom Active: Then the l eft and mi ddl e mouse buttons are associ ated wi th the
zoom functi ons as i n the standar d MATLAB zoom. Left button zooms i n and the
mi ddl e one zooms out. I n addi ti on, you can dr aw rectangl es wi th the l eft
2-35
button, to defi ne the area to be zoomed. Doubl e-cl i cki ng r estor es the or i gi nal
pl ot. The ri ght mouse button i s associ ated wi th speci al GUI acti ons that depend
on the wi ndow. I n the View pl ots, the r i ght mouse button i s used to i denti fy
the curves. Poi nt and cl i ck on a curve, and a box wi l l di spl ay the name of the
model /data set that the curve i s associ ated wi th, and al so the curr ent
coor di nate val ues for the cur ve. I n the Model Selection pl ots the r i ght mouse
button i s used to i nspect and sel ect the var i ous model s. I n the Prefilter and
Data Range pl ots, r ectangl es ar e dr awn wi th thi s mouse button down, to
defi ne the sel ected range.
Zoom not active: The speci al GUI functi ons just menti oned ar e obtai ned by
any mouse button.
The zoom i s acti vated and deacti vated under the menu i tem Style. The defaul t
setti ng di ffer s between the pl ots. Dont acti vate the zoom from the command
l i ne! That wi l l destroy the speci al GUI functi ons. (I f you happen to do so
anyway, qui t the wi ndow and open i t agai n.)
Troubleshooting in Plots
The functi on Auto-range, whi ch i s found under the menu i tem Options, sets
automati c scal es to the pl ots. I t i s al so a good functi on to i nvoke when you thi nk
that you have l ost control over the cur ves i n the pl ot. (Thi s may happen, for
exampl e, i f you have zoom i n a porti on of a pl ot and then change the data of the
pl ot).
I f the vi ew pl ots dont respond the way you expect them to, you can al ways
qui t the wi ndow and open i t agai n. By qui t her e we mean usi ng the
under l yi ng wi ndow systems own qui tti ng mechani sm, whi ch i s cal l ed di ffer ent
thi ngs i n the di ffer ent pl atforms. Thi s acti on wi l l not be acknowl edged by the
cor respondi ng check box i n the ident wi ndow, so you wi l l have to fi rst uncheck,
and then check i t. The nor mal way to cl ose a wi ndow i s to use the Close
functi on under the menu i tem File, or to uncheck the cor respondi ng check box.
Layout Questions and idprefs.mat
The GUI comes wi th a number of preset defaul ts. These i ncl ude the wi ndow
si zes and posi ti ons, the col ors of the di fferent model s, and the defaul t opti ons
i n the di fferent View wi ndows.
The wi ndow si zes and posi ti ons, as wel l as the opti ons i n the pl ot wi ndows, can
of course be changed dur i ng the sessi on i n the standar d way. I f you want the
2 The G raphi cal User Interface
2-36
GUI to star t wi th your curr ent wi ndow l ayout and curr ent pl ot opti ons, sel ect
menu i tem
Opt i ons > Save pr e f er ence s
i n the mai n ident wi ndow. Thi s saves the i nformati on i n a fi l e i dpr e f s . mat .
Thi s fi l e al so stor es i nformati on about the four most recent sessi ons wi th
ident. Thi s al l ows the sessi on File menu to be cor rectl y i ni ti al i zed. The sessi on
i nfor mati on i s automati cal l y stor ed upon exi t. The l ayout and pr efer ence
i nfor mati on i s onl y saved when the i ndi cated opti on i s sel ected.
The fi l e i dpr ef s . mat i s created the fi r st ti me you open the GUI . I t i s by defaul t
stor ed i n the same di r ector y as your s t ar t up. m fi l e. I f thi s defaul t does not
wor k, a warni ng i s i ssued. Thi s can be i gnored, but then sessi on and pr efer ence
i nfor mati on cannot be stor ed.
To change or sel ect a di rector y for i dpr ef s . mat , use the command mi dpr e f s .
See Chapter 4, "Command Refer ence," for detai l s.
To change model col or s and defaul t opti ons to your own customi zed choi ce,
make a copy of the M-fi l e i dl ay out . m to your own di rectory (whi ch shoul d be
before the basi c i de nt di rectory i n the MATLABPATH), and edi t i t accor di ng to i ts
i nstr ucti ons.
Customized Plots
I f you need to pr epare hardcopi es of your pl ots wi th speci al i zed texts, ti tl es and
so on, make a copy of the fi gur e fi r st, usi ng Copy Figure under the File menu
i tem. Thi s pr oduces a copy of the cur rent fi gure i n a standard MATLAB fi gur e
format.
For pl ots that are not cover ed by the View wi ndows, (l i ke, e.g., Nyqui st pl ots),
you have to export the model to the MATLAB wor kspace and constr uct the pl ots
there.
Import from and Export to Workspace
As you expor t a model or a data set to the MATLAB workspace by dr oppi ng i ts
i con over the To Wor kspace i con, i t wi l l become a wor kspace vari abl e wi th the
same name as i n ident, say mymodel . At the same ti me another workspace
vari abl e wi l l be cr eated wi th the name mymode l _i nf o. Thi s contai ns al l di ary
and note i nfor mati on. Thi s wi l l be qui te useful i f you want to mani pul ate the
2-37
model usi ng MATLAB commands and then i mpor t i t back i nto i dent. The use i s
i l l ustr ated by the fol l owi ng exampl e:
Expor t model wi th name mymode l to workspace. Execute the fol l owi ng at the
MATLAB command l i ne:
mymodel c=t hd2t hc ( mymode l ) ;
% c onve r t i ng t he model t o c ont i nuous t i me
mymodel c_i nf o=s t r 2mat ( mymodel _i nf o, . . .
' my mode l c =t hd2t hc( my mode l ) ' ) ;
% addi ng t he i nf o of how t he ne w var i abl e was cr e at ed
Now sel ect pop-up menu Model>Import, enter the vari abl e name mymode l c ,
and sel ect Import.
Thi s wi l l enter the conti nuous-ti me model i nto ident al ong wi th the rel evant
i nfor mati on.
What Cannot be Done Using the GUI
The GUI covers pr i mari l y everythi ng you woul d l i ke to do to exami ne data,
esti mate model s and eval uate and compare model s. I t does not cover
Generati on (si mul ati on) of data sets
Model creati on (other than by esti mati on)
Model mani pul ati on and conversi ons
Recur si ve (on-l i ne) esti mati on al gor i thms
Check Chapter 3, "Tutor i al ," as wel l as the headi ngs Simulation and
Prediction, Model Structure Creation, Manipulating Model
Structures, Model Conversions, and Recursive Parameter Estimation
i n the begi nni ng of Chapter 4, "Command Reference," to see what M-fi l es ar e
avai l abl e i n the tool box for these functi ons.
Note that at any poi nt you can expor t a data set or a model to the MATLAB
wor kspace (by dr aggi ng and dr oppi ng i ts i con on the To Workspace i con).
There you can modi fy and mani pul ate i t any way you want and then i mpor t i t
back i nto ident. You can, for exampl e, construct a conti nuous-ti me model fr om
an esti mated di scr ete-ti me one (usi ng t hd2t hc) and then use the model vi ews
to compare the two.
2 The G raphi cal User Interface
2-38

3
Tutori al
The Toolbox Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
An Introductory Example to Command Mode . . . . . . . . . . . 3-5
The System Identification Problem . . . . . . . . . . . . . . . . . . . . 3-8
Nonparametric Model Estimation . . . . . . . . . . . . . . . . . . . . . 3-19
Parametric Model Estimation . . . . . . . . . . . . . . . . . . . . . . . . 3-22
Defining Model Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-29
Examining Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-40
Model Structure Selection and Validation . . . . . . . . . . . . . 3-49
Dealing with Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-58
Recursive Parameter Estimation . . . . . . . . . . . . . . . . . . . . . 3-61
Some Special Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-68
3 Tutori al
3-2
Thi s chapter has two pur poses. I t descr i bes the commands of the System
I denti fi cati on Tool box, thei r syntax and use. I f you use the gr aphi cal user
i nterface (GUI ), you wi l l not have to bother about these aspects. The chapter
al so descri bes the underl yi ng methods and al gori thms used. The commands
that are not reached fr om the GUI , i .e., the r ecur si ve al gor i thms and more
advanced model structure defi ni ti ons, ar e al so tr eated her e.
3-3
1. The Toolbox Commands
I t may be useful to r ecogni ze several layers of the System I denti fi cati on
Tool box. I ni ti al l y concentrate on the fi rst l ayer of basi c tool s, whi ch contai ns
the commands from the System I denti fi cati on Tool box that any user must
master . You can proceed to the next l evel s whenever an i nterest or the need
from the appl i cati ons warr ants i t. The l ayers ar e descri bed i n the fol l owi ng
paragraphs:
Layer 1: Basic Tools. The fi rst l ayer contai ns the basi c tool s for cor rel ati on and
spectral anal ysi s, and the esti mati on of so-cal l ed ARX model s usi ng the
l east-squar es method. I t al so contai ns the basi c tool s for exami ni ng the
obtai ned model s. The commands ar e:
ar , ar x , bodepl ot , c ompar e, c r a, dt r end, f f pl ot
i ds i m, pr es e nt , r e s i d, s pa, t h2ar x, t h2f f , t h2z p, z ppl ot
The corr espondi ng backgr ound i s gi ven i n the fol l owi ng secti ons: 3,4,5,6,7 and
8 of thi s chapter.
Layer 2: Model Structure Selection. The second l ayer of the tool box contai ns
some useful techni ques to sel ect orders and del ays, and to esti mate more
gener al i nput-output model structur es. The commands ar e:
ar max , ar xs t r uc, bj , e t f e , i df i l t , i v4, n4s i d
oe, pol y2t h, s el s t r uc, t h2pol y
Note that the commands ar x and i v 4 al so appl y to mul ti -i nput, mul ti -output
systems. The corr espondi ng background i s gi ven i n the secti ons 3, 5, 6 ,8 and 9
of thi s chapter.
Layer 3: More Methods To Examine Models and Multi-Input Systems .
Thi s thi rd l ayer contai ns tr ansfor mati ons between conti nuous and di scr ete
ti me, and functi ons for esti mati ng compl etel y general mul ti -i nput model
str uctur es. The commands are:
pe, pem, pr e di ct , t h2s s , t h2t f , t hc 2t hd, t hd2t hc
The corr espondi ng backgr ound i s gi ven i n secti on 7 of thi s chapter .
3 Tutori al
3-4
Layer 4: Recursive Identification. Recursi ve (adapti ve, onl i ne) methods of
par ameter esti mati on are cover ed by the commands:
r ar max, r ar x , r bj , r oe, r pe m, r pl r
The cor respondi ng background i s gi ven Recursi ve Parameter Esti mati on on
page 3-61.
Layer 5: State-Space Modeling. To bui l d model s i n state-space form (both
conti nuous and di scr ete ti me), and to handl e mor e advanced mul ti -output
structures, there are the commands:
c ans t ar t , f i xpar , mf 2t h, mods t r uc, ms 2t h, unf i x par
The cor respondi ng theor y i s covered i n secti ons 3, 5, 6, and 8 of thi s chapter.
(See the begi nni ng of the Chapter 4, "Command Refer ence," for a compl ete l i st
of avai l abl e functi ons.)
3-5
2. An Introductory Example to Command Mode
A demonstr ati on M-fi l e cal l ed i dde mo. m provi des sever al exampl es of what
mi ght be typi cal sessi ons wi th the System I denti fi cati on Tool box. To start the
demo, execute i ddemo from i nsi de MATLAB.
Befor e gi vi ng a for mal treatment of the capabi l i ti es and possi bi l i ti es of the
tool box, thi s exampl e i s desi gned to get you usi ng the software qui ckl y. Thi s
exampl e i s essenti al l y the same as demo #2 i n i ddemo. You may want to i nvoke
MATLAB at thi s ti me, execute i ddemo1, and fol l ow al ong.
Data have been col l ected from a l aborator y scal e pr ocess. (Feedbacks Pr ocess
Trai ner PT326; see page 440 i n Ljung, 1987 and Readi ng More About System
I denti fi cati on on page 1-18 for references.) The process operates much l i ke a
common hand-hel d hai r dr yer. Ai r i s bl own through a tube after bei ng heated
at the i nl et to the tube. The i nput to the process i s the power appl i ed to a mesh
of r esi stor wi r es that consti tutes the heati ng devi ce. The output of the process
i s the ai r temper atur e at the outl et measur ed i n vol ts by a thermocoupl e
sensor.
One thousand i nput-output data poi nts wer e col l ected from the pr ocess as the
i nput was changed i n a r andom fashi on between two l evel s. The sampl i ng
i nter val i s 80 ms. The data wer e l oaded i nto MATLAB i n ASCI I for m and are
now stor ed as the vectors y 2 (output) and u2 (i nput) i n the fi l e dr y er 2. mat .
Fi rst l oad the data:
l oad dr ye r 2
Thi s exampl e sel ects the fi r st 300 data poi nts for bui l di ng a model . For
conveni ence, the i nput-output vector s are merged i nto a matr i x:
z 2 = [ y 2( 1: 300) u2( 1: 300) ] ;
Take a l ook at the data,
i dpl ot ( z 2)
The tool box makes frequent use of defaul t ar guments. Defaul t val ues are used
when trai l i ng ar guments ar e omi tted. I n the case above, by defaul t, al l data
poi nts ar e graphed and the sampl i ng i nterval i s one ti me uni t.
3 Tutori al
3-6
You can sel ect the val ues between sampl e number s 200 and 300 for a cl ose-up,
and at the same ti me obtai n corr ect ti me scal es, wi th
i dpl ot ( z 2, 200: 300, 0. 08)
Remove the constant l evel s and make the data zero mean wi th
z 2 = dt r end( z 2) ;
Now, fi t to the data a model of the form:
where T i s the sampl i ng i nter val (here 0.08 seconds). Thi s model , known as an
ARX model , tri es to expl ai n or compute the val ue of the output at ti me t, gi ven
pr evi ous val ues of y and u. Later on, especi al l y i n Secti on 8, are di scussi ons of
how to deci de upon sui tabl e model orders (structures).
The best val ues of the coeffi ci ents and can be computed wi th
t h = ar x ( z 2, [ 2 2 3] ) ;
The numbers i n the second argument tel l ar x to fi nd a model (2.1) wi th two
a-parameter s, two b-par ameters, and three del ays. The resul t i s stored i n the
matri x t h i n a somewhat coded form. To speci fy the actual sampl i ng i nterval ,
enter
t h = s e t t ( t h, 0. 08) ;
Ther e ar e sever al ways to di spl ay and i l l ustrate the computed model . Wi th
pr e s e nt ( t h)
the coeffi ci ent val ues of (2.1) and thei r esti mated standar d devi ati ons are
pr esented on the scr een.
Next, you mi ght ask how to eval uate how wel l the model fi ts the data. A si mpl e
test i s to run a si mul ati on wher eby real i nput data i s fed i nto the model , and
compare the si mul ated output wi th the actual measur ed output. For thi s, sel ect
a porti on of the data that was not used to bui l d the model , for exampl e, fr om
sampl e 700 to 900:
u = dt r e nd( u2( 700: 900) ) ;
y = dt r e nd( y 2( 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
y s i m = i ds i m( u, t h) ;
pl ot ( [ y ( 100: 200) y s i m( 100: 200) ] )
Note that the functi on c ompar e does thi s sequence of commands mor e
effi ci entl y.
You see that the model i s qui te capabl e of descri bi ng the system, even for data
that were not used i n cal cul ati ng the fi t.
To compute and graph the pol es and zeros of the model , use
z pt h = t h2z p( t h) ;
z ppl ot ( z pt h)
I f you want to know the frequency r esponse, you can compute the fr equency
functi on of the model and present i t as a Bode pl ot by enter i ng
gt h = t h2f f ( t h) ;
bodepl ot ( gt h)
Compare thi s transfer functi on wi th a transfer functi on obtai ned fr om a
nonparametr i c, spectral anal ysi s method. Such an esti mate i s obtai ned di rectl y
from the data
gs = s pa( z 2) ;
gs = s e t t ( gs , 0. 08) ;
The sampl i ng i nter val , 0.08, i s set by the second command i n or der to obtai n
cor rect fr equency scal es. The functi on s pa al so al l ows you to sel ect wi ndow
si zes, fr equency r anges, etc. Al l these have her e been gi ven defaul t val ues.
You can compar e the esti mate of the transfer functi on obtai ned by spectr al
anal ysi s and the one obtai ned fr om the model (2.1) wi th
bodepl ot ( [ gs gt h] )
The agr eement i s qui te good.
Fi nal l y, pl ot the step response of the model . The model comes wi th an esti mate
of i ts own uncer tai nty. Ten di ffer ent step r esponses ar e computed and gr aphed.
They cor respond to possi bl e model s, dr awn from the di str i buti on of the tr ue
system (accor di ng to our model ):
s t e p = ones ( 30, 1) ;
i ds i ms d( s t e p, t h)
3 Tutori al
3-8
3. The System Identification Problem
Thi s secti on di scusses di ffer ent basi c ways to descr i be l i near dynami c systems
and al so the most i mportant methods for esti mati ng such model s.
Impulse Responses, Frequency Functions, and
Spectra
The basi c i nput-output confi gur ati on i s depi cted i n the fi gure above. Assumi ng
uni t sampl i ng i nter val , ther e i s an i nput si gnal
u(t); t=1,2,........,N
and an output si gnal
y(t); t=1,2,.......,.N
Assumi ng the si gnal s ar e r el ated by a l i near system, the rel ati onshi p can be
wri tten
where q i s the shi ft oper ator and i s 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 are cal l ed the impulse response of the system. Cl earl y,
i s the output of the system at ti me k i f the i nput i s a si ngl e (i m)pul se at
ti me zero. The functi on i s cal l ed the transfer function of the system. Thi s
functi on eval uated on the uni t ci r cl e gi ves the frequency function
I n (3.1) i s an addi ti onal , unmeasur abl e di sturbance (noi se). I ts properti es
can be expr essed i n terms of i ts (auto) spectrum
whi ch i s defi ned by
where i s the covari ance functi on of :
and E denotes mathemati cal expectati on. Al ternati vel y, the di sturbance
can be descri bed as fi l tered whi te noi se:
where i s whi te noi se wi th vari ance and
Equati ons (3.1) and (3.8) together gi ve a time domain description of the system:
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 Tutori al
3-10
whi l e (3.4) and (3.5) consti tute a frequency domain description:
The i mpul se r esponse (3.3) and the frequency domai n descri pti on (3.11) ar e
cal l ed nonparametric model descriptions si nce they ar e not defi ned i n terms of
a fi ni te number of parameters. The basi c descr i pti on (3.10) al so appl i es to the
mul ti vari abl e case; i .e., to systems wi th several (say nu) i nput si gnal s and
sever al (say ny) output si gnal s. I n that case i s an ny by nu matri x whi l e
and ar e ny by ny matr i ces.
Polynomial Representation of Transfer Functions
Rather than speci fyi ng the functi ons G and H i n (3.10) i n terms of functi ons of
the fr equency var i abl e , you can descr i be them as r ati onal functi ons of
and speci fy the numer ator and denomi nator coeffi ci ents i n some way.
A commonl y used parametr i c model i s the ARX model that cor responds to
where B and A ar e pol ynomi al s i n the del ay operator :
Here, the number s na and nb ar e the or der s of the r especti ve pol ynomi al s. The
number nk i s the number of del ays from i nput to output. The model i s usual l y
wri tten
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 expl i ci tl y
Note that (3.15) -(3.16) appl y al so to the mul ti var i abl e case, wher e and
the coeffi ci ents become ny by ny matr i ces, and the coeffi ci ents
become ny by nu matr i ces.
Another very common, and mor e gener al , model str uctur e i s the ARMAX
str uctur e
Her e, and are as i n (3.13)-(3.14), whi l e
An Output-Error (OE) structure i s obtai ned as
wi th
The so-cal l ed Box-J enkins (BJ) model str ucture i s gi ven by
wi th
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 Tutori al
3-12
Al l these model s are speci al cases of the general parametri c model str uctur e:
The var i ance of the whi te noi se i s assumed to be .
Wi thi n the str uctur e of (3.23), vi rtual l y al l of the usual l i near bl ack-box model
structures ar e obtai ned as speci al cases. The ARX structure i s obvi ousl y
obtai ned for . The ARMAX str uctur e cor responds to
. The ARARX structure (or the gener al i zed l east-squar es model )
i s obtai ned for , whi l e the ARARMAX structur e (or extended
matri x model ) corr esponds to . The Output-Err or model i s obtai ned
wi th , whi l e the Box-Jenki ns model corr esponds to .
(See Secti on 4.2 i n Ljung (1987) for a detai l ed di scussi on.)
The same type of model s can be defi ned for systems wi th an arbi trary number
of i nputs. They have the 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 descri bi ng l i near systems i s to use the state-space form:
Her e the r el ati onshi p between the i nput and the output i s defi ned vi a
the nx-di mensi onal state vector . I n transfer functi on for m (3.24)
cor responds to (3.1) wi th
Her e i s the nx by nx i denti ty matri x. Cl ear l y (3.24) can be vi ewed as one
way of parametri zi ng the tr ansfer functi on: Vi a (3.25) becomes a functi on
of the el ements of the matri ces A, B, C, and D.
To fur ther descri be the character of the noi se ter m i n (3.24) a mor e fl exi bl e
innovations form of the state-space model can be used:
Thi s i s equi val ent to (3.10) wi th gi ven by (3.25) and by
Her e ny i s the di mensi on of and .
I t i s often possi bl e to set up a system descri pti on di r ectl y i n the i nnovati ons
form (3.26). I n other cases, i t mi ght be pr efer abl e to descr i be fi r st the nature of
di sturbances that act on the system. That l eads to a stochasti c state-space
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 Tutori al
3-14
where and ar e stochasti c processes wi th certai n covari ance
pr oper ti es. I n stati onar i ty and from an i nput-output vi ew, (3.28) i s equi val ent
to (3.26) i f the matr i x K i s chosen as the steady-state Kalman gain. How to
compute K from (3.28) i s descr i bed i n the Contr ol System Tool box.
Continuous-Time State-Space Models
I t i s often easi er to descri be a system fr om physi cal model i ng i n terms of a
conti nuous-ti me model . The reason i s that most physi cal l aws are expressed i n
conti nuous ti me as di fferenti al equati ons. Ther efor e, physi cal model i ng
typi cal l y l eads to state-space descr i pti ons l i ke
Here, means the ti me deri vati ve of . I f the i nput i s pi ece-wi se constant over
ti me i nter val s , then the rel ati onshi p between
and can be exactl y expr essed by (3.24) by taki ng
and associ ate y(t) wi th y[t], etc.
I f you star t wi th a conti nuous-ti me i nnovati ons form
the di screte-ti me counter part i s gi ven by (3.26) where sti l l the r el ati onshi ps
(3.30) hol d. The exact connecti on between and K i s somewhat mor e
compl i cated, though. An ad hoc sol uti on i s to use
i n anal ogy wi th G and B. Thi s i s a good approxi mati on for shor t sampl i ng
i nterval s 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
Consi der the descr i pti on (3.1). Suppose that the i nput i s whi te noi se; i .e.,
i ts covari ance functi on i s
Then, the cr oss covar i ance functi on between the i nput and the output i s
where g() i s the i mpul se response of the system. I n thi s case, i t can easi l y be
esti mated as
based on the observed i nput-output data.
I f the i nput i s not whi te, a whi teni ng fi l ter L(q) can be determi ned for i t, so
that the fi l tered sequence
i s approxi matel y whi te. By fi l ter i ng the output sequence thr ough the same
fi l ter and computi ng (3.33) based on the fi l ter ed data, a natural esti mate of the
i mpul se r esponse coeffi ci ents g(k) i s obtai ned. Thi s pr ocedur e i s known as
correlation 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 Tutori al
3-16
Estimating Spectra and Frequency Functions
Thi s secti on descri bes methods that esti mate the frequency functi ons and
spectra (3.11) di r ectl y. The cr oss-covari ance functi on between y(t) and
u(t) was defi ned above. I ts Four i er transform, the cross spectr um, i s
defi ned anal ogousl y to (3.6). Provi ded that the i nput i s i ndependent of ,
the r el ati onshi p (3.1) i mpl i es the fol l owi ng rel ati onshi ps between the spectr a:
By esti mati ng the var i ous spectra i nvol ved, the frequency functi on and the
di stur bance spectrum can be esti mated as fol l ows:
Form esti mates of the covari ance functi ons (as defi ned i n (3.7)) , ,
and , usi ng
and anal og expressi ons for the other s. Then, for m esti mates of the
correspondi ng spectra
and anal ogousl y for and . Here i s the so-cal l ed lag window and
M i s the wi dth of the l ag wi ndow. The esti mates are then formed as
Thi s pr ocedur e i s known as spectral analysis. (See Chapter 6 i n 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
Gi ven a descr i pti on (3.10) and havi ng obser ved the i nput-output data u, y, the
(predi cti on) er ror s i n (3.10) can be computed as:
These er ror s are, for gi ven data y and u, functi ons of G and H. These i n turn
ar e parametri zed by the pol ynomi al s i n (3.15)-(3.23) or by entr i es i n the
state-space matr i ces defi ned i n (3.29)(3.32). The most common par ametri c
i denti fi cati on method i s to deter mi ne esti mates of G and H by mi ni mi zi ng
that i s
Thi s i s cal l ed a prediction error method. For Gaussi an di sturbances i t coi nci des
wi th the maxi mum l i kel i hood method. (See Chapter 7 i n Ljung (1987).)
A somewhat di fferent phi l osophy can be appl i ed to the ARX model (3.15). By
formi ng fi l tered versi ons of the i nput
and by mul ti pl yi ng (3.15) wi th , , 2, , na and ,
, 2, , nb and summi ng over t, the noi se i n (3.15) can be cor rel ated out
and sol ved for the dynami cs. Thi s gi ves the instrumental variable method, and
are cal l ed the i nstr uments. (See Secti on 7.6 i n 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 Tutori al
3-18
Subspace Methods for Estimating State-Space
Models
The state-space matri ces A, B, C, D, and K i n (3.26) can be esti mated di r ectl y,
wi thout fi r st speci fyi ng any parti cul ar parametri zati on by effi ci ent subspace
methods. The i dea behi nd thi s can be expl ai ned as fol l ows: I f the sequence of
state vector s x(t) were known, together wi th y(t) and u(t), eq (3.26b) woul d be a
l i near r egressi on, and C and D coul d be esti mated by the l east squares method.
Then e(t) coul d be determi ned, and treated as a known si gnal i n (3.26a), whi ch
then woul d be another l i near regr essi on model for A, B and K. (One coul d al so
tr eat (3.24) as a l i near r egr essi on for A, B, C, and D wi th y(t) and x(t+1) as
si mul taneous outputs, and fi nd the joi nt process and measur ement noi ses as
the r esi dual s from thi s r egressi on. The Kal man gai n K coul d then be computed
from the Ri ccati equati on.) Thus, once the states are known, the esti mati on of
the state-space matr i ces i s easy.
How to fi nd the states x(t)? Appendi x 4.A of Ljung(1987) shows that al l states
i n r epr esentati ons l i ke (3.26) can be formed as l i near combi nati ons of the
k-step ahead predi cted outputs (k=1,2,...,n). I t i s thus a matter of fi ndi ng these
pr edi ctors, and then sel ecti ng a basi s among them. The subspace methods for m
an effi ci ent and numer i cal l y rel i abl e way of determi ni ng the pr edi ctor s by
pr ojecti ons di r ectl y on the obser ved data sequences. For more detai l s, see the
r efer ences under n4s i d i n Chapter 4, "Command Reference" .
3-19
4. Nonparametric Model Estimation
Thi s and the fol l owi ng secti ons gi ve an i ntr oducti on to the basi c functi ons i n
the System I denti fi cati on Tool box. Not al l of the opti ons avai l abl e when usi ng
the functi ons are descr i bed her e; see the Command Reference chapter and the
onl i ne Hel p faci l i ty.
Data Representation
The observed output and i nput si gnal s, and , ar e r epr esented i n the
System I denti fi cati on Tool box as column vectors y and u. Row k corr esponds to
sampl e number k. For mul ti var i abl e systems, each i nput (output) component
i s repr esented as a col umn vector, so that u becomes an N by nu matr i x (N =
number of sampl ed observati ons, nu = number of i nput si gnal s). The
output-i nput data i s col l ecti vel y represented as a matri x whose fi rst col umn(s)
i s the output and next col umn(s) i s the i nput:
z = [ y u]
The data can be gr aphed by the command i dpl ot :
i dpl ot ( z )
Thi s gi ves pl ots of al l combi nati ons of i nputs and outputs for vi sual i nspecti on.
Some of the functi ons i n the System I denti fi cati on Tool box appl y onl y to si ngl e
output data ( ) and some onl y to si ngl e-i nput-si ngl e-output data
( , ). Chapter 4, "Command Refer ence" gi ves detai l s about thi s.
y t ( ) u t ( )
ny 1 =
ny 1 = nu 1 =
3 Tutori al
3-20
Correlation Analysis
The cor rel ati on anal ysi s procedure descr i bed i n The System I denti fi cati on
Probl em i n Chapter 3 i s i mpl emented i n the functi on c r a:
i r = cr a( z )
Thi s functi on returns the esti mated i mpul se response i n the vector i r . I t al so
opti onal l y pl ots the esti mated covari ance functi ons for y and u, so that the
success of the whi teni ng fi l ter (3.34) can be checked. Fr om the esti mated
i mpul se r esponse i t i s easy to for m the step r esponse:
i r = cr a( z )
s r = cums um( i r )
pl ot ( s r )
Spectral Analysis
The functi on s pa per for ms spectr al anal ysi s accor di ng to the procedure i n
(3.35)(3.37).
[ G, PHI V] = s pa( z )
Here z contai ns the output-i nput data as above. G and PHI V ar e matri ces that
contai n the esti mated fr equency functi on and the esti mated di sturbance
spectrum i n (3.37). They ar e coded i nto a speci al format, the freqfunc
format, whi ch al l ows you to pl ot them usi ng the functi on bode pl ot or f f pl ot :
[ G, PHI V] = s pa( z )
bodepl ot ( G)
bodepl ot ( PHI V)
bodepl ot gi ves l ogar i thmi c ampl i tude and frequency scal es (i n r ad/sec) and
l i near phase scal e, whi l e f f pl ot gi ves l i near frequency scal es (i n Hz). The
detai l s of the f r eqf unc for mat are gi ven i n Chapter 4, "Command Refer ence"
and by typi ng hel p f r e qf unc. To obtai n cor rect fr equency scal es you can
operate wi th the command s et t on G or gi ve the sampl i ng i nterval as an
opti onal ar gument to s pa.
By omi tti ng the ar gument PHI V, onl y the tr ansfer functi on esti mate G i s
computed:
G = s pa( z )
GN
v
3-21
When PHI V i s i ncl uded, the esti mated standar d devi ati ons of G and PHI V are
al so returned by s pa and i ncl uded i n the fr eqfunc for mat.
I f z = y i s a ti me seri es, s pa r etur ns an esti mate of the spectr um of that si gnal :
PHI Y = s pa( y )
f f pl ot ( PHI Y)
I n the computati ons (3.35)-(3.37), s pa uses a Hammi ng wi ndow for wi th
a defaul t l ength M equal to the mi ni mum of 30 and a tenth of the number of
data poi nts. Thi s wi ndow si ze M can be changed to an arbi trar y number by
[ G, PHI V] = s pa( z , M)
The rul e i s that as Mi ncreases, the esti mated frequency functi ons show sharper
detai l s, but are al so mor e affected by r andom di sturbances. A typi cal sequence
of commands that test di ffer ent wi ndow si zes i s
g10 = s pa( z , 10)
g25 = s pa( z , 25)
g50 = s pa( z , 50)
bodepl ot ( [ g10 g25 g50] )
An empi ri cal transfer functi on esti mate i s obtai ned as the rati o of the output
and i nput Fouri er tr ansfor ms wi th
G = e t f e( z )
Thi s can al so be i nterpr eted as the spectr al anal ysi s esti mate for a wi ndow si ze
that i s equal to the data l ength. For a si ngl e si gnal e t f e gi ves the periodogram
as a spectr al esti mate. The functi on al so al l ows some smoothi ng of the cr ude
esti mate; i t can be a good al ter nati ve for si gnal s and systems wi th shar p
resonances. See Chapter 4, "Command Refer ence" for more i nformati on.
W ( )
3 Tutori al
3-22
5. Parametric Model Estimation
The System I denti fi cati on Tool box contai ns sever al functi ons for par ametri c
model esti mati on. They al l share the same command str uctur e
t h = f unct i on( [ y u] , t hs )
I nput var i abl es y and u ar e col umn vectors that contai n the output and i nput
data sequences, whi l e the matri x t hs speci fi es the parti cul ar str ucture of the
model to be esti mated. The resul ti ng esti mated model i s contai ned i n t h. I t i s
coded i nto the theta format. Thi s i s the basi c for mat for repr esenti ng model s i n
the System I denti fi cati on Tool box. I t col l ects i nformati on about the model
structure and the orders, del ays, parameter s, and esti mated covari ances of
esti mated par ameters i nto a matr i x. The detai l s of thi s r epr esentati on are
found i n Chapter 4, "Command Refer ence" or by typi ng he l p t he t a. The t het a
format can be tr ansl ated to other useful model r epr esentati ons. To just di spl ay
the model i nformati on, use the command pr es ent :
t h = f unct i on( z , t hs )
pr e s e nt ( t h)
The fol l owi ng secti ons assume that you have formed an ar ray z that consi sts of
the output y and the i nput u:
z = [ y u]
ARX Models
To esti mate the par ameters and of the ARX model (3.15), use the functi on
ar x :
t h = ar x ( z , [ na nb nk] )
Here na, nb, and nk are the cor respondi ng orders and del ays i n (3.16) that
defi ne the exact model structure. The functi on ar x i mpl ements the
l east-squares esti mati on method, usi ng the MATLAB / oper ator for
over deter mi ned l i near equati ons.
An al ternati ve i s to use the I nstr umental Vari abl e (I V) method descri bed i n
connecti on wi th (3.41). Thi s i s obtai ned wi th
t h = i v 4( z , [ na nb nk] )
a
i
b
i
3-23
whi ch gi ves an automati c (and appr oxi matel y opti mal ) choi ce of the fi l ter s N
and M i n (3.41). (See the pr ocedur e (15.21)-(15.26) i n Ljung (1987).)
Both ar x and i v 4 are appl i cabl e to ar bi tr ary mul ti var i abl e systems. I f you have
ny outputs and nu i nputs, the orders ar e defi ned accordi ngl y: na i s an
ny by ny matri x whose i -j entr y gi ves the order of the pol ynomi al that rel ates
past val ues of to the cur rent val ue of (i .e., past val ues of up to
ar e used when predi cti ng . Si mi l ar l y the i -j entr i es of the
ny by nu matr i ces nu and nk, respecti vel y, gi ve the or der and del ay from i nput
number j when pr edi cti ng output number i. (See Defi ni ng Model Structures
on page 3-29 and Chapter 4, "Command Refer ence" for exact detai l s.)
AR Models
For a si ngl e si gnal the counterpar t of the ARX model i s the AR model :
The ar x command al so covers thi s speci al case
t h = ar x( y, na)
but for scal ar si gnal s mor e opti ons are offered by the command
t h = ar ( y , na)
whi ch has an opti on that al l ows you to choose the al gori thm fr om a gr oup of
sever al popul ar techni ques for computi ng the l east-squar es AR model . Among
these are Bur gs method, a geometri c l atti ce method, the Yul e-Wal ker
approach, and a modi fi ed covar i ance method. (See Chapter 4, "Command
Refer ence" for detai l s.) The counterpar t of the i v 4 command i s
t h = i v ar ( y , na)
whi ch uses an i nstrumental vari abl e techni que to compute the AR par t of a
ti me seri es.
General Polynomial Black-Box Models
Based on the pr edi cti on er ror method (3.40), you can constr uct model s of
basi cal l y any str ucture. For the gener al model (3.23), ther e i s the functi on
t h = pe m( 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 Tutori al
3-24
where nn gi ves al l the orders and del ays
nn = [ na nb nc nd nf nk]
The pe m command covers al l cases of bl ack-box l i near system model s. Mor e
effi ci ent r outi nes are avai l abl e, however, for the common speci al cases
t h = ar max ( z , [ na nb nc nk] )
t h = oe ( z , [ nb nf nk] )
t h = bj ( z , [ nb nc nd nf nk] )
These handl e the model str uctur es (3.17), (3.19) and (3.21), r especti vel y.
Al l the r outi nes al so cover si ngl e-output, mul ti -i nput systems of the type
where nb, nf , and nk ar e r ow vector s of the same l engths as the number of i nput
channel s contai ni ng each of the orders and del ays
nb = [ nb1 . . . nbnu] ;
nf = [ nf 1 . . . nf nu] ;
nk = [ nk1 . . . nknu] ;
These parameter esti mati on r outi nes r equi r e an i terati ve search for the
mi ni mum of the functi on (3.39). Thi s search uses a speci al star t-up procedur e
based on l east squar es and i nstr umental var i abl es (the detai l s ar e gi ven as
equati on (10.75) i n Ljung (1987)). From the i ni ti al esti mate, a Gauss-Newton
mi ni mi zati on pr ocedur e i s carr i ed out unti l the nor m of the Gauss-Newton
di r ecti on i s l ess than a cer tai n tol erance. See Ljung (1987), Secti on 11.2 or
Denni s and Schnabel (1983) for detai l s. See al so the entry on opti onal vari abl es
associ ated wi th the search at the end of thi s secti on.
The routi nes pem, ar max, oe , and bj can al so be star ted at any i ni ti al val ue t hi
speci fi ed i n the theta for mat by repl aci ng nn by t hi . For exampl e
t h = pe m( z , t hi )
Whi l e the sear ch i s typi cal l y i ni ti al i zed usi ng the bui l t-i n star t-up procedure
gi vi ng just or ders and del ays (as descr i bed above), the abi l i ty to force a speci fi c
i ni ti al condi ti on i s useful i n several contexts. Some exampl es ar e menti oned i n
Some Speci al Topi cs 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
I f a last argument t r ac e i s added, as i n
t h = ar max( z , nn, t r ace )
these r outi nes gi ve status reports to the screen dur i ng the mi ni mi zati on,
contai ni ng curr ent and pr evi ous esti mates, the associ ated l oss functi ons, and
the Gauss-Newton update vector and i ts norm. The esti mates are then
repr esented by a col umn vector, l i sti ng the parameter s i n al phabeti cal or der .
The number then fl i cker i ng i n the upper l eft corner shows how many ti mes the
suggested update di recti on has been bi sected duri ng the sear ch. I t i s a heal thy
si gn i f thi s number i s smal l .
These routi nes return the esti mated covar i ance matri x of the esti mated
parameter vector as part of t h. Thi s r efl ects the r el i abi l i ty of the esti mates. The
covari ance matr i x esti mate i s computed under the assumpti on that i t i s
possi bl e to obtai n a tr ue descr i pti on i n the gi ven str uctur e.
State-Space Models
Black-box, discrete-time, parametrizations. Suppose fi rst that ther e i s no
parti cul ar knowl edge about the i nternal str uctur e of the di scr ete-ti me
state-space model (3.16). Any l i near model of a gi ven order i s sought. Then
ther e ar e essenti al l y two di ffer ent ways to esti mate state-space model s, l i ke
(3.26). The si mpl est one i s to use n4s i d:
t h = n4s i d( z , or der ) ;
whi ch creates a model i n state-space form (coded as usual i n the theta format)
i n a r eal i zati on that i s automati cal l y chosen to be reasonabl y wel l condi ti oned.
The basi c i dea behi nd thi s subspace al gori thm was descr i bed i n The System
I denti fi cati on Probl em on page 3-8.
The other al ter nati ve i s to use a predi cti on er ror method, mi ni mi zi ng the
cr i teri on (5.3) bel ow. I ni ti al i zi ng the sear ch at the n4s i d model i s then a good
i dea. Thi s i s obtai ned by
t hi = c ans t ar t ( z , or der , nu)
t h = pe m( z , t hi )
3 Tutori al
3-26
Arbitrarily parameterized models in discrete and continuous time. For
state-space model s of gi ven structure, most of the effor t i nvol ved rel ates to
defi ni ng and mani pul ati ng the structure. Thi s i s di scussed i n Defi ni ng Model
Structures on page 3-29. Once the str uctur e i s defi ned i n the theta for mat as
t hs , you can esti mate i ts par ameters wi th
t h = pe m( z , t hs )
When the systems ar e mul ti -output, the fol l owi ng cr i teri on i s used for the
mi ni mi zati on:
whi ch i s the maxi mum l i kel i hood cr i ter i on for Gaussi an noi se wi th unknown
covari ance matr i x.
The numeri cal mi ni mi zati on of the predi cti on err or cr i teri on (3.39) or (5.3) can
be a di ffi cul t pr obl em for gener al model parametri zati ons. The cri ter i on, as a
functi on of the free par ameter s, can defi ne a compl i cated sur face wi th many
l ocal mi ni ma, narr ow val l eys and so on. Thi s may requi re substanti al
i nteracti on from the user , i n pr ovi di ng r easonabl e i ni ti al par ameter val ues,
and al so by freezi ng certai n par ameter val ues whi l e al l owi ng other s to be fr ee.
Note that pem easi l y al l ows the fr eezi ng of any parameter s to thei r nomi nal
val ues. The functi ons f i x par and unf i xpar ar e al so useful . A procedure that i s
often used for state-space model s i s to al l ow the noi se parameter i n the K
matri x free, onl y when a reasonabl e model of the dynami c part has been
obtai ned. See al so Some Speci al Topi cs on page 3-68.
Optional Variables
The functi ons pe m, ar max , oe, and bj can accept thr ee addi ti onal i nput opti ons
that affect the mi ni mi zati on, as wel l as one extra output argument. For
exampl e,
[ t h, i t e r _i nf o] = bj ( z , nn, max i t e r , t ol , l i m)
The for mat i s the same for the other functi ons. I f these var i abl es ar e not gi ven,
defaul t val ues ar e assi gned to them.
det e t ( )e
T
t ( )
t 1 =
N

min (5.3)
3-27
max i t er : Thi s var i abl e deter mi nes the maxi mum number of i ter ati ons
performed i n the search for the mi ni mum. The defaul t val ue i s 10. Setti ng the
val ue of maxi t e r to zero r esul ts i n the return of the esti mate from the star t-up
procedure.
t ol : The i terati ons ar e conti nued unti l the nor m of the Gauss-Newton update
vector i s l ess than t ol . The defaul t val ue i s 0.01. The i terati ons al so termi nate
when maxi ter i s r eached or when no decrease i n the cri ter i on can be found al ong
the sear ch di r ecti on after i t has been bi sected 10 ti mes. (After the 10 fi r st
bi secti ons, the sear ch di r ecti on i s changed to the gr adi ent one, and 10 new
bi secti ons ar e tr i ed.)
The par ameters associ ated wi th the noi se dynami cs, (C and D), are often mor e
di ffi cul t to esti mate than the dynami cs parameter s, A, B, and F. Major
contri buti ons to the nor m of the update di recti on then come from the entri es
cor respondi ng to the noi se parameter s. The Gauss-Newton vector can be
moni tor ed to see i f i t i s reasonabl e to i ncr ease t ol on thi s gr ound.
l i m: The quadrati c cr i ter i on (3.39) gi ves a consi der abl e rel ati ve wei ght to l arge
predi cti on err or s. You may want to l i mi t thei r i nfl uence, usi ng robust
estimation techniques. I n the esti mati on functi ons ar , bj , max, oe , and pe m, a
predi cti on err or that i s l ar ger than l i m
*
(esti mated standar d devi ati on of e)
carr i es a l i near, r ather than a quadrati c, wei ght.
The defaul t val ue of l i m i s 1. 6. l i m=0 di sabl es the r obust esti mati on and
appl i es a purel y quadrati c cr i ter i on. The standard devi ati on i s esti mated
robustl y as the medi an of the absol ute devi ati ons fr om the medi an, di vi ded by
0.7. (See eq (15.9)-(15.10) i n Ljung (1987).)
Note that the l oss functi on di spl ayed by pr es ent ( t h) i s quadrati c and that the
data-dependent del i mi ter i s computed onl y once, befor e the mi ni mi zati on
starts.
i t e r _i nf o: Thi s a a row vector wi th three entr i es that gi ve i nfor mati on about
the i ter ati on process. The fi rst entry i s the number of used i terati ons. The
second one i s the i mprovement of the fi t over the l ast i ter ati on, and the thi r d
var i abl e i s the nor m of the Gauss-Newton sear ch vector. I f the number of used
i ter ati ons i s l ess than max i t er , at the same ti me as thi s nor m i s l arger then
t ol , i t means that the i terati ons have been aborted because no better fi t coul d
be obtai ned al ong the i ndi cated sear ch di r ecti on.
3 Tutori al
3-28
For the spectr al anal ysi s esti mate, you can compute the frequency functi ons at
ar bi tr ary fr equenci es. I f the fr equenci es are speci fi ed i n a r ow vector w, then
[ G, PHI V] = s pa( z , M, w)
r esul ts i n G and PHI V bei ng computed at these fr equenci es. Thi s computati on i s
somewhat sl ower , however, than usi ng the defaul t fr equenci es.
You can gener ate l ogar i thmi cal l y spaced fr equenci es usi ng the MATLAB
l ogs pac e functi on. For exampl e
w = l ogs pace ( 3, pi , 128)
The opti onal trai l i ng ar guments can be omi tted, i n whi ch case defaul t val ues
ar e used. Enter i ng them as empty matri ces, [ ], al so causes functi ons to rel y
upon defaul ts.
3-29
6. Defining Model Structures
Si nce the System I denti fi cati on Tool box handl es a wi de vari ety of di ffer ent
model structures, i t i s i mpor tant that these can be defi ned i n a fl exi bl e way. I n
the previ ous secti on you saw how model structures that ar e speci al cases of the
gener al model (3.23) can be defi ned by speci fyi ng the orders and del ays i n the
var i ous esti mati on routi nes ar x , i v 4, oe , bj , ar max , and pem. Thi s secti on
descr i bes how model structures and model s can be di rectl y defi ned. For
bl ack-box model s (3.23) thi s may be r equi red, for exampl e, when cr eati ng a
model for si mul ati on. Commands for cr eati ng state-space model str uctur es ar e
di scussed i n thi s secti on.
The general way of r epr esenti ng model s and model str uctur es i n the System
I denti fi cati on Tool box i s the theta format. Thi s secti on i ntroduces the
commands (apart from the parametri c esti mati on functi ons themsel ves) that
cr eate model s i n the theta for mat.
Polynomial Black-Box Models
The general i nput-output form (3.23):
i s defi ned by the fi ve pol ynomi al s A(q), B(q), C(q), D(q), and F(q). These are
repr esented i n the standard MATLAB for mat for pol ynomi al s. Pol ynomi al
coeffi ci ents are stor ed as row vectors or der ed by descendi ng power s. For
exampl e, the pol ynomi al
i s repr esented as
A = [ 1 a1 a2 . . . an]
Del ays i n the system ar e i ndi cated by l eadi ng zeros i n the pol ynomi al . For
exampl e, the 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 Tutori al
3-30
i s r epr esented by the pol ynomi al s
A = [ 1 1. 5 0. 7]
B = [ 0 0 2. 5 0. 9]
The theta format r epresentati on of (6.1) i s now cr eated by the command
t h = pol y2t h( A, B, C, D, F, l am, T)
l am i s here the var i ance of the whi te noi se source and T i s the sampl i ng
i nterval . Trai l i ng ar guments can be omi tted for defaul t val ues. The system
(6.2) can for exampl e be r epr esented by
t h = pol y2t h( [ 1 1. 5 0. 7] , [ 0 0 0. 5 0. 7] )
I n the mul ti -i nput case (5.2) B and F are matri ces, whose row number k
cor responds to the k- th i nput. The command pol y2t h can al so be used to defi ne
ti me-conti nuous systems. See the Command Reference chapter for detai l s.
Multivariable ARX Models
A mul ti var i abl e ARX model i s gi ven by
Here A(q) i s an ny by ny matr i x whose entri es ar e pol ynomi al s i n the del ay
operator q
-1
. You can r epr esent i t as
as wel l as the matr i x
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
where the entri es ar e pol ynomi al s i n the del ay operator :
Thi s pol ynomi al descr i bes how ol d val ues of output number j affect output
number k. Here i s the Kr onecker-del ta; i t equal s 1 when , otherwi se,
i t i s 0. Si mi l arl y i s an ny by nu matri x
or
wi th
The del ay fr om i nput number j to output number k i s . To l i nk wi th the
str uctur e defi ni ti on i n terms of [ na nb nk] i n the ar x and i v 4 commands, note
that na i s a matri x whose kj-el ement i s , whi l e the kj-el ements of nb and nk
ar e and r especti vel y.
The theta format r epr esentati on of the model (6.3) can be cr eated by
t h = ar x 2t h( A, B, ny, nu)
where ny and nu are the number of outputs and i nputs, r especti vel y, and A and
B ar e matr i ces that defi ne the matri x pol ynomi al s (6.4) and (6.7):
A = [ ey e( 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 Tutori al
3-32
Consi der the fol l owi ng system wi th two outputs and thr ee i nputs:
Thi s system i s defi ned and si mul ated for a certai n i nput u, and then esti mated
i n the corr ect ARX str uctur e by the fol l owi ng str i ng of commands:
A0 = ey e ( 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] ;
t h0 = ar x2t h( A, B, 2, 3) ;
e = r andn( 200, 2) ;
u = [ i di nput ( 200) , i di nput ( 200) , i di nput ( 200) ] ;
y = i ds i m( [ u e ] , t h0) ;
na = [ 2 1; 2 1] ;
nb = [ 2 3 0; 1 1 2] ;
nk = [ 4 0 0; 0 4 1] ;
t he = ar x( [ y u] , [ na nb nk] ) ;
[ Ae , Be ] = t h2ar x( t he ) ;
You can use the two commands f i xpar and unf i x par to mani pul ate ARX
structures, so that certai n par ameters i n the structure are fi xed to cer tai n
known val ues and not esti mated. See Chapter 4, "Command Refer ence"for
more i nfor mati on.
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 with Free Parameters
The basi c state-space model s ar e the fol l owi ng ones: (See al so The System
I denti fi cati on Probl em on page 3-8.)
Discrete-Time Innovations Form
Her e T i s the sampl i ng i nter val , i s the i nput at ti me i nstant and
i s the output at ti me . (See Ljung (1987) page 87.)
System Dynamics Expressed in Continuous Time
(See Ljung (1987) page 82.) I t i s often easi er to defi ne a parametr i zed
state-space model i n conti nuous ti me because physi cal l aws are most often
descr i bed i n ter ms of di fferenti al equati ons. The matr i ces F, G, H, and D
contai n el ements wi th physi cal si gni fi cance (for exampl e, materi al constants).
The numer i cal val ues of these may or may not be known. To esti mate unknown
parameter s based on sampl ed data (assumi ng T i s the sampl i ng i nterval ) fi r st
transform (6.9) to (6.8) usi ng the formul as (3.30). The val ue of the Kal man-gai n
matri x K i n (6.8) or i n (6.9) depends on the assumed character of the addi ti ve
noi ses and i n (3.28), and i ts conti nuous-ti me counter part. Di sregar d
that l i nk and vi ew K i n (6.8) (or i n (6.9)) as the basi c tool to model the noi se
properti es. Thi s gi ves the directly parametrized innovations form. (See Ljung
(1987) page 88.) I f the i nternal noi se str uctur e i s i mportant, you coul d use
user -defi ned str uctures as i n Exampl e 6.4.
The System I denti fi cati on Tool box al l ows you to defi ne ar bi tr ar y
parameter i zati ons of the matr i ces i n (6.8) or (6.9). When defi ni ng the str ucture,
the known el ements i n the matr i ces are entered wi th thei r numeri cal val ues,
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 Tutori al
3-34
whi l e the unknown el ements ar e enter ed as NaN. Use the commands mods t r uc
and ms 2t h.
The Black-Box, Discrete-Time Case
For a di screte-ti me model , l i ke (6.8) wi thout any parti cul ar i nter nal structur e,
i t i s easi er and more natural to use cans t ar t or n4s i d to esti mate the model ,
wi thout any pri or speci fi cati on of the par ametri zati on.
Example 6.1: A Discrete-Time Structure. Consi der the di scr ete-ti me model
wi th fi ve unknown parameter s , i=1, ...,3. Thi s structure i s defi ned i n the
theta for mat by
A = [ 1 NaN; 0 1] ;
B = [ NaN; NaN] ;
C = [ 1 0] ;
D = 0;
K = [ NaN; NaN] ;
x 0 = [ 0; 0] ;
ms 1 = mods t r uc ( A, B, C, D, K, x0) ;
t h1 = ms 2t h( ms 1, ' d' )
The defi ni ti on thus fol l ows i n two steps. Fi rst the actual structure (known and
unknown parameter val ues) i s coded i n the matri x ms 1 and then a theta for mat
matri x i s created by ms 2t h. The ar gument ' d' denotes that the structure i s a
di screte-ti me str uctur e. Other opti onal ar guments al l ow defi ni ti on of guessed
val ues of the unknown parameter s, as wel l as speci fi cati on of the covari ance
matri x of and of the sampl i ng i nterval T. You can al so speci fy unknown
el ements i n the i ni ti al val ue vector .
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 model s that ar e par ametr i zed as canoni cal forms, use canf or m i nstead of
mods t r uc to defi ne the model structure.
Example 6.2: A Continuous-Time Model Structure. Consi der the fol l owi ng
model structure
Thi s cor responds to an el ectri cal motor , where i s the angul ar
posi ti on of the motor shaft and i s the angul ar vel oci ty. The
parameter i s the i nver se ti me constant of the motor and i s the
stati c gai n fr om the i nput to the angul ar vel oci ty. (See page 84 i n Ljung (1987).)
The motor i s at r est at ti me 0 but at an unknown angul ar posi ti on. Suppose
that i s around -1 and i s around 0.25. I f you al so know that the vari ance
of the er rors i n the posi ti on measur ement i s 0.01 and i n the angul ar vel oci ty
measurements i s 0.1, you can then defi ne a theta structure usi ng
F = [ 0 1; 0 NaN]
G = [ 0 ; NaN]
H = e ye ( 2)
D = z er os ( 2, 1)
K = z er os ( 2, 2)
x 0 = [ NaN; 0]
ms 2 = mods t r uc ( F, G, H, D, K, x0) ;
t hgue s s =[ 1, 0. 25, 0]
noi s e var = [ 0. 01 0; 0 0. 1]
t h2 = ms 2t h( ms 2, ' c ' , t hgue s s , noi s e var )
The structur e t h2 can now be used to esti mate the unknown parameter s
from observed data z = [ y1 y 2 u] by
model = pem( z , t h2)
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 Tutori al
3-36
The i ter ati ve sear ch for mi ni mum i s then i ni ti al i zed at t hgues s . The structur e
can al so be used to si mul ate the system above wi th sampl i ng i nterval T=0. 1 for
i nput u and noi se r eal i zati on e :
e =r andn( 300, 2)
u=i di nput ( 300) ;
t h2 = s e t t ( t h2, 0. 1) % s et t i ng t he s ampl i ng i nt e r v al
y = i ds i m( [ u e ] , t h2)
The nomi nal parameter val ues t hgues s ar e then used, and the noi se sequence
i s scal ed accor di ng to the matr i x noi s e var .
When esti mati ng model s, you can tr y a number of nei ghbor i ng structures,
l i ke what happens i f I fi x thi s parameter to a cer tai n val ue or what happens
i f I l et l oose these par ameters. Rather than goi ng thr ough the whol e pr ocedur e
i n r edefi ni ng the structure, you can use the commands f i x par and unf i x par .
For exampl e, to free the par ameter x
2
(0) (per haps the motor wasnt at r est
after al l ) you can use
t h = unf i x par ( t h2, ' x0' , [ 2, 1] )
To mani pul ate i ni ti al condi ti ons, the functi on t hi ni t i s al so useful .
State-Space Models with Coupled Parameters
I n some si tuati ons you may want the unknown par ameters i n the matr i ces i n
(6.8) or (6.9) to be l i nked to each other. Then the NaN feature i s not suffi ci ent to
descri be these l i nks. I nstead you need to wri te an M-fi l e that descr i bes the
structure. The for mat i s
[ A, B, C, D, K, x 0] = my mf i l e( par , T, aux ) ;
where my mf i l e i s the user-defi ned name for the M-fi l e, par contai ns the
par ameters, T i s the sampl i ng i nter val , and aux contai ns auxi l i ary vari abl es.
The l atter var i abl es ar e used to house opti ons, so that some di ffer ent cases can
be tri ed out wi thout havi ng to edi t the M-fi l e. The matri ces A, B, C, D, K, and x 0
r efer to the di scr ete-ti me descri pti on (6.8). I f the underl yi ng parameter i zati on
i s i n conti nuous ti me, as i n (6.9), i t i s desi rabl e to wri te the M-fi l e so that a
negati ve val ue of T i nhi bi ts the sampl i ng. Thi s means that A, B, C and D shoul d
be r etur ned as the matri ces i n (6.9) when mymf i l e i s cal l ed wi th a negati ve T.
To obtai n the same str uctur e as i n the Exampl e 6.2 , you can do the fol l owi ng:
3-37
f unct i on [ A, B, C, D, K, x0] = mymf i l e ( par , T, aux)
F = [ 0 1; 0 par ( 1) ] ;
G = [ 0; par ( 2) ] ;
C = e ye ( 2) ;
D = z er os ( 2, 2) ;
K = z er os ( 2, 1) ;
x 0 =[ par ( 3) ; 0] ;
i f T>0, [ A, B] = c2d( F, G, T) ; e l s e A=F; B=G; e nd
Her e c 2d i s the sampl i ng functi on from the Contr ol System Tool box, whi ch
consequentl y i s requi red to r un thi s exampl e.
Once the M-fi l e has been wr i tten, the corr espondi ng theta structur e i s defi ned
by the command mf 2t h (M-fi l e to theta):
t h = mf 2t h( ' my mf i l e' , ' c ' , par , aux) ;
where par contai ns the nomi nal (i ni ti al ) val ues of the corr espondi ng entr i es i n
the str uctur e. ' c ' si gnal s that the underl yi ng par ametri zati on i s conti nuous
ti me, and that the M-fi l e i s equi pped wi th sampl i ng i nhi bi ti on (for ). aux
contai ns the val ues of the auxi l i ar y parameter s.
From here on, esti mate model s and eval uate resul ts as for any other model
str uctur e. Note, though that the featur es f i xpar and unf i xpar ar e not
avai l abl e for these general structures. Some fur ther exampl es of user -defi ned
model structures ar e gi ven bel ow.
State-Space Structures: Initial Values and Numerical
Derivatives
I t i s someti mes di ffi cul t to fi nd good i ni ti al par ameter val ues at whi ch to star t
the numeri cal search for a mi ni mum of (3.38). I t i s al ways best to use physi cal
i nsi ght, whenever possi bl e, to suggest such val ues wi th t hgues s . For r andom
i ni ti al i zati on, the command t hi ni t i s a useful al ter nati ve and compl ement to
t hgue s s . Si nce there i s al ways a ri sk that the numer i cal mi ni mi zati on may get
stuck i n a l ocal mi ni mum, i t i s advi sabl e to tr y sever al di ffer ent i ni ti al i zati on
val ues for .
I n the sear ch for the mi ni mum, the gradi ent of the predi cti on er ror s i s
computed by numeri cal di ffer enti ati on. The step-si ze i s determi ned by the
M-fi l e nude r s t . I n i ts defaul t versi on the step-si ze i s si mpl y ti mes the
absol ute val ue of the par ameter i n questi on (or the number i f thi s i s
T 0 <

e t ( )
10
4
10
7
3 Tutori al
3-38
l ar ger ). When the model structure contai ns par ameters wi th di fferent or der s of
magni tude, tr y to scal e the vari abl es so that the parameter s ar e al l roughl y the
same magni tude. I n any case, you may need to edi t the M-fi l e nuder s t to
addr ess the pr obl em of sui tabl e step si zes for numer i cal di fferenti ati on.
Some Examples of User-Defined Model Structures
Wi th user-defi ned str uctur es, you have compl ete fr eedom i n the choi ce of
model s of l i near systems. Thi s secti on gi ves two exampl es of such structures.
Example 6.3: Heat Diffusion. Consi der a system dr i ven by the heat-di ffusi on
equati on (see al so Exampl e 4.3 i n Ljung (1987)).
Thi s i s a metal rod wi th heat-di ffusi on coeffi ci ent whi ch i s i nsul ated at the
near end and heated by the power u (W) at the far end. The output of the
system i s the temper ature at the near end. Thi s system i s descr i bed by a parti al
di fferenti al equati on i n ti me and space. Repl aci ng the space-second der i vati ve
by a cor respondi ng di fference appr oxi mati on gi ves a ti me-conti nuous
state-space model (6.9), where the di mensi on of x depends on the step-si ze i n
space used i n the approxi mati on. Thi s i s descri bed by the fol l owi ng M-fi l e:
f unct i on [ A, B, C, D, K, x 0] = heat d( par s , T, aux)
N = aux ( 1) ; % Numbe r of poi nt s i n t he
% s pac e di s cr et i z at i on
L = aux ( 2) ; % Le ngt h of t he r od
t emp = aux ( 3) ; % As s umi ng uni f or m i ni t i al
% t e mpe r at ur e of t he r od
del t aL = L/N; % Space i nt er val
kappa = par s ( 1) ; % The he at di f f us i on coe f f i c i e nt
K = par s ( 2) ; % Heat t r ans f e r c oe f f i c i e nt at
% f ar e nd of r od
F=z er os ( N, N) ;
f or kk=2: N1
F( kk, kk1) =1;
F( kk, kk) =2;
F( kk, kk+1) =1;
e nd
F( 1, 1) =1; F( 1, 2) =1; % Ne ar e nd of r od
% i ns ul at ed
F( N, N1) =1; F( N, N) =1;
F=Fkappa/de l t aL/de l t aL;

3-39
G=z er os ( N, 1) ;
G( N, 1) =K/de l t aL;
C=z er os ( 1, N) ;
C( 1, 1) =1;
D=0;
K=z er os ( N, 1) ;
x 0=t e mp ones ( N, 1) ;
i f T>0 [ A, B] =c 2d( F, G, T) ; e l s e A=F; B=G; e nd
You can then get started wi th the theta format wi th
t h = mf 2t h( ' he at d' , ' c' , [ 0. 27 1] , [ 10, 1, 22] , [ ] , 10)
for a 10th order appr oxi mati on of a heat rod one meter i n l ength, wi th an i ni ti al
temperature of 22 degr ees and a sampl i ng i nter val of 10 seconds. The i ni ti al
esti mate of the heat conducti vi ty i s 0.27, and of the heat transfer coeffi ci ent i s
1. The covari ance matr i x of the predi cti on err ors i s gi ven a defaul t val ue.
Example 6.4: Parametrized Noise Models. Consi der a di screte-ti me model
x(t+1)=Ax(t)+Bu(t)+w(t)
y(t)=Cx(t)+e(t)
where w and e ar e i ndependent whi te noi ses wi th covari ance matri ces R1 and
R2, r especti vel y. Suppose that you know the var i ance of the measur ement
noi se R2, and that onl y the fi rst component of i s nonzer o. Thi s can be
handl ed by the fol l owi ng M-fi l e:
f unct i on [ A, B, C, D, K, x0] = mynoi s e ( par , T, aux)
R2 = aux( 1) ; % The as s ume d known me as ur e me nt
% noi s e v ar i anc e
A = [ par ( 1) par ( 2) ; 1 0] ;
B = [ 1; 0] ;
C=[ par ( 3) par ( 4) ] ;
D=0;
R1= [ par ( 5) 0; 0 0] ;
K = Adl qe ( A, e ye ( 2) , C, R1, R2) ; % f r om t he
% Cont r ol Sy s t em Tool box
x 0=[ 0; 0] ;
w t ( )
3 Tutori al
3-40
7. Examining Models
Once you have esti mated a model , you need to i nvesti gate i ts pr oper ti es. You
have to si mul ate i t, test i ts predi cti ons, and compute i ts pol es and zer os and so
on. You thus have to tr ansfor m the model fr om the theta format to other ways
of r epresenti ng and pr esenti ng i t.
Theta Format: th
The basi c format for r epresenti ng model s i n the System I denti fi cati on Tool box
i s cal l ed the theta format. I t stor es al l r el evant i nfor mati on about the model
structure used, i ncl udi ng the val ues of the esti mated par ameter s, the
esti mated covar i ances of the parameter s, and the esti mated i nnovati ons
vari ance and so on. I t al so contai ns some i nformati on about how and when the
model was cr eated. The detai l s of the repr esentati on can be found i n the
Chapter 4, "Command Reference" or by typi ng he l p t het a (for state-space
based structures type he l p t hs s ). The r epr esentati on shoul d, however, be
thought of as an i nternal one; unl ess you are an advanced user , you do not need
to wor ry about the detai l s. Defi ni ng Model Structures on page 3-29 descr i bes
how to cr eate model s i n the theta for mat usi ng sever al di ffer ent commands.
The i nformati on i n the theta for mat i s di spl ayed by the pr es e nt command:
pr e s e nt ( t h)
Thi s spel l s out the i nformati on i n t h. Dependi ng on the character of the
underl yi ng model structur e, the i nformati on i s gi ven i n ter ms of the
pol ynomi al s i n (6.1), i n terms of the matr i ces i n (6.8) or (6.9), or i n ter ms of the
ARX pol ynomi al s i n (6.3). Esti mated standar d devi ati ons for the parameter s
ar e al ways suppl i ed. For mul ti vari abl e ARX model s and for state-space
matri ces, the standard devi ati ons are gi ven as i magi nary number s added to the
par ameters. For the pol ynomi al s they ar e gi ven as a second row. For exampl e,
the fol l owi ng pri ntout from pr es e nt
The pol y nomi al c oe f f i ci ent s and t hei r s t andar d de vi at i ons ar e
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
i s i nter preted as and the standard devi ati on
of 1 i s zer o (natur al l y enough , si nce i t i s not esti mated). The standard
devi ati on of i s 0.0214. Note that l eadi ng zer os i n the B pol ynomi al i ndi cate
the del ay, as defi ned i n Defi ni ng Model Str uctur es on page 3-29.
The actual parameter s can be extr acted from the theta format by
[ par , P] = t h2par ( t h)
Her e par i s a r ow vector contai ni ng the parameter s, and P i s the esti mated
covari ance matr i x of the par ameters. The par ameters ar e l i sted i n
al phabeti cal or der. See Some Speci al Topi cs on page 3-68. For the
pol ynomi al model (6.1) the coeffi ci ents of the A, B, C, D, and F pol ynomi al s are
gi ven i n the order of i ncreasi ng power s of . (See for exampl e (6.2).) Note that
l eadi ng 0s of B and the l eadi ng 1 i n the other pol ynomi al s are omi tted si nce
they do not corr espond to esti mated par ameters. For the state-space model
(6.8) the par ameters ar e gi ven i n the order obtai ned as the matri x A i s fi r st
sear ched for esti mated parameter s row by r ow, then B and then C, etc. The
same i s true for the conti nuous model (6.9). For user -defi ned structures, the
orderi ng i n par i s the same as defi ned i n the cor respondi ng M-fi l e. For
mul ti var i abl e ARX model s, the or der i ng of parameter s i s somewhat tri cky and
i t i s safer use t h2ar x. (See The ARX For mat: ar x on page 3-45.)
The sampl i ng i nter val can be extr acted from the theta format by
T = get t ( t h)
A negati ve T means that t h repr esents a ti me-conti nuous system. Then system
abs ( T) i ndi cates the sampl i ng i nter val for the data for whi ch the model was
esti mated. I t i s al so the sampl i ng i nterval that appl i es when t h i s used for
si mul ati on or predi cti on.
Frequency Function Format: ff
The frequency functi on and the di sturbance spectr um corr espondi ng to a model
t h i n the theta format i s computed by
[ G, PHI V] = t h2f f ( t h)
Thi s gi ves G and i n (3.11) al ong wi th thei r esti mated standard devi ati ons,
whi ch ar e tr ansl ated fr om the covari ance matr i x of the esti mated parameter s.
I f t h cor responds to a ti me-conti nuous model , the fr equency functi ons are
computed accor di ngl y.
A q ( ) 1 1.5312q
1
0.6983q
2
+ =
a
1
q
1

v
3 Tutori al
3-42
The resul ti ng matri ces G and PHI V are gi ven i n the freqfunc format. Thi s format
stor es the frequency functi ons and spectr a (3.11) and thei r standar d devi ati ons
as col umn vectors. The fi r st row i s r eserved for admi ni strati ve i nformati on,
gi vi ng detai l s about i nput and output number s. The frequency val ues can be
chosen ar bi tr ari l y, but defaul t to 128 val ues equal l y spaced between 0
(excl uded) and the Nyqui st fr equency. For ti me-conti nuous model s, the defaul t
frequency range extends to a decade over the Nyqui st frequency for the
sampl ed data upon whi ch the model i s based. Typi ng he l p f r e qf unc descri bes
the detai l s of the format, whi ch, however, i s not i mpor tant for basi c use of the
tool box.
The functi on t h2f f has opti ons that al l ow the sel ecti on of speci fi c i nput-output
pai r s, and the computati on of fr equency functi ons and spectr a at arbi trar y
frequenci es.
I f t h corresponds to a model of a ti me seri es, i ts spectrum i s obtai ned as
PHI Y = t h2f f ( t h)
Model s i n the fr eqfunc format are al so obtai ned by the nonparametr i c
esti mati on routi nes s pa and e t f e , as descr i bed i n Nonparametri c Model
Esti mati on on page 3-19.
Thr ee functi ons offer graphi c di spl ay of the fr equency functi ons and spectr a:
bodepl ot , f f pl ot , and nyqpl ot .
bodepl ot ( G)
pl ots the Bode di agr am of G (l ogar i thmi c scal es and frequenci es i n rad/sec). I f G
i s a spectrum, onl y an ampl i tude pl ot i s gi ven. Several curves i n the same
di agram ar e obtai ned wi th
bodepl ot ( [ G1 G2 . . . Gn] )
I f i nformati on about standard devi ati ons i s i ncl uded i n G, confi dence i nterval s
cor respondi ng to s d standard devi ati ons ar e graphed wi th
bodepl ot ( G, s d)
The command f f pl ot has the same syntax as bode pl ot but works wi th l i near
frequency scal es and Hertz as the uni t. The command ny qpl ot al so has the
same syntax, but pr oduces Nyqui st pl ots; i .e., graphs of the frequency functi on
i n the compl ex pl ane.
For the cr eati on of own fr equency pl ots, the command ge t f f extracts the
r el evant porti ons of the freqfunc format. (See Chapter 4, "Command
Reference"for more i nformati on.)
3-43
Zero-Pole Format: zp
The command t h2z p computes the zeros, pol es, and stati c gai ns of the system
associ ated wi th t h:
[ z e po, K] = t h2z p( t h)
The matr i x z e po now contai ns i nfor mati on about the zeros and the pol es of the
model , al ong wi th thei r esti mated standard devi ati ons. I t al so contai ns (i n the
fi rst r ow) admi ni strati ve i nfor mati on about i nput and output numbers, whi ch
i s used for pl otti ng. Si mi l arl y, K contai ns the stati c gai ns and thei r standar d
devi ati ons. The best way of usi ng the i nformati on i n z epo i s to gr aph the zer os
and pol es by
z ppl ot ( z e po)
Confi dence r egi ons (l i nes and el l i psoi ds) corr espondi ng to s d standard
devi ati ons are i l l ustr ated by
z ppl ot ( z e po, s d)
Compari sons between sever al model s ar e obtai ned by
z p1 = t h2z p( t h1)
z p2 = t h2z p( t h2)
z ppl ot ( z pf or m( z p1, z p2) )
z ppl ot has sever al opti ons that deter mi ne how i nfor mati on about di ffer ent
model s and di ffer ent i nput-output pai r s i s depi cted. I t al so keeps tr ack of
whether the under l yi ng model i s i n di screte or conti nuous ti me and draws the
compl ex pl ane accordi ngl y. The command t h2z p al so al l ows the sel ecti on of
speci fi c i nput-output subsystems i n the case of mul ti var i abl e model s.
The functi on get z p al l ows you to extract the zer os and the pol es expl i ci tl y fr om
the zero-pol e format.
State-Space Format: ss
The command
[ A, B, C, D, K, X0] = t h2s s ( t h)
computes the matri ces of a state-space r epresentati on of t h. The
repr esentati on i s i n di scr ete ti me as (6.8) or i n conti nuous ti me as (6.9)
dependi ng on the status of t h. I f the underl yi ng model str uctur e i s a
3 Tutori al
3-44
state-space one, the matri ces A, B, etc. ar e gi ven i n the same basi s as ori gi nal l y
defi ned. I f the under l yi ng model i s defi ned i n terms of i nput-output
pol ynomi al s, the state-space representati on i s i n observer canoni cal for m. The
state-space matr i ces can be used for further anal ysi s and desi gn i n the Contr ol
System Tool box and the Si gnal Pr ocessi ng Tool box.
The command t h2s s can al so compute the standar d devi ati ons of the el ements
i n state-space matr i ces.
Transfer Function Format: tf
The transfer functi ons associ ated wi th the model t h ar e computed by
[ NUM, DEN] = t h2t f ( t h)
NUM and DEN are gi ven i n the same for mat that i s used i n the Control System
Tool box and the System Processi ng Tool box. The common denomi nator DEN as
a row matri x and the k-th row of NUM gi ves the numerator pol ynomi al
associ ated wi th output number k. I f the model t h has several i nputs, speci fy
the i nput number as an ar gument. The pol ynomi al s are represented as r ow
vectors i n descendi ng power s of s (i n conti nuous ti me) or z or q (i n di screte
ti me). I t thus di ffer s from the pol ynomi al for mat. (See bel ow.) For exampl e, the
conti nuous-ti me system
i s r epr esented as
NUM = [ 0 0 1] ( or j us t 1)
DEN = [ 1 2 0]
whi l e the di scr ete-ti me system
i s r epr esented 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
I n the pol ynomi al for mat, the pol ynomi al s A, B, C, D, and F i n (3.23) are gi ven
as fol l ows: Pol ynomi al coeffi ci ents ar e stored i n row vectors, or dered by
ascendi ng powers i n the del ay oper ator , , 1, , al ways starti ng wi th
. Thi s means that (7.1) i s r epresented by
B = [ 0 0 0 1]
A = [ 1 1. 5 0. 7]
Del ays are thus denoted by l eadi ng zeros i n B. Note the di fference wi th the
tr ansfer functi on repr esentati on, i n that l eadi ng zeros must be expl i ci tl y gi ven.
Onl y when the l engths of A and B ar e the same do the formats coi nci de. See al so
Secti on 6. The pol ynomi al s corr espondi ng to t h are extracted by
[ A, B, C, D, F] = t h2pol y( t h)
Thi s i s consequentl y the i nver se of pol y 2t h descri bed i n Defi ni ng Model
Str uctur es on page 3-29.
Conti nuous-ti me systems can al so be represented i n the pol ynomi al format.
Then the pol ynomi al s are gi ven as r ow vector s i n descendi ng power s of the
Lapl ace var i abl e s just as i n the tr ansfer functi on case.
The ARX Format: arx
To obtai n an ARX descr i pti on from a model t h that cor responds to such a
descr i pti on (i .e., i t has or i gi nal l y been gener ated by ar x, i v 4, or ar x 2t h), use
[ A, B] = t h2ar x ( t h)
The matr i ces A and B then contai n the ARX pol ynomi al s as descr i bed i n Secti on
6. t h2ar x i s thus an i nverse of ar x 2t h.
q
k
k 0 =
k 0 =
3 Tutori al
3-46
Transformations Between Discrete and Continuous
Models
Continuous-Time Models
A model i n the theta format can be i nternal l y r epresented as a continuous-time
model. Thi s occur s i f the structure was or i gi nal l y defi ned as a state-space
structure wi th ms 2t h or mf 2t h usi ng the ar gument ' c ' . (See Defi ni ng Model
Structures on page 3-29 and the Chapter 4, "Command Reference".) The model
then remai ns a conti nuous-ti me one dur i ng the esti mati on phases wi th pe m
even though the esti mati on i s perfor med usi ng sampl ed data. A
conti nuous-ti me model of the type (6.1) i n pol ynomi al for m al so r esul ts when
pol y2t h i s used wi th a negati ve val ue of the sampl i ng i nter val . Thi s str uctur e
cannot, however, be used for further esti mati on. Fi nal l y, conti nuous-ti me
model s are obtai ned by the command t hd2t hc. (See bel ow.)
Conti nuous-ti me model s ar e i ndi cated by a negati ve sampl i ng i nterval . A qui ck
check can thus be gi ven by
ge t t ( t h) <0
Al l the model transformati ons t h2f f , t h2z p, t h2s s , t h2t f , and t h2pol y r esul t
i n the corr espondi ng characteri sti cs i n conti nuous ti me for model s t h that are
i ndi cated as conti nuous. For si mul ati on and predi cti on, however , the model i s
fi r st transformed to di scr ete ti me.
The absol ute val ue of the sampl i ng i nterval of a conti nuous-ti me model i s the
sampl i ng i nterval of the data for whi ch the model was esti mated. I t i s al so used
to sel ect sui tabl e defaul t frequency i nter val s i n t h2f f (the defaul t bei ng from
zero up to 10
*
/ | T| r ad/sec). The absol ute val ue of T al so appl i es when the
model i s used for si mul ati on and pr edi cti on.
Discrete-Time Models
These model s are obtai ned from the esti mati on functi ons ar , ar max , ar x , bj ,
i var , i v4, n4s i d, and oe . They ar e al so obtai ned from pem when appl i ed to (6.1)
and to state-space str uctur es generated by ms 2t h and mf 2t h wi th the argument
' d' . Di scr ete-ti me model s al so resul t fr om pol y 2t h wi th posi ti ve or defaul t
val ues of the sampl i ng i nter val . Fi nal l y di scr ete-ti me model s ar e obtai ned wi th
the command t hc2t hd. (See bel ow.)
3-47
The sampl i ng i nter val T i s obtai ned by T = get t ( t h) . I t i ndi cates the sampl i ng
i nter val of the model as wel l as of the data to whi ch the model was adjusted. I t
i s al so used for appropri ate fr equency scal es i n the fr eqfunc for mat.
Transformations
Transformati ons between conti nuous-ti me and di scr ete-ti me model
repr esentati ons are achi eved by t hc2t hd and t hd2t hc . The corr espondi ng
uncer tai nty measur e (the esti mated covar i ance matri x of the i nter nal
parameter s) i s al so transformed i n most cases. The syntax i s
t hc = t hd2t hc( t hd)
t hd = t hc 2t hd( t hc, T)
I f the di scr ete-ti me model has some pure ti me del ays ( ) the defaul t
command r emoves them befor e formi ng the conti nuous-ti me model . They
shoul d then be appended as an extra dead ti me. Thi s i s done automati cal l y by
t h2f f . t hd2t hc offers as an opti on to approxi mate the dead ti me by a fi ni te
di mensi onal system. Note that the noi se properti es ar e transl ated by the
somewhat questi onabl e formul a (3.32). The covari ance matri x i s transl ated by
Gauss appr oxi mati on for mul a usi ng numer i cal deri vati ves. The M-fi l e
nuder s t i s then i nvoked. You may want to edi t i t for appl i cati ons where the
parameter s have ver y di ffer ent orders of magni tude. See the comments i n
Defi ni ng Model Str uctur es on page 3-29.
Her e i s an exampl e whi ch compares the Bode pl ots of an esti mated model and
i ts conti nuous-ti me counter part:
t h = ar max( z , [ 2 3 1 2] ) ;
gd = t h2f f ( t h) ;
t hc = t hd2t hc( t h) ;
gc = t h2f f ( t hc ) ;
bodepl ot ( [ gd gc] )
Simulation and Prediction
Any model , when gi ven i n the theta format, can be si mul ated wi th
y = i ds i m( [ u e ] , t h)
where u and e ar e col umn vectors (or matri ces) contai ni ng the i nput and noi se
sequences. The output i s returned i n a col umn vector y of the same l ength.
Noti ce that t h contai ns i nformati on about the noi se vari ance so e shoul d be a
nk 1 >
3 Tutori al
3-48
zero-mean, uni t-var i ance sequence. I f e i s omi tted, a noi se-free si mul ati on i s
obtai ned. Her e i s a typi cal str i ng of commands:
A = [ 1 1. 5 0. 7] ;
B = [ 0 1 0. 5] ;
t h0 = pol y 2t h( A, B, [ 1 1 0. 2] ) ;
u = i di nput ( 400, r bs , [ 0 0. 3] ) ;
e = r andn( 400, 1) ;
y = i ds i m( [ u e ] , t h0) ;
pl ot ( y)
The i nverse model (3.38), whi ch computes the pr edi cti on er rors fr om gi ven
i nput-output data, i s si mul ated wi th
e = pe( [ y u] , t h)
To compute the k-step ahead predi cti on of the output si gnal based on a model
t h, the pr ocedur e i s as fol l ows:
y hat = pr e di ct ( [ y u] , t h, k)
The pr edi cted val ue i s computed usi ng the i nfor mati on i n up to
ti me and i nfor mati on i n up to ti me . The actual way that
the i nfor mati on i n past outputs i s used depends on the noi se model i n t h. For
exampl e, an output er ror model mai ntai ns that ther e i s no
i nfor mati on i n past outputs, ther efor e, predi cti ons and si mul ati ons coi nci de.
pr e di ct can eval uate how wel l a ti me seri es model i s capabl e of predi cti ng
futur e val ues of the data. Here i s an exampl e, where y i s the ori gi nal ser i es of,
say, monthl y sal es fi gur es. A model i s esti mated based on the fi rst hal f, and
then i ts abi l i ty to pr edi ct hal f a year ahead i s checked out on the second hal f of
the obser vati ons:
i dpl ot ( y )
y 1 = y( 1: 48) , y2 = y( 49: 96)
t h = ar ( y1, 4)
y hat = pr e di ct ( y 2, t h4, 6)
pl ot ( [ y 2 y hat ] )
The command c ompar e i s useful for any compari sons i nvol vi ng i ds i m and
pr e di ct .
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
After you have been anal yzi ng data for some ti me, you typi cal l y end up wi th a
l ar ge col l ecti on of model s wi th di fferent order s and str uctur es. You need to
deci de whi ch one i s best, and i f the best descr i pti on i s an adequate model for
your purposes. These are the pr obl ems of model validation.
Model val i dati on i s the heart of the i denti fi cati on probl em, but ther e i s no
absol ute pr ocedur e for approachi ng i t. I t i s wi se to be equi pped wi th a var i ety
of di fferent tool s wi th whi ch to eval uate model qual i ti es. Thi s secti on descri bes
the techni ques you can use to eval uate model qual i ti es usi ng the System
I denti fi cati on Tool box.
Comparing Different Structures
I t i s natural to compare the resul ts obtai ned from model structures wi th
di ffer ent or ders. For state-space model s thi s i s easi l y obtai ned by usi ng a vector
ar gument for the or der i n n4s i d:
t h = n4s i d( z , 1: 10)
Thi s i nvokes a pl ot fr om whi ch a best order i s chosen.
For model s of ARX type, var i ous order s and del ay can be effi ci entl y studi ed
wi th the command ar x s t r uc. Col l ect i n a matr i x NN al l of the ARX str uctur es
you want to i nvesti gate, so that each r ow of NN i s of the type
[ na nb nk]
Wi th
V = ar x s t r uc ( z e, z v , NN)
an ARX model i s fi tted to the data set z e for each of the structures i n NN. Next,
for each of these model s, the sum of squar ed predi cti on er rors i s computed, as
they ar e appl i ed to the data set z v . The resul ti ng l oss functi ons are stored i n V
together wi th the corr espondi ng structures.
To sel ect the str uctur e that has the smal l est l oss functi on for the val i dati on set
z v , use
nn = s e l s t r uc( V, 0)
3 Tutori al
3-50
Such a procedure i s known as cross validation and i s a good way to approach
the model sel ecti on pr obl em.
I t i s usual l y a good i dea to vi sual l y i nspect how the fi t changes wi th the number
of esti mated par ameters. A gr aph of the fi t ver sus the number of parameter s i s
obtai ned wi th
nn = s e l s t r uc( V)
Thi s r outi ne pr ompts you to choose the number of parameter s to esti mate,
based upon vi sual i nspecti on of the gr aph, and then i t sel ects the structure
wi th the best fi t for that number of par ameters.
The command s t r uc hel ps gener ate typi cal structure matr i ces NN for
si ngl e-i nput systems. A typi cal sequence of commands i s
V = ar x s t r uc ( z e, z v , s t r uc( 2, 2, 1: 10) ) ;
nn = s e l s t r uc( V, 0) ;
nk = nn( 3) ;
V = ar x s t r uc ( z e, z v , s t r uc( 1: 5, 1: 5, nk1: nk+1) ) ;
nn = s e l s t r uc( V)
where you fi rst establ i sh a sui tabl e val ue of the del ay nk by testi ng second
order model s wi th del ays between one and ten. The best fi t sel ects the del ay,
and then al l combi nati ons of ARX model s wi th up to fi ve a and b parameter s
ar e tested wi th del ays ar ound the chosen val ue (a total of 75 model s).
I f the model i s val i dated on the same data set from whi ch i t was esti mated; i .e.,
i f z e = z v, the fi t al ways i mproves as the model structure i ncreases. You need
to compensate for thi s automati c decr ease of the l oss functi ons. There are
sever al approaches for thi s. Probabl y the best known techni que i s Akai kes
Fi nal Pr edi cti on Er ror (FPE) cr i ter i on and hi s cl osel y rel ated I nformati on
Theoreti c Cr i teri on (AI C). Both si mul ate the cr oss val i dati on si tuati on, where
the model i s tested on another data set.
The FPE i s formed as
FPE
1 n + N
1 n N
-------------------- = *V
3-51
where n i s the total number of esti mated par ameters and N i s the l ength of the
data recor d. V i s the l oss functi on (quadrati c fi t) for the structure i n questi on.
The AI C i s formed as
(See Secti on 16.4 i n Ljung (1987).)
Accordi ng to Akai kes theory, i n a col l ecti on of di fferent model s, choose the one
wi th the smal l est FPE (or AI C). The FPE val ues ar e di spl ayed by the pr e s ent
command and are al so gi ven as the entry (2,1) of the t h matri x. The str uctur e
that mi ni mi zes the AI C i s obtai ned wi th
nn = s e l s t r uc( V, ' AI C' )
where V was gener ated by ar xs t r uc .
A rel ated cr i teri on i s Ri ssanens mi ni mum descr i pti on l ength (MDL) approach,
whi ch sel ects the str uctur e that al l ows the shor test over-al l descr i pti on of the
observed data. Thi s i s obtai ned wi th
nn = s e l s t r uc( V, ' MDL' )
I f substanti al noi se i s present, the ARX model s may need to be of hi gh or der to
descr i be si mul taneousl y the noi se character i sti cs and the system dynami cs.
(For ARX model s the noi se model 1/A(q) i s di rectl y coupl ed to the dynami cs
model B(q)/A(q).) An al ternati ve i s to compute the dynami cs model onl y, usi ng
an I V techni que, and to compute the fi t between the model s si mul ated output
and the output i n the val i dati on data set z v . Thi s i s accompl i shed wi th
V = i vs t r uc ( z e , z v, NN)
The i nformati on i n V can then be handl ed as descr i bed above. I n thi s case, V
al so contai ns the condi ti on number of the matr i x fr om whi ch the I V esti mates
ar e sol ved. Poor condi ti oni ng of thi s matri x i ndi cates unnecessari l y hi gh model
orders. (See page 415 i n Ljung, 1987).
Checking Pole-Zero Cancellations
A near pol e-zer o cancel l ati on i n the dynami cs model i s an i ndi cati on that the
model order may be too hi gh. To judge i f a near cancel l ati on i s a r eal
cancel l ati on, take the uncer tai nti es i n the pol e- and zero-l ocati ons i nto
AIC log 1 2n + N ( )*V [ ]
3 Tutori al
3-52
consi der ati on. The functi on t h2z p computes confi dence r egi ons for the pol es
and zer os, whi ch ar e graphed by
z ppl ot ( t h2z p( t h) , 1)
where the 1 i ndi cates how many standard-devi ati ons wi de the confi dence
i nterval i s. I f the confi dence r egi ons over l ap, tr y l ower model order s.
Thi s check i s especi al l y useful when the model s have been gener ated by ar x. As
menti oned under Compari ng Di fferent Str uctur es, the order s can be pushed
up due to the requi rement that 1/A(q) descri be the noi se char acter i sti cs.
Checki ng cancel l ati ons i n B(q)/A(q) then gi ves a good i ndi cati on of whi ch or der s
to chose from model structures l i ke ar max , oe , and bj .
Residual Analysis
The resi dual s associ ated wi th the data and a gi ven model , as i n (3.38), are
i deal l y whi te and i ndependent of the i nput for the model to cor rectl y descr i be
the system. The functi on
e = r es i d( z , t h)
computes the resi dual s e and per forms whi teness and i ndependence anal yses.
The auto cor rel ati on functi on of e and the cross corr el ati on functi on between e
and u ar e computed and di spl ayed for up to l ag 25. Al so di spl ayed are 99%
confi dence i nterval s for these vari abl es, assumi ng that e i s i ndeed whi te and
i ndependent of u.
The rul e i s that i f the corr el ati on functi ons go si gni fi cantl y outsi de these
confi dence i nterval s, do not accept the cor respondi ng model as a good
descri pti on of the system. Some qual i fi cati ons of thi s statement ar e necessary:
Model str uctur es l i ke the OE str ucture (3.19) and methods l i ke the I V
method (3.41) focus on the dynami cs G and l ess about the noi se pr oper ti es H.
I f you ar e i nterested pri mari l y i n G, focus on the i ndependence of e and u
rather than the whi teness of e .
Corr el ati on between e and u for negati ve l ags, or curr ent affecti ng
future , i s an i ndi cati on of output feedback. Thi s i s not a reason to r eject
the model . Correl ati on at negati ve l ags i s of i nterest, si nce certai n methods
do not wor k wel l when feedback i s pr esent i n the i nput-output data, (see
e t ( )
u t ( )
3-53
Deal i ng wi th Data on page 3-58), but concentrate on the posi ti ve l ags i n the
cross-cor rel ati on pl ot for model val i dati on pur poses.
When usi ng the ARX model (3.15), the l east-squares procedure
automati cal l y makes the cor rel ati on between and zero for
, , , for the data used for the esti mati on.
As part of the val i dati on pr ocess, you can graph the resi dual s usi ng
pl ot ( e )
for a si mpl e vi sual i nspecti on of i rr egul ari ti es and outl i er s. (See al so Deal i ng
wi th Data on page 3-58.)
Noise-Free Simulations
To check whether a model i s capabl e of repr oduci ng the observed output when
dri ven by the actual i nput, you can r un a si mul ati on:
y h = i ds i m( u, t h)
pl ot ( [ y y h] )
The same r esul t i s obtai ned by
c ompar e ( [ y, u] , t h)
I t i s a much tougher and reveal i ng test to per for m thi s si mul ati on, as wel l as
the resi dual tests, on a fresh data set [ y u] that was not used for the esti mati on
of the model t h. Thi s i s cal l ed cross validation. (Note that i v s t r uc forms the
squared di ffer ence of y and y h for I V-computed model s t h.)
Assessing the Model Uncertainty
The esti mated model i s al ways uncertai n, due to di sturbances i n the obser ved
data, and due to the l ack of an absol utel y corr ect model structure. The
var i abi l i ty of the model that i s due to the random di stur bances i n the output i s
esti mated by most of the esti mati on procedures, and i t can be di spl ayed and
i l l umi nated i n a number of ways. Thi s var i abi l i ty answer s the questi on of how
di ffer ent can the model be i f I repeat the i denti fi cati on procedure, usi ng the
same model str ucture, but wi th a di ffer ent data set that uses the same i nput
sequence. I t does not account for systemati c err ors due to an i nadequate choi ce
of model structure. Ther e i s no guar antee that the true system l i es i n the
confi dence i nter val .
e t ( ) u t k ( )
k nk = nk 1 + nk nb 1 +
3 Tutori al
3-54
The uncertai nty i n the frequency r esponse i s cal cul ated wi th
[ g, phi v ] = t h2f f ( t h)
and can subsequentl y be gr aphed wi th bodepl ot . The uncer tai nty i n the ti me
r esponse i s di spl ayed by
i ds i ms d( u, t h)
Ten possi bl e model s are dr awn fr om the asymptoti c di stri buti on of the model
t h. The response of each of them to the i nput u i s gr aphed on the same di agram.
The uncertai nty of these responses concerns the external , i nput-output
pr oper ti es of the model . I t r efl ects the effects of i nadequate exci tati on and the
pr esence of di sturbances.
You can al so di rectl y get the standar d devi ati on of the si mul ated resul t by
[ ys i m, y s i ms d] = i ds i m( u, t h)
The uncertai nty i n i nter nal r epr esentati ons i s mani fested i n the covar i ance
matri x of the esti mated parameter s,
pr e s e nt ( t h)
and i n the standard devi ati ons of the pol e- and zero-l ocati ons, whi ch ar e
computed wi th
z epo = t h2z p( t h)
and di spl ayed usi ng z ppl ot . Large uncer tai nti es i n these r epr esentati ons ar e
caused by excessi vel y hi gh model or ders, i nadequate exci tati on, or bad
si gnal -to-noi se r ati os.
Comparing Different Models
I t i s a good i dea to di spl ay the model properti es i n terms of quanti ti es that have
more physi cal meani ng than the parameter s themsel ves. Bode pl ots, zer o-pol e
pl ots, and model si mul ati ons al l gi ve a sense of the properti es of the system
that have been pi cked up by the model .
I f several model s of di fferent char acter s gi ve ver y si mi l ar Bode pl ots i n the
frequency range of i nterest, you can be fai rl y confi dent that these must refl ect
features of the tr ue, unknown system. You can then choose the si mpl est model
among these.
3-55
A typi cal i denti fi cati on sessi on i ncl udes esti mati on i n several di fferent
str uctur es, and compari sons of the model pr oper ti es. Here i s an exampl e:
a1 = ar x( z , [ 1 1] ) ;
[ gs , ns s ] = s pa( z ) ;
[ ga1, ns a1] = t h2f f ( a1) ;
bodepl ot ( [ gs ga1] )
bodepl ot ( [ ns s ns a1] )
z pa1 = t h2z p( a1) ;
am2 = ar max ( z , [ 2 2 2 1] ) ;
[ gam2, ns am2] = t h2f f ( am2) ;
bodepl ot ( [ gs gam2] )
z pam2 = t h2z p( am2) ;
z ppl ot ( z pf or m( z pa1, z pam2) )
Conditioning of the Prediction Error Gradient
When the model or der s i n (3.23) ar e over esti mated, so that a pol e-zero
cancel l ati on can take pl ace i n the model , the predi cti on err or gr adi ent
theor eti cal l y becomes rank defi ci ent. The matri x that i s i nverted when
esti mati ng the covar i ance matri x becomes si ngul ar , and the Gauss-Newton
sear ch di r ecti on becomes ambi guous.
Due to the hi gh numer i c pr eci si on i n MATLAB, you ar e unl i kel y to encounter
messages about si ngul ar and rank defi ci ent matr i ces. I nstead, over esti mated
model order s usual l y show up as l arge esti mated par ameter var i ances and
l ar ge norms of the Gauss-Newton vector (al though onl y mi nor decr eases i n the
cr i teri on val ue resul t). Consequentl y, these are good i ndi cator s that you have
gone too far i n i ncr easi ng the model orders. See al so Some Speci al Topi cs on
page 3-68.
Selecting Model Structures for Multivariable
Systems
Mul ti vari abl e systems ar e often mor e di ffi cul t to model . Some basi c aspects
and advi ce were gi ven i n The Basi c Steps of System I denti fi cati on on page
1-10. The gr aphi cal user i nter face (GUI ) offer s parti cul arl y useful suppor t for
the mul ti var i abl e case. I n thi s secti on we gi ve some mor e techni cal comments
about the i denti fi cati on of mul ti var i abl e systems.
3 Tutori al
3-56
The basi c comments gi ven so far i n thi s secti on al so appl y to such systems.
Ther e ar e, however , a l ar ge number of possi bl e str uctur es for systems wi th
sever al outputs, and systemati c tests of the many possi bi l i ti es are i mpracti cal .
Thi s pr obl em i s a di ffi cul t one, and for a mor e comprehensi ve tr eatment, refer
to Appendi x 4.A of Ljung (1987).
Fi r st of al l , physi cal i nsi ght i s mor e i mportant than anythi ng el se. Whenever
there i s pri or knowl edge suffi ci ent to form physi cal l y par ametr i zed state-space
model s, you shoul d test that. Even l acki ng mor e pr eci se knowl edge, some
physi cal i nsi ght mi ght hel p you to come up wi th fi rst suggesti ons of or ders and
del ays.
For mul ti -output bl ack-box model s, i t i s easi est to fi r st try state-space model s
usi ng n4s i d for the model esti mati on.
Mul ti vari abl e ARX model s ar e al so easy to deal wi th. When bui l di ng such
model s, a si mpl e start-up pr ocedur e i s to tr y ar x wi th a structure that i s fi l l ed
wi th parameter s. Then consi der those esti mates that are of the same
magni tude as thei r standard devi ati ons, and try order s and del ays that
automati cal l y set them to zer o. Note that for ar x each r ow i s esti mated
i ndependentl y of the others. Changi ng or ders and del ays associ ated wi th
output number i (i .e. the i -th r ow of na, nb, and nk) does not change the
par ameter esti mates associ ated wi th the other r ows. When a r easonabl e
structure has been found, try i v4 wi th i t and eval uate the model s i n the usual
ways.
I f the si gnal to noi se l evel i s not good, and i t i s i mpor tant to have model s that
descri be the noi se character i sti cs, tr y state-space model s. (These are
equi val ent to mul ti var i abl e ARMAX model s.) Agai n, i t i s easi er to esti mate
state-space model s di rectl y wi thout speci fyi ng the parti cul ar str uctur e. Thi s i s
done usi ng n4s i d.
An al ternati ve i s to appl y the pr edi cti on er ror method usi ng canoni cal
state-space for ms. These ar e obtai ned by the command cans t ar t . Thi s defi nes
a canoni cal form structur e from the pseudo-observabi l i ty i ndi ces. These i ndi ces
form a vector wi th the same number of entri es as the number of outputs.
Loosel y speaki ng, i ndex number k descr i bes how many del ayed val ues of y
k

affect the cur rent val ue of y
k
. The sum of the i ndi ces i s equal to the order of the
3-57
system. The number of possi bl e pseudo-obser vabi l i ty i ndi ces for a system of
order n wi th p outputs i s
I t i s, however, r eassuri ng to know that al most ever y system of or der n can be
descr i bed i n a structure cor respondi ng to any set of pseudo-obser vabi l i ty
i ndi ces whose sum i s n. You can esti mate the order of the system (or, r ather ,
tr y several di fferent or der s) and pi ck any set of pseudo-obser vabi l i ty i ndi ces
cor respondi ng to that order . A defaul t choi ce of i ndi ces can be made by
cans t ar t i f onl y the order i s speci fi ed. Onl y i f the mi ni mi zati on i n pem shows
si gns of poor condi ti oni ng of the i nvol ved matri ces do you need to try other
i ndi ces.
Note that the canoni cal form parametr i zati ons cannot handl e i nput del ays. To
deal wi th speci fi c del ays from the i nput(s), shi ft the i nput sequences
accordi ngl y.
Al so note that wi th f i x par any canoni cal form parameter i zati on can be
tr ansfor med to a cor respondi ng output-er ror structure, by fi xi ng the matri x K
to zer o.
n
p ,
_
3 Tutori al
3-58
9. Dealing with Data
Extracti ng i nformati on from data i s not an enti r el y str ai ghtforward task. I n
addi ti on to the deci si ons requi red for model structure sel ecti on and val i dati on,
the data may need to be handl ed car eful l y. Thi s secti on gi ves some advi ce on
handl i ng several common si tuati ons.
Offset Levels
When the data have been col l ected from a physi cal pl ant, they ar e typi cal l y
measured i n physi cal uni ts. The l evel s i n these r aw i nputs and outputs may not
match i n any consi stent way. Thi s wi l l force the model s to waste some
par ameters cor recti ng the l evel s.
Offsets are easi l y deal t wi th; al ways subtr act the mean l evel s fr om the i nput
and output sequences before the esti mati on. I t i s best i f the mean l evel s
cor respond to a physi cal equi l i br i um, but i f such val ues are not known, use the
sampl e means:
z = dt r e nd( z ) ;
Secti on 14.6 i n Ljung (1987) di scusses thi s i n more detai l . Wi th the dt r end
command, you can al so remove pi ece-wi se l i near tr ends.
Outliers
Real data ar e al so subject to possi bl e bad di sturbances; an unusual l y l ar ge
di stur bance, a temporary sensor or tr ansmi tter fai l ure, etc. I t i s i mportant that
such outl i ers ar e not al l owed to affect the model s too str ongl y.
The robusti fi cati on of the er ror cri ter i on (descr i bed under l i m i n Opti onal
Var i abl es on page 3-26) hel ps her e, but i t i s al ways good pr acti ce to exami ne
the resi dual s for unusual l y l ar ge val ues, and to go back and cri ti cal l y eval uate
the or i gi nal data r esponsi bl e for the l arge val ues. I f the raw data are obvi ousl y
i n er ror, they can be smoothed, and the esti mati on pr ocedur e r epeated.
Filtering Data
Dependi ng upon the appl i cati on, i nter est i n the model can be focused on
speci fi c frequency bands. Fi l ter i ng the data befor e the esti mati on, thr ough
fi l ter s that enhance these bands, i mproves the fi t i n the i nteresti ng regi ons.
Thi s i s used i n the System I denti fi cati on Tool box functi on i df i l t . For
3-59
exampl e, to enhance the data i n the fr equency band between 0.02
*
and
0.1
*
, execute
z f = i df i l t ( z , 5, [ 0. 02 0. 1] ) ;
Thi s computes and uses a fi fth order Butterworth bandpass fi l ter wi th
passband between the i ndi cated frequenci es. Chapter 13 i n Ljung (1987)
di scusses the r ol e of fi l teri ng i n more detai l .
The SI TB contai ns other useful commands for rel ated probl ems. For exampl e,
i f you want to l ower the sampl i ng r ate by a factor of 5, use
z 5 = i dr e s amp( z , 5) ;
Feedback in Data
I f the system was operati ng i n cl osed l oop (feedback from the past outputs to
the curr ent i nput) when the data were col l ected, some car e has to be exer ci sed.
Basi cal l y, al l the predi cti on err or methods work equal l y wel l for cl osed-l oop
data. Note, however , that the Output-Er ror model (3.19) and the Box-Jenki ns
model (3.21) are normal l y capabl e of gi vi ng a corr ect descr i pti on of the
dynami cs G, even i f H (whi ch equal s 1 for the output error model ) does not
al l ow a cor rect descri pti on of the noi se properti es. Thi s i s no l onger true for
cl osed-l oop data. You then need to model the noi se pr oper ti es car eful l y.
The spectr al anal ysi s method and the i nstrumental vari abl e techni ques (wi th
defaul t i nstruments) gi ve unr el i abl e r esul ts when appl i ed to cl osed-l oop data.
These techni ques shoul d be avoi ded when feedback i s pr esent.
To detect i f feedback i s pr esent, use the basi c method of appl yi ng c r a to
esti mate the i mpul se r esponse. Si gni fi cant val ues of the i mpul se response at
negati ve l ags i s a cl ear i ndi cati on of feedback. When a par ametri c model has
been esti mated and the r e s i d command i s appl i ed, a graph of the cor rel ati on
between r esi dual s and i nputs i s gi ven. Si gni fi cant corr el ati on at negati ve l ags
agai n i ndi cates output feedback i n the generati on of the i nput. Testi ng for
feedback i s, ther efor e, a natural par t of model val i dati on.
Delays
The sel ecti on of the del ay nk i n the model str uctur e i s a very i mportant step i n
obtai ni ng good i denti fi cati on r esul ts. You can get an i dea about the del ays i n
the system by the i mpul se response esti mate fr om c r a.
3 Tutori al
3-60
I ncorr ect del ays ar e al so vi si bl e i n parametri c model s. Under esti mated del ays
( nk too smal l ) show up as smal l val ues of l eadi ng esti mates, compared to
thei r standard devi ati ons. Overesti mated del ays (nk too l arge) ar e usual l y
vi si bl e as a si gni fi cant corr el ati on between the r esi dual s and the i nput at the
l ags corr espondi ng to the mi ssi ng terms.
A good pr ocedur e i s to star t by usi ng ar xs t r uc to test al l feasi bl e del ays
together wi th a second-order model . Use the del ay that gi ves the best fi t for
fur ther model i ng. When you have found an other wi se sati sfactory structure,
vary nk around the nomi nal val ue wi thi n the structure, and eval uate the
r esul ts.
b
k
b
k
3-61
10. Recursive Parameter Estimation
I n many cases i t may be necessary to esti mate a model on l i ne at the same ti me
as the i nput-output data i s r ecei ved. You may need the model to make some
deci si on on l i ne, as i n adapti ve contr ol , adapti ve fi l ter i ng, or adapti ve
predi cti on. I t may be necessar y to i nvesti gate possi bl e ti me vari ati on i n the
systems (or si gnal s) properti es dur i ng the col l ecti on of data. Terms l i ke
recursive identification, adaptive parameter estimation, sequential estimation,
and online algorithms are used for such al gori thms. Chapter 11 i n Ljung (1987)
deal s wi th such al gor i thms i n some detai l .
The Basic Algorithm
A typi cal r ecursi ve i denti fi cati on al gor i thm i s
Her e i s the parameter esti mate at ti me t, and i s the observed output
at ti me t. Moreover , i s a pr edi cti on of the val ue based on observati ons
up to ti me and al so based on the cur rent model (and possi bl y al so earl i er
ones) at ti me . The gai n deter mi nes i n what way the cur rent
predi cti on err or affects the update of the par ameter esti mate. I t i s
typi cal l y chosen as
where i s (an appr oxi mati on of) the gradi ent wi th respect to of .
The l atter symbol i s the predi cti on of accor di ng the model descr i bed by .
Note that model structures l i ke AR and ARX that corr espond to l i near
regressi ons can be wr i tten as
where the regression vector contai ns ol d val ues of obser ved i nputs and
outputs, and r epresents the true descri pti on of the system. Moreover ,
i s the noi se source (the i nnovati ons). Compar e wi th (3.15). The natural
predi cti on i s and i ts gr adi ent wi th respect to becomes
exactl y .

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 Tutori al
3-62
For model s that cannot be wr i tten as l i near regressi ons, you cannot recur si vel y
compute the exact predi cti on and i ts gr adi ent for the cur rent esti mate .
Then appr oxi mati ons and must be used i nstead. Secti on 11.4 i n
Ljung (1987) descr i bes sui tabl e ways of computi ng such appr oxi mati ons for
general model structures.
The matr i x that affects both the adaptati on gai n and the di r ecti on i n
whi ch the updates ar e made, can be chosen i n several di fferent ways. Thi s i s
di scussed i n the fol l owi ng secti on.
Choosing an Adaptation Mechanism and Gain
The most l ogi cal appr oach to the adaptati on probl em i s to assume a certai n
model for how the true par ameters change. A typi cal choi ce i s to descri be
these par ameters as a random wal k:
Here i s assumed to be whi te Gaussi an noi se wi th covari ance matr i x

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 that the under l yi ng descri pti on of the observati ons i s a l i near
regressi on (10.3). An opti mal choi ce of i n (10.1)-(10.2) can then be
computed from the Kal man fi l ter, and the compl ete al gori thm becomes
Her e i s the var i ance of the i nnovati ons i n (10.3): (a scal ar ).
The al gori thm (10.6) wi l l be cal l ed the Kal man Fi l ter (KF) Approach to
adaptati on, wi th drift matrix . See eq (11.66)-(11.67) i n Ljung (1987). The
al gor i thm i s enti rel y speci fi ed by , , , , and the sequence of data
, , , 2,. Even though the al gor i thm was moti vated for a l i near
regressi on model str uctur e, i t can al so be appl i ed i n the gener al case where
i s computed i n a di fferent way from (10.6b).
Another approach i s to di scount ol d measurements exponenti al l y, so that an
observati on that i s sampl es ol d car ri es a wei ght that i s of the wei ght of
the most recent observati on. Thi s means that the fol l owi ng functi on i s
mi ni mi zed r ather than (3.39):
at ti me t. Here i s cl ear l y i s a posi ti ve number 1. The measur ements that
ar e ol der than car ry a wei ght i n (10.7) that i s l ess than about 0.3.
Thi nk of as the memory horizon of the appr oach. Typi cal val ues
of ar e i n the 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 Tutori al
3-64
The cr i teri on (10.7) can be mi ni mi zed exactl y i n the l i near r egressi on case
gi vi ng the al gori thm (10.6abc) wi th the fol l owi ng choi ce of :
Thi s al gori thm wi l l be cal l ed the For getti ng Factor (FF) Appr oach to
adaptati on, wi th the forgetting factor . See eq (11.63) i n Ljung (1987). The
al gori thm i s al so known as RLS, recursive least squares i n the l i near regr essi on
case. Note that i n thi s appr oach gi ves the same al gor i thm as
i n the Kal man fi l ter appr oach.
A thi rd appr oach i s to al l ow the matri x to be a mul ti pl e of the i denti ty
matri x:
I t can al so be nor mal i zed wi th r espect to the si ze of :
See eqs (11.45) and (11.46), respecti vel y i n Ljung (1987). These choi ces of
move the updates of i n (10.1) i n the negati ve gradi ent di r ecti on (wi th respect
to ) of the cr i teri on (3.39). Therefore, (10.9) wi l l be cal l ed the Unnor mal i zed
Gradi ent (UG) Approach and (10.10) the Normal i zed Gr adi ent (NG) Appr oach
to adaptati on, wi th gai n . The gradi ent methods ar e al so known as LMS, least
mean squares i n the l i near regr essi on 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 System I denti fi cati on Tool box pr ovi des the fol l owi ng functi ons that
i mpl ement al l common recur si ve i denti fi cati on al gori thms for model str uctur es
i n the fami l y (6.1): r ar max, r ar x , r bj , r pem, r pl r , and r oe . They al l share the
fol l owi ng basi c syntax:
[ t hm, yh] = r f c n( z , nn, adm, adg)
Her e z contai ns the output-i nput data as usual . nn speci fi es the model
str uctur e, exactl y as for the cor respondi ng offl i ne al gori thm. The ar guments
adm and adg sel ect the adaptati on mechani sm and adaptati on gai n l i sted above.
adm = ' f f ' ; adg = l am
gi ves the for getti ng factor al gori thm (10.8), wi th forgetti ng factor l am.
adm = ' ug' ; adg = gam
gi ves the unnormal i zed gr adi ent approach (10.9) wi th gai n gam. Si mi l ar l y,
adm = ' ng' ; adg = gam
gi ves the normal i zed gai n approach (10.10). To obtai n the Kal man fi l ter
approach (10.6) wi th dri ft matr i x R1 enter
adm = ' kf ' ; adg = R1
The val ue of i s al ways 1. Note that the esti mates i n (10.6) ar e not affected
i f al l the matri ces and are scal ed by the same number . You can
ther efor e al ways scal e the ori gi nal probl em so that becomes 1.
The output ar gument t hm i s a matri x that contai ns the curr ent model s at the
di ffer ent sampl es. Row k of t hm contai ns the model par ameters, i n al phabeti cal
order at sampl e ti me k, cor respondi ng to r ow k i n the data matr i x z . The
orderi ng of the par ameters i s the same as t h2par woul d gi ve when appl i ed to
the theta for mat of a corr espondi ng offl i ne model .
The output ar gument yh i s a col umn vector that contai ns, i n row k, the
predi cted val ue of , based on past observati ons and cur rent model . The
vector yh thus contai ns the adapti ve predi cti ons of the outputs, and i s useful
al so for noi se cancel l i ng and other adapti ve fi l teri ng appl i cati ons.
The functi ons al so have opti onal i nput ar guments that al l ow the speci fi cati on
of , and . Opti onal output ar guments i ncl ude the l ast val ue of
the matr i x P and of the vector .
R
2

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

3 Tutori al
3-66
Now, r ar x i s a recur si ve var i ant of ar x; si mi l ar l y r ar max i s the recursi ve
counter part of ar max and so on. Note, though that r ar x does not handl e
mul ti -output systems, and r pe m does not handl e state-space structures.
The functi on r pl r i s a var i ant of r pe m, and uses a di fferent appr oxi mati on of
the gradi ent . I t i s known as the recursive pseudo-linear regression approach,
and contai ns some wel l known speci al cases. See equati on (11.57) i n Ljung
(1987). When appl i ed to the output er ror model ( nn=[ 0 nb 0 0 nf nk] ) i t
r esul ts i n methods known as HARF ( 'f f 'c as e) and SHARF ('ng'cas e). The
common extended least squares (ELS) method i s an r pl r al gori thm for the
ARMAX model ( nn=[ na nb nc 0 0 nk] ) .
The fol l owi ng exampl e shows a second or der output err or model , whi ch i s bui l t
r ecur si vel y and i ts ti me var yi ng par ameter esti mates pl otted as functi ons of
ti me:
t hm = r oe( z , [ 2 2 1] , ' f f ' , 0. 98) ;
pl ot ( t hm)
A second order ARMAX model i s recur si vel y esti mated by the ELS method,
usi ng Kal man fi l ter adaptati on. The r esul ti ng stati c gai ns of the esti mated
model s are then pl otted as a functi on of ti me:
[ N, dum] =s i z e ( z ) ;
t hm = r pl r ( z , [ 2 2 2 0 0 1] , ' kf ' , 0. 01ey e( 6) ) ;
nums = s um( t hm( : , 3: 4) ' ) ' ;
dens = one s ( N, 1) +s um( t hm( : , 1: 2) ' ) ' ;
s t g = nums . /de ns ;
pl ot ( s t g)
So far, the exampl es of appl i cati ons where a batch of data i s exami ned cover
studi es of the vari abi l i ty of the system. The al gori thms are, however, al so
pr epar ed for tr ue onl i ne appl i cati ons, wher e the computed model i s used for
some onl i ne deci si on. Thi s i s accompl i shed by stori ng the update i nfor mati on
i n and i nfor mati on about past data i n (and )
and usi ng that i nfor mati on as i ni ti al data for the next ti me step. The fol l owi ng
exampl e shows the recur si ve l east-squar es al gori thm bei ng used on l i ne (just
to pl ot one curr ent par ameter esti mate):
%I ni t i al i z at i on, f i r s t i /o pai r y, u ( s cal ar s )
[ t h, y h, P, phi ] = r ar x( [ y u] , [ 2 2 1] , ' f f ' , 0. 98) ;
axi s ( [ 1 50 2 2] )
pl ot ( 1, t h( 1) , ' ' ) , hol d

t 1 ( ) P t 1 ( ) , t 1 ( ) t 1 ( )
3-67
%The onl i ne l oop:
f or k = 2: 50
% At t i me k r e ce i v e y, u
[ t h, y h, P, phi ] = . . .
r ar x( [ y u] , [ 2 2 1] , ' f f ' , 0. 98, t h' , P, phi ) ;
pl ot ( k, t h( 1) , ' ' )
e nd
Executi ng i dde mo 6 i l l ustrates the recursi ve al gori thms.
Segmentation of Data
Someti mes the system or si gnal exhi bi ts abr upt changes duri ng the ti me when
the data i s col l ected. I t may be i mpor tant i n certai n appl i cati ons to fi nd the
ti me i nstants when the changes occur and to devel op model s for the di fferent
segments dur i ng whi ch the system does not change. Thi s i s the segmentation
problem. Faul t detecti on i n systems and detecti on of tr end breaks i n ti me
seri es can ser ve as two exampl es of typi cal pr obl ems.
The System I denti fi cati on Tool box offer s the functi on s egme nt to deal wi th the
segmentati on pr obl em. The basi c syntax i s
t hm = s egme nt ( z , nn)
wi th a for mat l i ke r ar x or r ar max . The matri x t hm contai ns the pi ecewi se
constant model s i n the same format as for the al gori thms descr i bed ear l i er i n
thi s secti on.
The al gori thm that i s i mpl emented i n s egme nt i s based on a model descri pti on
l i ke (10.4), where the change ter m i s zero most of the ti me, but now and
then i t abruptl y changes the system par ameters . Several Kal man fi l ters
that esti mate these par ameters ar e r un i n paral l el , each of them cor respondi ng
to a par ti cul ar assumpti on about when the system actual l y changed. The
rel ati ve r el i abi l i ty of these assumed system behavi or s i s constantl y judged, and
unl i kel y hypotheses are repl aced by new ones. Opti onal arguments al l ow the
speci fi cati on of the measur ement noi se vari ance i n (10.3), of the probabi l i ty
of a jump, of the number of paral l el model s i n use, and al so of the guaranteed
l i fespan of each hypothesi s. See i dde mo 7 i n Chapter 4, "Command Reference"
al so.
w t ( )

0
t ( )
R
2
3 Tutori al
3-68
11. Some Special Topics
Thi s secti on descri bes a number of mi scel l aneous topi cs. Most of the
i nfor mati on her e i s al so covered i n other par ts of the manual , but si nce
manual s sel dom ar e r ead from the begi nni ng, you can al so check i f a par ti cul ar
topi c i s br ought up here.
Time Series Modeling
When there i s no i nput pr esent, the general model (6.1) reduces to the ARMA
model structure:
Wi th you have an AR model str uctur e.
Basi cal l y al l commands sti l l appl y to these ti me ser i es model s, but wi th natur al
modi fi cati ons. They are l i sted as fol l ows:
t h = pol y2t h( A, [ ] , C, 1, [ ] , l am)
y = i ds i m( e, t h)
Spectral anal ysi s (e t f e and s pa) and the t h2f f functi on now r etur n the
spectral esti mate of y as thei r fi rst output arguments:
PHI Y = t h2f f ( t h)
PHI Y = s pa( y )
PERI OD = e t f e( y)
Note that e t f e gi ves the periodogram esti mate of the spectrum.
ar max and ar x work the same way, but need no speci fi cati on of nb and nk:
t h = ar x ( y , na)
t h = ar max ( y , [ na nc ] )
Note that ar x al so handl es mul ti var i ate si gnal s. State-space model s of ti me
ser i es can be bui l t si mpl y by speci fyi ng B = [ ] , D = [ ] i n mods t r uc , mf 2t h, and
ms 2t h. r es i d wor ks the same way for ti me ser i es model s, but does not provi de
any i nput-resi dual corr el ati on pl ots:
e = r es i d( y, t h)
A q ( )y t ( ) C q ( )e t ( ) =
(11.1)
C q ( ) 1 =
3-69
I n addi ti on there are two commands that are speci fi cal l y constructed for
bui l di ng scal ar AR model s of ti me seri es. One i s
t h = ar ( y , na)
whi ch has an opti on that al l ows you to choose the al gori thm fr om a gr oup of
sever al popul ar techni ques for computi ng the l east-squar es AR model . Among
these ar e Burgs method, a geometri c l atti ce method, the Yul e-Wal ker
approach, and a modi fi ed covar i ance method. See Chapter 4, "Command
Refer ence" for detai l s. The other command i s
t h = i v ar ( y , na)
whi ch uses an i nstrumental vari abl es techni que to compute the AR part of a
ti me seri es.
Fi nal l y, when no i nput i s pr esent, the functi ons bj , i v , i v 4, and oe ar e not
defi ned.
Her e i s an exampl e where you can si mul ate a ti me seri es, compar e spectral
esti mates and covar i ance functi on esti mates, and al so the predi cti ons of the
model .
t s 0 = pol y2t h( [ 1 1. 5 0. 7] , [ ] ) ;
% The t r ue s pe ct r um:
s pe 0 = t h2f f ( t s 0) ;
i r = i ds i m( [ 1; z e r os ( 24, 1) ] , t s 0) ;
% The t r ue c ov ar i anc e f unct i on:
Ry0 = c onv( i r , i r ( 25: 1: 1) ) ;
e = r andn( 200, 1) ;
y = i ds i m( e , t s 0) ;
pl ot ( y)
per = e t f e( y ) ;
s pe h = s pa( y ) ;
f f pl ot ( [ per , s peh, s pe 0] )
% A s ec ond or der AR model :
t s 2 = ar ( y, 2) ;
s p2 = t h2f f ( t s 2) ;
f f pl ot ( [ s pe h, s p2, s pe 0, 3] )
% The c ov ar i ance f unc t i on e s t i mat e s :
Ryh = c ov f ( y , 24) ;
i r 2 = i ds i m( [ 1; z er os ( 24, 1) ] , t s 2) ;
Ry2 = c onv( i r 2, i r 2( 25: 1: 1) ) ;
3 Tutori al
3-70
pl ot ( [ 24: 24] one s ( 1, 3) , [ Ryh, Ry2, Ry0] )
% The pr edi c t i on abi l i t y of t he mode l :
c ompar e ( y, t h2, 5)
The Sampling Interval
The System I denti fi cati on Tool box assumes a nor mal i zed sampl i ng i nter val of
, unl ess you speci fy otherwi se. Thi s means that the fr equency uni t
becomes r adi ans per sampl i ng i nterval , and that al l the tr ansfor mati ons
between conti nuous- and di scr ete-ti me model s gi ve numeri cal parameter
val ues cor respondi ng to the uni t ... per sampl i ng i nter val rather than ... per
second. To obtai n corr ect physi cal uni ts i n these cases, the sampl i ng i nterval
must be speci fi ed accor di ngl y.
Al l model s i n the theta format contai n the sampl i ng i nter val T as the ( 1, 2)
el ement. I t can be r ead by
T = get t ( t h)
and i t i s changed by
t hnew = s e t t ( t hol d, T)
Note that the val ue of T i s just changed; no transformati on of parameter s i s
carr i ed out by s et t .
A negati ve val ue of T i ndi cates that the corr espondi ng model i s gi ven i n
conti nuous ti me. The absol ute val ue of T denotes, i n that case, the sampl i ng
i nterval of the data, for whi ch thi s model was esti mated. Thi s i s al so the
sampl i ng i nterval used when the model i s used for si mul ati on or pr edi cti on. Al l
other transformati ons (to the fr equency functi on, to pol es and zer os, to transfer
functi ons and to state-space matri ces) wi l l be i n ter ms of the conti nuous-ti me
model . I n the case of t h2f f , abs ( T) i s used for the defaul t choi ce of fr equency
r ange.
You can speci fy the sampl i ng i nterval as an opti onal ar gument i n al l the
functi ons that create theta structures. I t i s general l y the l ast ar gument. Note
that i n ms 2t h and mf 2t h, i t i s the sampl i ng i nterval of the data that you need
to speci fy, even i f the model i tsel f i n parametri zed i n conti nuous ti me. I f the
i ni ti al structure i n pem, ar max, bj , and oe i s gi ven by a matri x t h i n the theta
format, the defaul t val ue of T i s the one gi ven by t h. An expl i ci tl y gi ven
sampl i ng i nterval (as an argument to pe m, for exampl e) overr i des the defaul t
val ue i n t h.
T 1 =
3-71
The sampl i ng i nter val T i s al so used by et f e, s pa, and t h2f f to determi ne
defaul t frequency r anges. For di screte-ti me systems, thi s defaul t i s [ 1: 128] /
128
*
pi /T and for conti nuous-ti me systems, i t i s
l ogspace(l og10(pi /abs(T)/100),l og10(10
*
pi /abs(T)),128).
Di scr ete-ti me defaul t fr equency ranges can be changed by s et t , l i ke i n
g = s pa( z ) ;
g = s et t ( g, T) ;
Out of Memory
I f you r un out of memor y on computer s wi th memor y l i mi tati ons, cl ear
unnecessar y var i abl es and use the pac k functi on. When you ar e usi ng the
i ter ati ve pr ocedur es ar max, bj , oe , and pe m, i t i s a good i dea to use pac k to
cl ean up after the star t-up esti mati on pr ocedur e usi ng, for exampl e
t h = ar max( z , nn, 0) ;
pac k
t h = ar max( z , t h) ;
Al l the rel evant System I denti fi cati on Tool box functi ons have an opti onal
var i abl e MAXSI ZE that control s the memory/speed trade-off and i s set
automati cal l y, based upon the best val ues for the machi ne you are usi ng. The
routi nes do not al l ow any matri x of si ze l ar ger than MAXSI ZE to form. I nstead
they go i nto for-l oops to handl e the si tuati on.
The defaul t val ue of MAXSI ZE i s set i n the M-fi l e i dms i z e. Theor eti cal l y,
MAXSI ZE i s 8188 on the smal l er machi nes, but si nce many matr i ces may for m,
i t best to set the defaul t val ue for these machi nes to MAXSI ZE = 4096.
I f you have memory probl ems, you can use the argument MAXSI ZE, or edi t
i dms i z e , wi th val ues l ower than the defaul t.
I f you have a l arge amount of i nput-output data, so that the memory del i mi ter
gi ves you a sl ower r esponse, use a por ti on of the data to cal cul ate a good i ni ti al
condi ti on for the mi ni mi zati on, for exampl e
t h = ar max( z ( 1: 500, : ) , [ na nb nc ] , 10, 0. 1) ;
t h = ar max( z , t h) ;
3 Tutori al
3-72
On a smal l machi ne, i f you have col l ected more than 8188 data poi nts so that
you cannot for m z =[ y u] , no memory hel p i s offer ed. You then have to bui l d
separ ate model s for separ ate par ts of the data and r econci l e the model s.
Memory-Speed Trade-Offs
On machi nes wi th no for mal memor y l i mi tati ons, i t i s sti l l of i nterest to
moni tor the si zes of the matr i ces that are formed. The typi cal si tuati on i s when
an over determi ned set of l i near equati ons i s sol ved for the l east-squares
sol uti on. The sol uti on ti me depends, of course, on the di mensi ons of the
cor respondi ng matr i x. The number of r ows cor responds to the number of
obser ved data, whi l e the number of col umns cor responds to the number of
esti mated par ameters. The argument MAXSI ZE used wi th al l the r el evant
M-fi l es, guar antees that no matr i x wi th more than MAXSI ZE el ements i s for med.
Lar ger data sets and/or hi gher or der model s are handl ed by for-l oops. For -l oops
gi ve l i near i ncr ease i n ti me when the data record i s i ncreased, pl us some
over head (and somewhat wor se numer i cal pr oper ti es).
I f you regul ar l y work wi th l arge data sets and/or hi gh order model s, i t i s
advi sabl e to tai l or the memory and speed trade-off to your machi ne by choosi ng
the defaul t val ue of MAXSI ZE i n the M-fi l e i dms i z e car eful l y. Note that thi s
val ue i s al l owed to depend on the number of rows and col umns of the matr i ces
formed.
Regularization
The Gauss-Newton di r ecti on i s usual l y defi ned as
where i s the gradi ent matri x of the pr edi cti ons wi th r espect to the
par ameters, and e i s the vector of r esi dual s.
When the i nverted matri x i s i l l -condi ti oned, you can add a smal l fr acti on of the
i denti ty matr i x to i t. Thi s i s cal l ed regularization. See Ljung (1987), Secti on
10.2.
The routi nes i n the System I denti fi cati on Tool box compute the Gauss-Newton
di r ecti on wi th
g=ps i \e
gn

( )
1
= *
*
*e
N n
N 1
3-73
whi ch uses the MATLAB mechani sm for deal i ng wi th underdeter mi ned,
overdeter mi ned systems of equati ons. An advanced ver si on of regul ari zati on i s
thus automati cal l y i ncl uded.
Because of the hi gh pr eci si on of MATLAB, regul ari zati on i s not i nvoked easi l y.
You may see some ver y l ar ge nor m of gnv ec t or val ues before you see the
MATLAB message that the matr i x i s rank defi ci ent.
A l arge val ue for the gnv ec t or suggests that you decr ease the model orders.
However, i f you ar e i nterested i n how the r egul ari zati on works, you can
decr ease the val ue of the machi ne epsi l on. For exampl e, set
e ps = 0. 000001
and run the i denti fi cati on agai n.
Local Minima
The i ter ati ve sear ch procedures i n pe m, ar max, oe, and bj l ead to theta val ues
cor respondi ng to a l ocal mi ni mum of the cr i teri on functi on (3.39). Nothi ng
guarantees that thi s l ocal mi ni mum i s al so a gl obal mi ni mum. The star t-up
procedure for bl ack-box model s i n these routi nes i s, however, r easonabl y
effi ci ent i n gi vi ng i ni ti al esti mates that l ead to the gl obal mi ni mum.
I f there i s an i ndi cati on that a mi ni mum i s not as good as you expected, try
starti ng the mi ni mi zati on at sever al di ffer ent i ni ti al condi ti ons, to see i f a
smal l er val ue of the l oss functi on can be found.
Initial Parameter Values
When onl y or ders and del ays ar e speci fi ed, the functi ons ar max , bj , oe, and pe m
use a start-up pr ocedur e to produce i ni ti al val ues. The star t-up procedure goes
through two to four l east squares and i nstrumental vari abl es steps. I t i s
reasonabl y effi ci ent i n that i t usual l y saves sever al i terati ons i n the
mi ni mi zati on phase. Someti mes i t may, however , pay to use other i ni ti al
condi ti ons. For exampl e, you can use an i v 4 esti mate computed ear l i er as an
i ni ti al condi ti on for esti mati ng an output-err or model of the same str uctur e:
t h1 = i v4( z , [ na nb nk] ) ;
[ a, b] = t h2pol y( t h1) ;
t h2 = pol y2t h( 1, b, 1, 1, a) ;
t h3 = oe( z , t h2) ;
3 Tutori al
3-74
Another exampl e i s when you want to tr y a model wi th one more del ay (for
exampl e, thr ee i nstead of two) because the l eadi ng b-coeffi ci ent i s qui te smal l :
t h1 = ar max( z , [ 3 3 2 2] ) ;
[ a, b, c] = t h2pol y( t h1) ;
b( 3) = 0;
t h2 = pol y 2t h( a, b, c ) ;
t h3 = ar max( z , t h2) ;
I f you decrease the number of del ays, r emember that pol y2t h stri ps away
l eadi ng zer os. Suppose you go fr om three to two del ays i n the above exampl e:
t h1 = ar max( z , [ 3 3 2 3] ) ;
[ a, b, c] = t h2pol y( t h1) ;
b( 3) = 0. 00001;
t h2 = pol y 2t h( a, b, c ) ;
t h3 = ar max( z , t h2) ;
Note that when constructi ng home-made i ni ti al condi ti ons, the condi ti ons
must corr espond to a stabl e pr edi ctor (C and F bei ng Hurwi tz pol ynomi al s),
and that they shoul d not contai n any exact pol e-zero cancel l ati ons.
For state-space and mul ti -output model s, you must pr ovi de the i ni ti al
par ameter val ues ei ther when defi ni ng the str uctur e i n ms 2t h or mf 2t h, or wi th
the speci al i ni ti al i zati on functi on t hi ni t . The basi c approach i s to use physi cal
i nsi ght to choose i ni ti al val ues of the parameter s wi th physi cal si gni fi cance,
and tr y some di fferent (r andomi zed) i ni ti al val ues for the other s. For model s
par ametri zed i n canoni cal state-space for m, use c ans t ar t to get star ted.
Linear Regression Models
A l i near regr essi on model i s of the type
where and ar e measured vari abl es and r epr esents noi se. Such
model s are very useful i n most appl i cati ons. They al l ow, for exampl e, the
i ncl usi on of nonl i near effects i n a si mpl e way. The System I denti fi cati on
Tool box functi on ar x al l ows an ar bi trary number of i nputs. You can ther efor e
handl e arbi trar y l i near regr essi on model s wi th ar x . For exampl e, i f you want
to bui l d a model of the type
y t ( )
T
t ( ) e t ( ) + =
(11.2)
y t ( ) t ( ) e t ( )
3-75
cal l
z = [ y ones ( u) u u. ^2 u. ^3] ;
t h = ar x( z , [ 0 1 1 1 1 0 0 0 0] )
Thi s i s formal l y a model wi th one output and four i nputs, but al l the model
testi ng i n ter ms of compar e , i ds i m, and r e s i d oper ate i n the natur al way for
the model (11.2), once the data matri x z i s defi ned as above.
Note that when pe m i s appl i ed to l i near regr essi on structures, by defaul t a
robusti fi ed quadr ati c cri ter i on i s used. The sear ch for a mi ni mum of the
cr i teri on functi on i s car ri ed out by i ter ati ve sear ch. Normal l y, use thi s
robusti fi ed cr i teri on. I f you i nsi st on a quadrati c cr i teri on, then set the
ar gument l i m i n pe m to zer o. Then pe m al so conver ges i n one step.
Spectrum Normalization and the Sampling Interval
I n the functi on s pa the spectr um esti mate i s nor mal i zed wi th the sampl i ng
i nter val T as
where
(See al so (3.3)). The normal i zati on i n e t f e i s consi stent wi th (11.4). Thi s
nor mal i zati on means that the uni t of i s power per radi ans/ti me uni t
and that the fr equency scal e i s r adi ans/ti me uni t. You then 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 Tutori al
3-76
I n MATLAB l anguage, therefore, you have wher e
s p = s pa( y ) ; s p = s et t ( s p, T) ;
[ om, PHI Y] = ge t f f ( s p) ;
S1 = s um( PHI Y) /l engt h( PHI Y) /T;
S2 = s um( y . ^2) /l engt h( y ) ;
Note that PHI Y contai ns between and wi th a frequency
step of /T /(l e ngt h(PHI Y)). The sum S1 i s, therefore, the r ectangul ar
appr oxi mati on of the i ntegr al i n (11.5). The spectr um nor mal i zati on di ffers
from the one used by s pe ct r um i n the Si gnal Pr ocessi ng Tool box, and the above
exampl e shows the natur e of the di fference.
The nor mal i zati on wi th T i n (11.4) al so gi ves consi stent resul ts when ti me
ser i es are deci mated. I f the energy above the Nyqui st fr equency i s removed
before deci mati on (as i s done i n i dr es amp), the spectr al esti mates coi nci de;
other wi se you see fol di ng effects.
Try the fol l owi ng sequence of commands:
t h0 = pol y 2t h( 1, [ ] , [ 1 1 1 1] ) ;
% 4t h or der MApr oce s s
y = i ds i m( r andn( 2000, 1) , t h0) ;
g1 = s pa( y ) ;
g2 = s pa( y ( 1: 4: 2000) ) ; g2 = s e t t ( g2, 4) ;
f f pl ot ( [ g1 g2] ) % Fol di ng e f f e ct s
g3 = s pa( i dr es amp( y , 4) ) ; % Pr e f i l t er appl i e d
g3 = s e t t ( g3, 4) ;
f f pl ot ( [ g1 g3] ) % No f ol di ng
For a parametr i c noi se (ti me seri es) model
the spectrum i s computed as
whi ch i s consi stent wi th (11.4) and (11.5). Thi nk of as the spectral densi ty
of the whi te noi se source .
When a par ametri c noi se model i s transfor med between conti nuous ti me and
di screte ti me and/or resampl ed at another sampl i ng rate, the functi ons
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
t hc 2t hd and t hd2t hc i n the System I denti fi cati on Tool box use formul as that
ar e formal l y corr ect onl y for pi ecewi se constant i nputs. (See (3.32)). Thi s
approxi mati on i s good when T i s smal l compar ed to the bandwi dth of the noi se.
Duri ng these tr ansfor mati ons the vari ance of the i nnovati ons i s
changed so that the spectr al densi ty T
.
remai ns constant. Thi s has two
effects:
The spectrum scal i ngs ar e consi stent, so that the noi se spectrum i s
essenti al l y i nvari ant (up to the Nyqui st fr equency) wi th r espect to
r esampl i ng.
Si mul ati ons wi th noi se usi ng i ds i m has a hi gher noi se l evel when per for med
at faster sampl i ng.
Thi s l atter effect i s wel l i n l i ne wi th the standar d descri pti on that the
under l yi ng conti nuous-ti me model i s subject to conti nuous-ti me whi te noi se
di sturbances (whi ch have i nfi ni te, i nstantaneous var i ance), and appropri ate
l ow-pass fi l teri ng i s appl i ed before sampl i ng the measurements. I f thi s effect i s
unwanted i n a par ti cul ar appl i cati on, scal e the noi se source appr opri atel y
before appl yi ng i ds i m.
Note the fol l owi ng cauti ons rel ati ng to these tr ansfor mati ons of noi se model s.
Conti nuous-ti me noi se model s must have a whi te noi se component. Otherwi se
the underl yi ng state-space model , whi ch i s formed and used i n t hc2t hd and
t hd2t hc , i s i l l -defi ned. War ni ngs about thi s are i ssued by pol y 2t h and these
functi ons. Modi fy the C-pol ynomi al accordi ngl y. Make the degree of the moni c
C-pol ynomi al i n conti nuous ti me equal to the sum of the degrees of the moni c
A- and D-pol ynomi al s; i .e., i n conti nuous ti me
l engt h( C) 1 = ( l engt h( A) 1) +( l e ngt h( D) 1) .
Interpretation of the Loss Function
The val ue of the quadrati c l oss functi on i s gi ven as el ement 1,1 i n the theta
format, and al so di spl ayed by pr e s e nt . For mul ti -output systems, thi s i s equal
to the deter mi nant of the esti mated covari ance matr i x of the i nnovati ons.
For most model s the esti mated covari ance matri x of the i nnovati ons i s obtai ned
by formi ng the corr espondi ng sampl e mean of the pr edi cti on er ror s, computed
(usi ng pe) fr om the model wi th the data for whi ch the model was esti mated.
e t ( )

3 Tutori al
3-78
Note the di scr epancy between thi s val ue and the val ues shown dur i ng the
mi ni mi zati on pr ocedure (i n pe m, ar max , bj , or oe , si nce these ar e the val ues of
the robustified l oss functi on (see under l i m i n Secti on 5).
Be car eful when compari ng l oss functi on val ues between di fferent structures
that use ver y di ffer ent noi se model s. An Output-Er ror model may have a better
i nput-output fi t, even though i t di spl ays a hi gher val ue of the l oss functi on
than, say, an ARX model .
Note that for ARX model s computed usi ng i v 4, the covar i ance matri x of the
i nnovati ons i s esti mated usi ng the pr ovi si onal noi se model that i s used to for m
the opti mal i nstr uments. The l oss functi on therefore di ffer s fr om what woul d
be obtai ned i f you computed the predi cti on err or s usi ng the model di r ectl y fr om
the data. I t i s sti l l the best avai l abl e esti mate of the i nnovati ons covar i ance. I n
par ti cul ar , i t i s di ffi cul t to compar e the l oss functi on i n an ARX model
esti mated usi ng ar x and one esti mated usi ng i v 4.
Enumeration of Estimated Parameters
I n some cases the par ameters of a model ar e gi ven just as an or der ed l i st. Thi s
i s the case for t h2par , and al so when onl i ne i nformati on fr om the mi ni mi zati on
r outi nes ar e gi ven. Furthermor e, i n ms 2t h, you ar e asked to gi ve a l i st of
nomi nal /i ni ti al parameter val ues. I n these cases i t i s i mpor tant to know i n
what order the par ameter are l i sted. The basi c thr ee cases are as fol l ows:
For the i nput-output model (3.23) or i ts mul ti -i nput vari ant (5.2), you have
the fol l owi ng al phabeti cal orderi ng
Here superscr i pt refers to the i nput number .
For a state-space str uctur e, defi ned by ms 2t h, the par ameters i n par s ar e
obtai ned i n the fol l owi ng order. The A matri x i s fi rst scanned row by row for
free par ameters. Then the B matr i x i s scanned r ow by row, and so on for the
C, D, K, and X0 matr i ces. (See ms 2t h i n the Command Reference chapter .)
For a state-space matr i x that i s defi ned by mf 2t h, the orderi ng of the
parameter s i s the same as i n the user -wr i tten M-fi l e.
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
Mul ti vari ate ARX model s are i nter nal l y r epresented i n state-space form. The
parameter or deri ng fol l ows the one descri bed above. The orderi ng of the
parameter s may, however , not be tr ansparent so i t i s better to use t h2ar x and
ar x 2t h i nstead of t h2par and ms 2t h.
Complex-Valued Data
Some appl i cati ons of system i denti fi cati on work wi th compl ex val ued data, and
thus cr eate compl ex-val ued model s. Most of the routi nes i n the SI TB suppor t
compl ex data and model s. Thi s i s true for the esti mati on r outi nes ar , ar max ,
ar x , bj , c ov f , i var , i v4, oe , pe m, and s pa, but (cur rentl y) not for cans t ar t and
n4s i d. The transformati on r outi nes, l i ke t h2f f , t h2z p, etc. al so wor k for
compl ex-val ued model s, but no pol e-zer o confi dence r egi ons ar e gi ven. Note
al so that the parameter vari ance-covari ance i nfor mati on then refers to the
compl ex val ued par ameters, so no separate i nfor mati on about the accuracy of
the real and i magi nary parts wi l l be gi ven. Some di spl ay functi ons l i ke compar e
and
i dpl ot do not wor k for the compl ex case. Use i ds i m and pl ot r eal and
i magi nar y parts separ atel y.
Strange Results
Str ange r esul ts can of cour se be obtai ned i n any number of ways. We onl y poi nt
out two cauti ons: I t i s tempti ng i n i denti fi cati on appl i cati ons to cal l the
resi dual s eps. Dont do that. Thi s changes the machi ne , whi ch certai nl y
wi l l gi ve you str ange resul ts.
I t i s al so natural to use names l i ke s t e p, phas e , etc., for certai n vari abl es. Note
though that these var i abl es take precedence over M-fi l es wi th the same name
so be sure you dont use var i abl e names that al so ar e names of M-fi l es.

3 Tutori al
3-80

4
Command Reference
4 C ommand Reference
4-2
Thi s chapter contai ns detai l ed descr i pti ons of al l of the functi ons i n the System
I denti fi cati on Tool box. I t begi ns wi th a l i st of functi ons gr ouped by subject area
and conti nues wi th the entr i es i n al phabeti cal order. I nformati on i s al so
avai l abl e through the onl i ne Hel p faci l i ty.
By typi ng a functi on name wi thout ar guments, you al so get i mmedi ate syntax
hel p about i ts arguments.
For ease of use, most functi ons have sever al defaul t ar guments. The Synopsi s
fi r st l i sts the functi on wi th the necessary i nput ar guments and then wi th al l
the possi bl e i nput ar guments. The functi ons can be used wi th any number of
ar guments between these extremes. The rul e i s that mi ssi ng, trai l i ng
ar guments ar e gi ven defaul t val ues, as defi ned i n the manual . Defaul t val ues
ar e al so obtai ned by enteri ng the arguments as the empty matri x [ ].
MATLAB does not requi re that you speci fy al l of the output arguments; those
not speci fi ed are not r etur ned. For functi ons wi th several output arguments i n
the System I denti fi cati on Tool box, mi ssi ng ar guments ar e, as a r ul e, not
computed, i n order to save ti me.
The Graphical User Interface
i dent Open the i nterface.
mi dpr ef s Set di rectory where to stor e start-up i nformati on.
Simulation and Prediction
i di nput Gener ate i nput si gnal s.
i ds i m Si mul ate a general l i near system.
pe Compute predi cti on er ror s.
pol y 2t h Create a model str ucture for i nput-output model s
defi ned as numer ator and denomi nator pol ynomi al s.
pr edi ct Compute predi cti ons accordi ng to model .
4-3
Data Manipulation
dt r e nd Remove tr ends from data.
i df i l t Fi l ter data.
i dr e s amp Resampl e data.
Nonparametric Estimation
covf Esti mate covari ance functi on.
cr a Esti mate i mpul se response and covar i ance functi ons
usi ng cor rel ati on anal ysi s.
et f e Esti mate spectr a and transfer functi ons usi ng di r ect
Four i er techni ques.
s pa Esti mate spectra and tr ansfer functi ons usi ng
spectr al anal ysi s.
Parameter Estimation
ar Esti mate AR model .
ar max Esti mate ARMAX model .
ar x Esti mate ARX model usi ng l east squares.
bj Esti mate Box-Jenki ns model .
cans t ar t Esti mate mul ti var i ate model s i n canoni cal
state-space for m.
i v ar Esti mate AR model usi ng i nstr umental var i abl e
methods.
i v x Esti mate ARX model usi ng gener al i nstr uments.
i v 4 Esti mate ARX model usi ng four-stage i nstrumental
var i abl e method.
4 C ommand Reference
4-4
oe Esti mate Output-Err or model .
n4s i d Esti mate state-space model usi ng subspace method.
pe m Esti mate general l i near model .
Model Structure Creation
ar x2t h Defi ne (mul ti var i ate) ARX structures.
canf or m Gener ate canoni cal for ms.
mf 2t h Create arbi trar y l i near model structure vi a an M-fi l e
that you wri te.
mods t r uc Defi ne state-space model s wi th known and unknown
parameter s.
ms 2t h Create model structur e for l i near state-space model s
wi th known and unknown par ameters.
pol y 2t h Create a model str ucture for i nput-output model s
defi ned as numer ator and denomi nator pol ynomi al s.
Manipulating Model Structures
f i xpar Fi x par ameters i n structures to gi ven val ues.
s e t t Set the sampl i ng i nter val .
s s 2t h Transform a state-space model to a parametri zed
canoni cal for m.
t hi ni t Sel ect or randomi ze i ni ti al par ameter val ues.
unf i x par Al l ow cer tai n ear l i er fi xed parameter s be esti mated.
Parameter Estimation
4-5
Model Conversions
i dmodr ed Reduce a model to l ower or der.
t hc2t hd Tr ansfor m fr om conti nuous to di screte ti me.
t hd2t hc Tr ansfor m fr om di scr ete to conti nuous ti me.
t h2ar x Theta to ARX par ameters.
t h2f f Theta to fr equency functi ons and spectr a.
t h2par Theta to esti mated par ameters and vari ances.
t h2pol y Theta to tr ansfer functi on pol ynomi al s.
t h2s s Theta to state-space matr i ces.
t h2t f Theta to tr ansfer functi ons.
t h2z p Theta to zer os, pol es, and stati c gai ns.
Model Presentation
bode pl ot Pl ot Bode di agrams.
f f pl ot Pl ot frequency functi ons and spectr a.
i dpl ot Di spl ay i nput-output data.
ny qpl ot Pl ot Nyqui st di agrams.
pr es ent Di spl ay model on screen.
z ppl ot Pl ot zeros and pol es.
4 C ommand Reference
4-6
Information Extraction
ge t f f Extr act the fr equency functi ons fr om the fr eqfunc
format.
ge t t Extr act the sampl i ng i nterval from the theta format.
ge t mf t h Extr act the M-fi l e name that defi nes the model
str uctur e.
ge t nc ap Extr act fr om the theta for mat the number of data
upon whi ch model i s based.
ge t z p Extr act the zer os and pol es from the zepo format.
t h2par Extr act esti mated parameter s and vari ances fr om
the theta format.
Model Validation
compar e Compare model s si mul ated or pr edi cted output wi th
actual output.
i ds i m Si mul ate a model .
pe Compute predi cti on er ror s.
pr edi ct Predi ct futur e outputs.
r e s i d Compute and test model r esi dual s.
Assessing Model Uncertainty
i ds i ms d Si mul ate responses fr om sever al possi bl e model s.
t h2f f Compute frequency functi on and i ts standard
devi ati on.
t h2z p Compute zeros, pol es, stati c gai ns, and thei r
standard devi ati ons.
4-7
Model Structure Selection
ar xs t r uc Compute l oss functi ons for sets of ARX model
str uctur e.
i v s t r uc Compute l oss functi ons for sets of output err or model
str uctur es.
s e l s t r uc Sel ect str uctur e.
s t r uc Gener ate sets of str uctur es.
Recursive Parameter Estimation
r ar max Esti mate ARMAX or ARMA model s recur si vel y.
r ar x Esti mate ARX or AR model s r ecur si vel y.
r bj Esti mate Box-Jenki ns model s r ecur si vel y.
r oe Esti mate Output-Err or model s (I I R-fi l ters)
recursi vel y.
r pem Esti mate gener al i nput-output model s usi ng a
recursi ve pr edi cti on er ror method.
r pl r Esti mate gener al i nput-output model s usi ng a
recursi ve pseudo-l i near r egressi on method.
s e gment Segment data and esti mate model s for each segment.
4 C ommand Reference
4-8
ar
4-9
ar
Purpose Esti mate the par ameters of an AR model for scal ar ti me seri es.
Syntax t h = ar ( y , n)
[ t h, r ef l ] = ar ( y , n, appr oac h, wi n, max s i z e, T)
Description The parameter s of the AR model str uctur e
ar e esti mated usi ng vari ants of the l east-squares method.
Col umn vector y contai ns the ti me seri es data. Scal ar n speci fi es the or der of
the model to be esti mated (the number of A parameter s i n the AR model ).
Note that the routi ne i s for scal ar ti me seri es onl y. For mul ti vari ate data use
ar x .
The esti mate i s returned i n t h and stor ed i n theta for mat. For the two
l atti ce-based approaches, ' bur g' and ' gl ' (see bel ow), var i abl e r e f l i s
returned contai ni ng the r efl ecti on coeffi ci ents i n the fi r st row, and the
cor respondi ng l oss functi on val ues i n the second. The fi r st col umn i s the zero-th
order model , so that the (2,1) el ement of r e f l i s the nor m of the ti me seri es
i tsel f.
Var i abl e appr oach al l ows you to choose an al gori thm fr om a gr oup of sever al
popul ar techni ques for computi ng the l east-squares AR model . Avai l abl e
methods ar e as fol l ows:
appr oac h = ' f b' : The for war d-backwar d appr oach. Thi s i s the defaul t
approach. The sum of a l east-squares cr i ter i on for a forward model and the
anal ogous cri ter i on for a ti me-r eversed model i s mi ni mi zed.
appr oac h = ' l s ' : The l east-squar es appr oach. The standar d sum of squar ed
forward pr edi cti on er ror s i s mi ni mi zed.
appr oac h = ' y w' : The Yul e-Wal ker approach. The Yul e-Wal ker equati ons,
formed fr om sampl e covari ances, are sol ved.
appr oac h = ' bur g' : Bur gs l atti ce-based method. The l atti ce fi l ter equati ons
ar e sol ved, usi ng the har moni c mean of for war d and backwar d squar ed
predi cti on err or s.
A q ( )y t ( ) e t ( ) =
ar
4-10
appr oac h = ' gl ' : A geometr i c l atti ce appr oach. As i n Bur gs method, but the
geometr i c mean i s used i nstead of the har moni c one. .
The computati on of the covari ance matr i x can be suppressed i n any of the
above methods by endi ng the appr oac h argument wi th 0 (zer o), for exampl e,
' bur g0' .
Windowing, wi thi n the context of AR model i ng, i s a techni que for deal i ng wi th
the fact that i nfor mati on about past and futur e data i s l acki ng. There are a
number of vari ants avai l abl e:
wi ndow = ' now' : No wi ndowi ng. Thi s i s the defaul t val ue, except when
appr oac h = ' yw' . Onl y actual l y measur ed data are used to form the r egressi on
vectors. The summati on i n the cri teri a starts onl y at ti me n.
wi ndow = ' pr w' : Pr e-wi ndowi ng. Mi ssi ng past data are repl aced by zeros, so
that the summati on i n the cr i teri a can be star ted at ti me zero.
wi ndow = ' pow' : Post-wi ndowi ng. Mi ssi ng end data ar e r epl aced by zeros, so
that the summati on can be extended to ti me N + n. (N bei ng the number of
obser vati ons.)
wi ndow = ' ppw' : Pr e- and post-wi ndowi ng. Thi s i s used i n the Yul e-Wal ker
approach.
The combi nati ons of appr oaches and wi ndowi ng have a vari ety of names. The
l east-squar es approach wi th no wi ndowi ng i s al so known as the covariance
method. Thi s i s the same method that i s used i n the ar x routi ne. The MATLAB
defaul t method, for war d-backwar d wi th no wi ndowi ng, i s often cal l ed the
modified covariance method. The Yul e-Wal ker appr oach, l east-squar es pl us
pre- and post-wi ndowi ng, i s al so known as the correlation method.
ar onl y handl es scal ar ti me seri es. For mul ti vari ate ser i es, use ar x .
See auxv ar for an expl anati on of the i nput ar guments max s i z e and T.
ar
4-11
Examples Compare the spectr al esti mates of Bur gs method wi th those found from the
forward-backward nonwi ndowed method, gi ven a si nusoi d i n noi se si gnal :
y = s i n( [ 1: 300] ' ) + 0. 5*r andn( 300, 1) ;
t hb = ar ( y, 4, ' bur g' ) ;
t hf b = ar ( y , 4) ;
s gb = t h2f f ( t hb) ;
s f b = t h2f f ( t hf b) ;
bodepl ot ( [ s gb s f b] )
See Also aux var , ar x , et f e, i var , s pa, t he t a
References Mar pl e, Jr., S. L. Digital Spectral Analysis with Applications, Pr enti ce Hal l ,
Engl ewood Cl i ffs, 1987, Chapter 8.
armax
4-12
ar max
Purpose Esti mate the parameter s of an ARMAX or ARMA model .
Syntax t h = ar max( z , nn)
t h = ar max( z , nn, t r ace )
[ t h, i t er _i nf o] = ar max( z , nn, maxi t e r , t ol , l i m, maxs i z e, T, t r ac e )
Description The parameter s of the ARMAX model structur e
ar e esti mated usi ng a predi cti on err or method.
Matri x z contai ns the output-i nput data z = [ y u] wher e y and u are col umn
vectors (u i s a matr i x i n the mul ti -i nput case). nn can be gi ven ei ther as
nn = [ na nb nc nk]
or as
nn = t hi
I n the former case na, nb, and nc are the orders of the ARMAX model , and nk
i s the del ay. I n the l atter case t hi i s an i ni ti al val ue, gi ven i n theta format. See
Secti on 3 i n the Tutorial for an exact defi ni ti on of the order s.
For mul ti -i nput systems, nb and nk are row vectors, such that the k-th entry
cor responds to the order and del ay associ ated wi th the k-th i nput.
I f z = y and nn = [ na nc ] , ar max cal cul ates an ARMA model for y:
t h i s returned wi th the resul ti ng par ameter esti mates, together wi th esti mated
covari ances, stor ed i n theta for mat.
ar max does not suppor t mul ti -output model s. Use state-space model for thi s
case (see cans t ar t , n4s i d, and pem)
I f a l ast ar gument t r ace i s suppl i ed, i nformati on about the progr ess of the
i ter ati ve sear ch for the model wi l l be fur ni shed to the MATLAB command
wi ndow.
The opti onal auxi l i ar y vari abl es i t e r _i nf o, l i m, max i t er , t ol , max s i z e , and T
ar e expl ai ned under aux var .
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 robusti fi ed quadrati c predi cti on err or cr i teri on i s mi ni mi zed usi ng an
i ter ati ve Gauss-Newton al gor i thm. The Gauss-Newton vector i s bi sected up to
10 ti mes unti l a l ower val ue of the cr i teri on i s found. I f no such val ue i s found,
a gr adi ent search di r ecti on i s used i nstead, and the procedure i s r epeated. The
i ter ati ons ar e ter mi nated when maxi t e r i s reached, when the Gauss-Newton
vector has a norm l ess than t ol , or when a l ower val ue of the cr i ter i on cannot
be found.
The i ni ti al condi ti ons for the i terati ve search, i f not speci fi ed i n nn, ar e
constr ucted i n a speci al four-stage LS-I V al gor i thm.
The cut-off val ue for the robusti fi cati on i s based on the parameter l i m as wel l
as on the esti mated standar d devi ati on of the resi dual s from the i ni ti al
parameter esti mate. I t i s not r ecal cul ated duri ng the mi ni mi zati on. The val ue
returned i n el ement t h( 1, 1) i s the nonr obusti fi ed, quadr ati c cri ter i on.
A stabi l i ty test of the pr edi ctor i s performed, so as to assure that onl y model s
cor respondi ng to stabl e pr edi ctor s ar e tested. General l y, both and (i f
appl i cabl e) must have al l thei r zeros i nsi de the uni t ci rcl e. Note that i f an
i ni ti al parameter esti mate i s gi ven i n nn, i ts predi ctor stabi l i ty i s taken for
gr anted (not tested).
I nformati on about the mi ni mi zati on i s furni shed to the scr een i n case the
ar gument t r ace i s speci fi ed.. Cur rent and previ ous par ameter esti mates (i n
col umn vector for m, l i sti ng par ameters i n al phabeti cal or der) as wel l as the
val ues of the cr i ter i on functi on ar e gi ven. The Gauss-Newton vector and i ts
nor m ar e al so di spl ayed. The number i n the upper l eft corner i s the number of
ti mes the sear ch vector has been bi sected.
See Also ar x , auxv ar , bj , oe, pe m, t he t a
References Ljung (1987), equati ons (10.41), (10.42), (10.46), (10.75)
C q ( ) F
i
q ( )
arx
4-14
ar x
Purpose Esti mate the parameter s of an ARX or AR model .
Syntax t h = ar x( z , nn)
t h = ar x( z , nn, maxs i z e, T)
Description The parameter s of the ARX model structure
ar e esti mated usi ng the l east-squares method.
Matri x z contai ns the output-i nput data z = [ y u] wher e y and u are col umn
vectors. nn i s gi ven as
nn = [ na nb nk]
defi ni ng the or ders and del ay of the ARX model . See Secti on 6 i n the Tutorial
for exact defi ni ti ons of the or der s and del ays.
t h i s r etur ned as the l east-squar es esti mates of the parameter s, stored i n theta
format.
Wi th z = y and nn = na, an AR model of order na for y i s computed:
Model s wi th several i nputs
ar e handl ed by al l owi ng u to contai n each i nput as a col umn vector ,
u = [ u1 . . . unu]
and by al l owi ng nb and nk to be row vectors defi ni ng the orders and del ays
associ ated wi th each i nput.
Model s wi th sever al i nputs and sever al outputs are handl ed by al l owi ng nn to
contai n one row for each output number. See Defi ni ng Model Str uctur es on
page 3-29 for exact defi ni ti ons.
The opti onal auxi l i ar y parameter s maxs i z e and T ar e expl ai ned under
aux var .
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 the tr ue noi se term i n the ARX model structur e i s not whi te noi se
and na i s nonzer o, the esti mate does not gi ve a cor rect model . I t i s then better
to use ar max, bj , i v 4, or oe.
Examples Her e i s an exampl e that gener ates and esti mates an ARX model :
A = [ 1 1. 5 0. 7] ; B = [ 0 1 0. 5] ;
t h0 = pol y2t h( A, B) ;
u = i di nput ( 300, ' r bs ' ) ;
y = i ds i m( [ u, r andn( 300, 1) ] , t h0) ;
z = [ y, u] ;
t h = ar x( z , [ 2 2 1] ) ;
Algorithm The l east-squares esti mati on probl em i s an overdeter mi ned set of l i near
equati ons that i s sol ved usi ng the MATLAB \ operator.
The regressi on matr i x i s for med so that onl y measured quanti ti es ar e used (no
fi l l -out wi th zeros). When the r egr essi on matr i x i s l ar ger than maxs i z e, the
nor mal equati ons are for med i n a for-l oop and subsequentl y sol ved.
See Also aux var , ar , i v, i v 4, t he t a
e t ( )
arxstruc
4-16
ar xstruc
Purpose Compute l oss functi ons for a set of di fferent model str uctures of si ngl e-output
ARX type.
Syntax v = ar x s t r uc( z e, z v , NN)
v = ar x s t r uc( z e, z v , NN, max s i z e )
Description NN i s a matri x that defi nes a number of di ffer ent str uctur es of the ARX type.
Each row of NN i s of the form
nn = [ na nb nk]
wi th the same i nter pretati on as descri bed for ar x. See s t r uc for easy
gener ati on of typi cal NN matr i ces for si ngl e-i nput systems.
Each of z e and z v are matri ces contai ni ng output-i nput data [ y u] . For
mul ti -i nput systems, u has the corr espondi ng number of col umns, whi l e for
ti me seri es, no u i s pr esent. Model s for each of the model structur es defi ned by
NN are esti mated usi ng the data set z e . The l oss functi ons (normal i zed sum of
squared pr edi cti on err ors) are then computed for these model s when appl i ed to
the val i dati on data set z v . The data sets, z e and z v, need not be of equal si ze.
They coul d, however , be the same sets, i n whi ch case the computati on i s faster.
Note that ar x s t r uc i s i ntended for si ngl e-output systems onl y.
v i s r etur ned wi th the l oss functi ons i n i ts fi r st row. The r emai ni ng rows of v
contai n the tr anspose of NN, so that the or der s and del ays are gi ven just bel ow
the cor respondi ng l oss functi ons. The l ast col umn of v contai ns the number of
data poi nts i n z e . The sel ecti on of a sui tabl e model structure based on the
i nfor mati on i n v i s best done usi ng s el s t r uc. See Secti on 8 i n the Tutorial for
advi ce on model structur e sel ecti on, cross-val i dati on, and the l i ke.
See auxv ar for an expl anati on of maxs i z e.
Examples Compare fi rst to fi fth order model s wi th one del ay usi ng cr oss-val i dati on on the
second hal f of the data set, and then sel ect the order that gi ves the best fi t to
the val i dati on data set:
NN = s t r uc ( 1: 5, 1: 5, 1) ;
V = ar x s t r uc ( z ( 1: 200, : ) , z ( 201: 400, : ) , NN) ;
nn = s e l s t r uc( V, 0) ;
t h = ar x( z , nn) ;
See Also ar x , i v s t r uc, s e l s t r uc , s t r uc
arx2th
4-17
ar x2th
Purpose Construct theta format matri x fr om ARX pol ynomi al s.
Syntax t h = ar x2t h( A, B, ny , nu)
t h = ar x2t h( A, B, ny , nu, l am, T)
Description ar x 2t h cr eates a matri x contai ni ng par ameters that descr i be the gener al
mul ti -i nput, mul ti -output model str uctur e of ARX type:
Her e and are matri ces of di mensi ons ny by ny and ny by nu, respecti vel y
(ny i s the number of outputs, i .e., the di mensi on of the vector and nu i s the
number of i nputs). Defi ni ng Model Structures on page 3-29.
The arguments A and B are matr i ces that contai n the A matr i ces and the B
matr i ces of the model :
A = [ I A1 A2 . . . Ana]
B = [ B0 B1 . . . Bnb]
Note that A al ways star ts wi th the i denti ty matr i x, and that del ays i n the model
ar e defi ned by setti ng the corr espondi ng l eadi ng entr i es i n B to zero. For a
mul ti var i ate ti me seri es take B = [ ] .
The arguments ny and nu denote the number of outputs and i nputs,
respecti vel y.
The opti onal argument l am sets the covar i ance matri x of the dri vi ng noi se
sour ce i n the model above. The defaul t val ue i s the i denti ty matr i x.
The opti onal argument T defi nes the sampl i ng i nterval (Defaul t 1).
t h i s retur ned as a model str uctur e i n the theta for mat. See t he t a.
The use of ar x2t h i s twofol d. You can use i t to cr eate model s that are si mul ated
(usi ng i ds i m) or anal yzed (usi ng t h2f f , t h2z p, etc.). You can al so use i t to
defi ne i ni ti al val ue model s that ar e fur ther adjusted to data (usi ng pe m). The
free parameter s i n the str uctur e ar e consi stent wi th the str uctur e of A and B,
i .e., l eadi ng zer os i n the rows of B are regarded as fi xed del ays, and tr ai l i ng
zeros i n A and B ar e r egarded as a defi ni ti on of l ower order pol ynomi al s. 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
zeros are fi xed, whi l e al l other par ameters are fr ee. The nomi nal val ues of these
free parameter s are set equal to the val ues i n A and B. The free parameter s can
be changed by t hi ni t and the str uctur e can be mani pul ated by f i xpar and
unf i x par .
For a model wi th one output, ar x2t h i s compati bl e wi th pol y2t h. The i nter nal
repr esentati on i s however di fferent, and onl y a model structure that has been
defi ned by ar x2t h can be mani pul ated by f i xpar and unf i xpar .
Examples Si mul ate a second or der ARX model wi th one i nput and two outputs, and then
esti mate a model usi ng the si mul ated data :
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] ;
t h0 = ar x 2t h( [ ey e( 2) A1 A2] , [ [ 0; 0] , B1 B2] , 2, 1) ;
u = i di nput ( 300) ;
e = r andn( 300, 2) ;
y = i ds i m( [ u e ] , t h0) ;
t h = ar x( [ y u] , [ [ 2 2; 2 2] , [ 2; 2] , [ 1; 1] ] ) ;
See Also ar x , f i xpar , pol y2t h, t h2ar x, unf i x par
auxvar
4-19
auxvar
Purpose Descri be auxi l i ary var i abl es i t e r _i nf o, l i m, max i t er , max s i z e , t ol , and T.
Syntax he l p auxv ar
Description Most of the functi ons have an opti onal argument max s i z e that al l ows a
tr ade-off between memory usage and speed. Sever al of the functi ons al l ow the
sampl i ng i nter val T to be speci fi ed. The i terati ve search procedures i n ar max ,
bj, oe , and pe m ar e contr ol l ed by the three par ameters l i m, max i t er , and l i m.
max s i z e : No matri x formed by the functi on i s al l owed to contai n more than
max s i z e el ements. I nstead, the al gor i thms spl i t the cal cul ati ons i nto for -l oops,
whi ch are sl ower . The defaul t val ue of maxs i z e i s set i n the M-fi l e i dms i z e . On
smal l machi nes, i t i s max s i z e =4096. The mai n use of max s i z e i s to l i mi t
var i abl e si zes when the al gor i thms r un out of memor y. See Some Speci al
Topi cs on page 3-68 for mor e i nfor mati on.
T: Speci fyi ng the sampl i ng i nterval T gi ves cor rect fr equency scal es on
frequency functi on pl ots, and corr ect ti me scal es when tr ansfor mi ng to
conti nuous ti me usi ng t hd2t hc . The defaul t val ue i s T=1.
max i t er : Thi s vari abl e determi nes the maxi mum number of i terati ons
performed duri ng a search for a mi ni mum. The defaul t val ue i s max i t er =10.
max i t er =0 r etur ns the r esul ts of the speci al startup pr ocedur e.
t ol : The i ter ati ons ar e conti nued unti l the norm of the Gauss-Newton update
vector i s l ess than TOL. The i terati ons al so ter mi nate when the al gor i thm fai l s
to fi nd a l ower val ue of the cri ter i on and when the maxi mum number of
i ter ati ons ar e r eached. The defaul t val ue i s t ol =0. 01.
l i m: Thi s var i abl e determi nes how the cr i teri on i s modi fi ed fr om quadrati c to
one that gi ves l i near wei ght to l ar ge err ors. See Par ametri c Model Esti mati on
on page 3-22 for a more pr eci se defi ni ti on. The defaul t val ue of l i m i s 1.6. l i m=0
di sabl es the r obusti fi cati on and l eads to a pur el y quadr ati c cri ter i on.
Defaul t val ues of these parameter s are obtai ned ei ther by omi tti ng tr ai l i ng
ar guments or by enteri ng them as the empty matr i x [ ].
auxvar
4-20
i t e r _i nf o: Thi s output argument fr om the i ter ati ve numeri cal search
al gor i thms ar max, bj , oe, and pem, suppl i es i nfor mati on about the i terati ons. I t
i s a row vector
i t e r _i nf o = [ l as t _i t er at i on#, l as t _f i t _i mpr ov ement ,
nor m_of _l as t _s ear c h_ve c t or ]
contai ni ng the i ndi cated i nfor mati on. I f the nor m of the l ast sear ch vector i s
l ar ger than t ol , and the number of the l ast i ter ati on i s l ess than max i t er , then
the i ter ati ons wer e stopped si nce no smal l er val ue of the cr i teri on coul d be
found al ong the search di recti on.
See Also ar max , bj , oe, pem
bj
4-21
bj
Purpose Esti mate the par ameters of a Box-Jenki ns model .
Syntax t h = bj ( z , nn)
t h = bj ( z , nn, t r ac e )
[ t h, i t er _i nf o] = bj ( z , nn, maxi t e r , t ol , l i m, max s i z e , T, t r ace )
Description The parameter s of the Box-Jenki ns model str uctur e
ar e esti mated usi ng a predi cti on err or method.
Matri x z contai ns the output-i nput data z = [ y u] wher e y and u ar e col umn
vectors. I n the mul ti -i nput case, u i s a matr i x contai ni ng the di fferent i nputs as
col umns. nn can be gi ven ei ther as
nn = [ nb nc nd nf nk]
or as
nn = t hi
I n the former case, nb, nc, nd, and nf are the or ders of the Box-Jenki ns model
and nk i s the del ay. I n the l atter case, t hi i s an i ni ti al val ue, gi ven i n theta
format. See The System I denti fi cati on Probl em on page 3-8 for exact
defi ni ti ons of the model order s.
t h i s retur ned wi th the resul ti ng par ameter esti mates and esti mated
covari ances, stored i n theta format.
The opti onal var i abl es i t e r _i nf o, l i m, maxi t e r , maxs i z e , t ol , and T are
expl ai ned under auxv ar .
For mul ti -i nput systems, nb, nf , and nk are row vectors wi th as many entri es
as ther e ar e i nput channel s. Entr y number i then descr i bed the or der s and
del ays associ ated wi th the i -th i nput.
bj does not suppor t mul ti -output model s. Use state-space model for thi s case
(see c ans t ar t , n4s i d, and pe m)
y t ( )
B q ( )
F q ( )
-----------u t nk ( )
C q ( )
D q ( )
------------e t ( ) + =
bj
4-22
I f a l ast ar gument t r ace i s suppl i ed, i nformati on about the progr ess of the
i ter ati ve sear ch for the model wi l l be fur ni shed to the MATLAB command
wi ndow.
Examples Her e i s an exampl e that gener ates data and stor es the r esul ts of the startup
procedure separatel y:
B = [ 0 1 0. 5] ;
C = [ 1 1 0. 2] ;
D = [ 1 1. 5 0. 7] ;
F = [ 1 1. 5 0. 7] ;
t h0 = pol y 2t h( 1, B, C, D, F, 0. 1) ;
e = r andn( 200, 1) ;
u = i di nput ( 200) ;
y = i ds i m( [ u e ] , t h0) ;
z = [ y u] ;
t hi = bj ( z , [ 2 2 2 2 1] , 0) ;
t h = bj ( z , t hi ) ;
pr e s e nt ( t h)
Algorithm bj uses essenti al l y the same al gori thm as ar max wi th modi fi cati ons to the
computati on of pr edi cti on er rors and gradi ents.
See Also ar max , auxv ar , oe, pem, t he t a
bodeplot
4-23
bodepl ot
Purpose Pl ot fr equency functi ons i n Bode di agr am for m.
Syntax bodepl ot ( g)
bodepl ot ( [ g1 g2 . . . gn] )
bodepl ot ( g, s d, C, mode )
Description g contai ns the fr equency data to be graphed. See f r e qf unc for the for mat. The
frequency functi ons do not have to be speci fi ed at the same frequenci es, but
have to have the same number of val ues.
I f the frequency functi ons are generated by t h2f f or s pa, and s d i s speci fi ed as
a number l ar ger than zero, confi dence i nter val s for the functi ons ar e added to
the graph as dash-dotted curves (of the same col or as the esti mate cur ve). They
i ndi cate the confi dence regi ons corr espondi ng to s d standard devi ati ons.
On ampl i tude pl ots, the l ogari thm of the absol ute val ue, pl us and mi nus the
standar d devi ati on you i ndi cate, i s graphed. The l atter val ue can someti mes be
negati ve, whi ch resul ts i n an er ror message fr om the pl otti ng routi ne. The
resul ti ng pl ot i s sti l l meani ngful , however .
By defaul t, ampl i tude and phase pl ots ar e shown si mul taneousl y for each i nput
(noi se spectrum) present i n g. For spectra, phase pl ots are omi tted. Pressi ng
the Return key advances the pl ot from one i nput to the next.
To show ampl i tude pl ots onl y, use C = ' A' . For phase pl ots onl y, use
C = ' P' . The defaul t i s C = ' B' for both pl ots.
To obtai n al l pl ots on the same di agram use mode = ' s ame ' .
Note that i f g contai ns i nformati on about sever al outputs, these pl ots ar e
al ways gi ven separatel y.
See Also et f e, f f pl ot , f r eqf unc , get f f , nyqpl ot , s pa, t h2f f
canform
4-24
canform
Purpose Defi ne mul ti var i abl e state-space canoni cal for m model structur es.
Syntax ms = canf or m( or der s , nu)
ms = canf or m( or der s , nu, dkx)
Description c anf or m i s, l i ke mods t r uc, a functi on that defi nes model par ameteri zati ons i n
state-space for m, whi ch are used i n ms 2t h to cr eate model structur es i n the
theta format. The onl y use of the r esul ti ng matr i x ms i s as an i nput to ms 2t h.
The model consi dered i s i n state-space for m:
The functi on appl i es both to the conti nuous- and di scr ete-ti me cases; whi ch one
i s determi ned onl y when the structure i s for med wi th ms 2t h.
or der s : The (pseudo-observabi l i ty) i ndi ces or der s defi ne whi ch matri x
el ements ar e fi xed (to zer o or one) and whi ch ar e l eft fr ee as par ameters.
or der s i s a r ow vector wi th as many entr i es as ther e ar e outputs. El ement k of
or der s descr i bes how many del ayed val ues of the output ar e requi red to
appropr i atel y predi ct the k-th component of the output. The sum of the or der
i ndi ces i s the order of the system (the di mensi on of x):
n = s um( or de r s )
The exact structure i s defi ned i n Appendi x 4.A of Ljung (1987). Br i efl y, the A
matr i x contai ns p n parameter s, where p i s the number of outputs and n i s
the number of states. The C matri x contai ns onl y zer os and ones, whi l e the B
matr i x i s fi l l ed wi th par ameters.
nu: The number of i nputs.
dkx : The argument dkx determi nes some addi ti onal str uctur e of the matri ces
of the state-space model to be esti mated. I t i s a row vector wi th thr ee entr i es:
dkx = [ d, k, x ]
The entr i es r efer to the matr i ces K, D, and the i ni ti al state x(0) of the
state-space model gi ven 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 i ndi cates that the K-matr i x i n the model (the Kal man Gai n) wi l l be ful l y
parameter i zed, whi l e k = 0 means that thi s matri x wi l l be fi xed to zer o. Thi s
wi l l gi ve a so-cal l ed output err or model .
d = 1 i ndi cates that D-matri x i n the model (the di r ect ter m fr om i nput to
output) wi l l be ful l y par ametri zed, whi l e d = 0 means that thi s matr i x wi l l be
fi xed to zero. Thi s al so i mpl i es that there wi l l be a del ay of (at l east) one sampl e
between the i nput and the output.
x = 1 i ndi cates that the i ni ti al state x(0) wi l l be parameter i zed, whi l e x = 0
means that the i ni ti al state wi l l be fi xed to zero.
Defaul t i s
dkx = [ 0, 1, 0]
An al ter nati ve to canf or m i s the functi on c ans t ar t . I t al so provi des good i ni ti al
esti mates for the fr ee parameter s.
Examples Wri te out the state-space matr i ces for a si xth or der system wi th thr ee outputs
and two i nputs wi th NaN denoti ng fr ee par ameters:
ps = [ 2 1 3] ;
ms = canf or m( ps , 2) ;
t h = ms 2t h( ms , ' c ' , ones ( 1, 18+12+18) NaN) ;
[ A, B, C, D, K] = t h2s s ( t h)
See Also cans t ar t , f i x par , mods t r uc, ms 2t h, unf i x par
References Ljung (1987), Appendi x 4.A.
canstart
4-26
canstar t
Purpose Defi ne and i ni ti al i ze state-space canoni cal for m model str uctur es.
Syntax t h = cans t ar t ( z , or de r s , nu)
t h = cans t ar t ( z , or de r s , nu, dkx )
Description or der s , nu, dkx : These ar guments defi ne the state-space model
par ameteri zati on exactl y as for the functi on canf or m. I n the present case
or der s can al so be taken as a scal ar , gi vi ng the model or der (di mensi on of state
vector). Then a defaul t choi ce of par ameteri zati on i s made.
The output t h i s a matri x i n the theta format. I t defi nes a state-space model
par ameteri zati on accor di ng to the ar guments or de r s , nu and dkx . The val ues
of the par ameters i n t h ar e esti mated fr om the data matr i x
z = [ y u]
where y i s the matr i x of output si gnal s, one col umn for each output, and u i s
the matr i x of i nput si gnal s, agai n one col umn for each i nput.
Choosi ng the order i ndi ces for many systems i s not cr i ti cal i n the sense that
most n-th or der systems can be descr i bed by any set of order
(pseudo-observabi l i ty) i ndi ces whose sum i s n. See Model Structur e Sel ecti on
and Val i dati on on page 3-49 for mor e i nfor mati on.
The model t h coul d be further refi ned by usi ng pem.
Algorithm The state-space model i s fi r st esti mated usi ng n4s i d, and then transformed to
the chosen canoni cal for m usi ng s s 2t h.
Examples A system wi th two i nputs and two outputs i s esti mated wi th a thi r d order
model :
t h = cans t ar t ( z , 3, 2) ;
t h = pe m( z , t h) ;
r es i d( z , t h) ;
See Also c anf or m, pe m
compare
4-27
compar e
Purpose Compare measur ed outputs wi th model outputs.
Syntax compar e ( z , t h) ;
[ y h, f i t ] = compar e ( z , t h, k, s ampnr , l e ve l adj )
Description z i s the output-i nput data i n the usual for mat
z = [ y u]
where y i s a matri x whose r -th col umn i s the r -th output si gnal and
cor respondi ngl y for the i nput u. compar e computes the output y h that r esul ts
when the model t h i s si mul ated wi th the i nput u. The r esul t i s pl otted (yel l ow/
sol i d) together wi th the cor respondi ng measured output y (magenta/dashed).
The mean square fi t
f i t = nor m( y h y) /s qr t ( l engt h( y) )
i s al so computed and di spl ayed. For mul ti -output systems thi s i s done
separ atel y for each output. Pressi ng the Return key advances the pl ots.
The argument k computes the k-step ahead predi cti on of y accordi ng to the
model t h i nstead of the si mul ated output. I n the cal cul ati on of , the model
can use outputs up to ti me : , , (and i nputs up to
the curr ent ti me t). The defaul t val ue of k i s i nf , whi ch obtai ns a pure
si mul ati on fr om the i nput onl y.
The argument s ampnr i ndi cates that onl y the sampl e numbers i n thi s row
vector ar e pl otted and used for the cal cul ati on of the fi t. The whol e data recor d
i s used for the si mul ati on/predi cti on, though. I f the opti onal ar gument
l e v el adj i s set to 'ye s ' , the si mul ated/predi cted output and the measur ed
output ar e l evel adjusted so that they both start at l evel zero. (Thi s appl i es al so
to the cal cul ati on of the fi t.) Thi s al l ows for di scounti ng of dri ft phenomena i n
the data.
Examples Spl i t the data r ecord i nto two parts. Use the fi rst one for esti mati ng a model
and the second one to check the model s abi l i ty to predi ct si x steps ahead:
z e = z ( 1: 250, : ) ;
z v = z ( 251: 500, : ) ;
t h = ar max( z e, [ 2 3 1 0] ) ;
c ompar e ( z v, t h, 6) ;
See Also i ds i m, pr edi c t
yh t ( )
t k y s ( ) s , t k = t k 1
covf
4-28
covf
Purpose Esti mate ti me ser i es covar i ance functi ons.
Syntax R = c ov f ( z , M)
R = c ov f ( z , M, max s i z e )
Description z i s an N by nz matri x and M i s the maxi mum del ay -1 for whi ch the covar i ance
functi on i s esti mated.
R i s r etur ned as an nz
2
x M matri x wi th entr i es
where i s the j -th col umn of z and mi ssi ng val ues i n the sum ar e repl aced by
zero.
The opti onal argument max s i z e control s the memory si ze as expl ai ned under
aux var .
The easi est way to descr i be and unpack the r esul t i s to use
r es hape ( R( : , k+1) , nz , nz ) = E z ( t ) z ' ( t +k)
Her e ' i s compl ex conjugate tr anspose, whi ch al so expl ai ns how compl ex data
ar e handl ed. The expectati on symbol E cor responds to the sampl e means.
Algorithm When nz i s at most two, and when per mi tted by maxs i z e , a fast Fouri er
tr ansfor m techni que i s appl i ed. Otherwi se, strai ghtforwar d summi ng i s used.
See Also s pa
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 form cor rel ati on anal ysi s and esti mate i mpul se r esponse.
Syntax cr a( z ) ;
[ i r , R, c l ] = c r a( z , M, na, pl ot ) ;
cr a( R) ;
Description The output-i nput data ar e gi ven as
z = [ y u]
wi th y as the output col umn vector and u as the i nput col umn vector. The
routi ne onl y handl es si ngl e-i nput-si ngl e-output data pai rs. (For the
mul ti var i ate case, appl y c r a to two si gnal s at a ti me.) c r a prewhi tens the i nput
sequence, i .e., fi l ters u through a fi l ter chosen so that the r esul t i s as
uncor rel ated (whi te) as possi bl e. The output y i s subjected to the same fi l ter,
and then the covar i ance functi ons of the fi l tered y and u are computed and
gr aphed. The cr oss corr el ati on functi on between (prewhi tened) i nput and
output i s al so computed and gr aphed. Posi ti ve val ues of the l ag vari abl e then
cor responds to an i nfl uence fr om u to l ater val ues of y . I n other wor ds,
si gni fi cant corr el ati on for negati ve l ags i s an i ndi cati on of feedback from y to u
i n the data.
A properl y scal ed ver si on of thi s corr el ati on functi on i s al so an esti mate of the
systems i mpul se r esponse i r . Thi s i s al so graphed al ong wi th 99% confi dence
l evel s. The output argument i r i s thi s i mpul se response esti mate, so that i ts
fi rst entry corr esponds to l ag zer o. (Negati ve l ags are excl uded i n i r .)
The output ar gument R contai ns the covar i ance/corr el ati on i nfor mati on as
fol l ows: The fi r st col umn of R contai ns the l ag i ndi ces. The second col umn
contai ns the covar i ance functi on of the (possi bl y fi l tered) output. The thi rd
col umn contai ns the covar i ance functi on of the (possi bl y pr ewhi tened) i nput,
and the four th col umn contai ns the corr el ati on functi on. The pl ots can be
redi spl ayed by c r a( R) .
The output ar gument cl i s the 99% confi dence l evel for the i mpul se response
esti mate.
The opti onal argument M defi nes the number of l ags for whi ch the covar i ance/
cor rel ati on functi ons ar e computed. These are fr om M to M, so that the l ength
of R i s 2M+1. The i mpul se r esponse i s computed from 0 to M. The defaul t val ue
of M i s 20.
cra
4-30
For the prewhi teni ng, the i nput i s fi tted to an AR model of order na. The thi rd
ar gument of c r a can change thi s order from i ts defaul t val ue na = 10. Wi th na
= 0 the covari ance and cor rel ati on functi ons of the ori gi nal data sequences are
obtai ned.
pl ot : pl ot = 0 gi ves no pl ots. pl ot = 1 (defaul t) gi ves a pl ot of the esti mated
i mpul se response together wi th a 99% confi dence r egi on. pl ot = 2 gi ves a pl ot
of al l the covar i ance functi ons.
Examples Compare a second or der ARX model s i mpul se r esponse wi th the one obtai ned
by cor rel ati on anal ysi s:
i r = cr a( z ) ;
t h = ar x( z , [ 2 2 1] ) ;
i mp = [ 1; z er os ( 19, 1) ] ;
i r t h = i ds i m( i mp, t h) ;
s ubpl ot ( 211)
pl ot ( [ i r i r t h] )
t i t l e ( ' i mpul s e r es pons e s ' )
s ubpl ot ( 212)
pl ot ( [ c ums um( i r ) , c ums um( i r t h) ] )
t i t l e ( ' s t e p r e s pons e s ' )
See Also c ov f , s pa
dtrend
4-31
dtrend
Purpose Remove trends from output-i nput data.
Syntax z d = dt r e nd( z )
z d = dt r e nd( z , o, br kp)
Description z i s a matr i x, wi th data organi zed i n col umn vector s. dt r e nd r emoves the tr end
from each col umn and r etur ns the resul t i n z d.
The defaul t (o = 0) removes the zer o-th order trends, i .e., the sampl e means are
subtracted.
Wi th o = 1, l i near trends are r emoved, after a l east-squares fi t. Wi th br kp not
speci fi ed, one si ngl e l i ne i s subtracted fr om the enti re data recor d. A
conti nuous pi ecewi se l i near trend i s subtr acted i f br kp contai ns breakpoi nts at
sampl e numbers gi ven i n a row vector.
Note that dt r e nd di ffer s somewhat fr om det r e nd i n the Si gnal Pr ocessi ng
Tool box.
Examples Remove a V-shaped trend fr om the output wi th i ts peak at sampl e number 119,
and remove the sampl e mean from the i nput:
z d( : , 1) = dt r e nd( z ( : , 1) , 1, 119) ;
z d( : , 2) = dt r e nd( z ( : , 2) ) ;
etfe
4-32
etfe
Purpose Esti mate empi r i cal tr ansfer functi ons and per i odograms.
Syntax g = e t f e( z )
g = e t f e( z , M, N, T)
Description e t f e esti mates the tr ansfer functi on g of the general l i near model
The matri x z contai ns the output-i nput data z = [ y u] , where y and u ar e
col umn vector s. The r outi ne works onl y for si ngl e-i nput, si ngl e-output systems.
For a ti me ser i es, z = y . Then g i s r etur ned as the per i odogram of y .
g i s gi ven i n frequency functi on for mat (see f r e qf unc ), wi th the esti mate of
at the fr equenci es
w = [ 1: N] /Npi /T
The defaul t val ues of N and T ar e 128 and 1, respecti vel y. N must be a power of
two.
When M i s speci fi ed other than the defaul t val ue M= [ ] , a smoothi ng oper ati on
i s per for med on the r aw spectral esti mates. The effect of Mi s then si mi l ar to the
effect of Mi n s pa. Thi s can be a useful al ter nati ve to s pa for narr owband spectra
and systems, whi ch other wi se requi re l ar ge val ues of M.
When e t f e i s appl i ed to ti me seri es, the cor respondi ng spectr al esti mate i s
nor mal i zed i n the way that i s defi ned i n Some Speci al Topi cs on page 3-68.
Note that thi s nor mal i zati on may di ffer fr om the one used by s pe ct r um i n the
Si gnal Processi ng Tool box.
Examples Compare an empi ri cal tr ansfer functi on esti mate to a smoothed spectral
esti mate:
ge = et f e ( z ) ;
gs = s pa( z ) ;
bodepl ot ( [ ge gs ] )
Algorithm The empi r i cal tr ansfer functi on esti mate i s computed as the r ati o of the output
Fouri er transform to the i nput Four i er tr ansfor m, usi ng f f t . The per i odogram
y t ( ) G q ( )u t ( ) v t ( ) + =
G e
i
( )
etfe
4-33
i s computed as the normal i zed absol ute squar e of the Four i er transform of the
ti me seri es.
The smoothed versi ons (Ml ess than the l ength of z ) ar e obtai ned by appl yi ng a
Hammi ng wi ndow to the output FFT ti mes the conjugate of the i nput FFT, and
to the absol ute squar e of the i nput FFT, respecti vel y, and subsequentl y
formi ng the rati o of the r esul ts. The l ength of thi s Hammi ng wi ndow i s equal
to the number of data poi nts i n z di vi ded by M, pl us one.
See Also f r e qf unc, s pa
ffplot
4-34
ffpl ot
Purpose Pl ot fr equency functi ons and spectr a.
Syntax f f pl ot ( g)
f f pl ot ( [ g1 g2 . . . gn] )
f f pl ot ( g, s d, C, mode )
Description Thi s functi on has exactl y the same syntax as bode pl ot . The onl y di fference i s
that i t gi ves gr aphs wi th l i near frequency scal es and Hz as the fr equency uni t.
See Also bodepl ot , f r eqf unc , get f f
fixpar
4-35
fi xpar
Purpose Fi x parameter s i n str uctur es defi ned by ms 2t h and ar x2t h.
Syntax t hn = f i x par ( t ho, mat r i x)
t hn = f i x par ( t ho, mat r i x, el e me nt s , par v al )
Description The f i xpar functi on produces a new model str uctur e t hn i n the theta format
from an ol d one t ho, by fi xi ng certai n par ameters to certai n val ues. The matri x
t ho must be or i gi nal l y defi ned by ar x , ar x 2t h, c ans t ar t , i v4, or ms 2t h but may
have been modi fi ed l ater on by f i xpar , pe m, t hi ni t , or unf i x par .
To modi fy a state-space structure
the ar gument mat r i x i s set equal to one of ' A' , ' B' , ' C' , ' D' ,' K' , or ' x0' . The
ar gument el ement s i s a matri x wi th two col umns, i n whi ch each row speci fi es
the i ndi ces of the el ement i n the chosen system matri x that need to be fi xed.
For exampl e, to fi x the 1,2-el ement and the 3,5-el ement of the A matr i x use
t hn = f i x par ( t ho, ' A' , [ 1, 2; 3, 5] ) ;
I f the ar gument el eme nt s i s omi tted (or enter ed as the empty matri x) al l
el ements of the i ndi cated matr i x wi l l be fi xed. I n thi s case par val can be gi ven
a scal ar number, and al l the i ndi cated el ements wi l l be fi xed to that number.
The defaul t i s that the el ements are fi xed to thei r nomi nal (i ni ti al or cur rentl y
esti mated) val ue. To fi x them to somethi ng el se use the four th i nput ar gument
par val . The r -th entr y of thi s vector contai ns the val ue cor respondi ng to the
el ement defi ned by the r -th row of el ement s .
To modi fy an ARX model
the ar gument mat r i x i s set equal to one of ' A1' , ' A2' , ..., ' B0' , ' B1' , .... The
ar gument e l e ment s i s then a matri x wi th two col umns, where each r ow gi ves
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 ( ) + + + +
fixpar
4-36
the i ndi ces of the el ement i n the chosen ARX matri x that need to be fi xed. The
rol e of par val i s the same as for the state-space case above.
The r outi ne does not appl y to speci al model structures that you have or i gi nal l y
defi ned usi ng mf 2t h, or to bl ack-box i nput-output model s other than ARX
model s. Fi xi ng certai n parameter s can, i n those cases, be achi eved by usi ng the
thi rd argument i n pem duri ng the esti mati on phase.
Examples Conver ti ng a state-space structure wi th al l el ements i n the Kal man gai n
matr i x K fr ee to an output er ror str ucture i n whi ch K i s fi xed to zero.
t hn = f i x par ( t hn, ' K' , [ ] , 0)
Fi xi ng the parameter to 1 i n a scal ar ARX model , and then esti mati ng the
remai ni ng parameter s:
t h = ar x( z , [ 2 3 0] ) ;
t h = f i xpar ( t h, ' B2' , [ 1, 1] , 1) ;
t h = pe m( z , t h) ;
See Also t he t a, t hi ni t , unf i x par
b
2
freqfunc
4-37
fr eqfunc
Purpose Descri be the frequency-functi on format.
Syntax he l p f r eqf unc
Description Frequency functi ons ar e created by et f e , s pa, and t h2f f , and used by
bodepl ot , f f pl ot , and ny qpl ot . The i nter nal format of the fr eqfunc for mat i s
i ntended to be tr ansparent. The basi c way to di spl ay the i nformati on i s to use
the pl ot commands. You can al so retr i eve the i nformati on fr om the format by
the functi on get f f . Thi s entr y gi ves detai l s of the i nternal representati on, but
thi s i nformati on i s not necessary for nor mal use of the System I denti fi cati on
Tool box.
The fr eqfunc for mat contai ns i nformati on about frequency val ues, ampl i tudes,
and phases, as wel l as thei r standard devi ati ons. These ar e al l gi ven as
col umns. The fi r st row of a f r e qf unc matr i x contai ns i nteger s, that, i n coded
form, descri be the si gni fi cance of the col umn i n questi on. The i nterpr etati on of
these i ntegers i s as fol l ows:
For transfer functi ons and spectr a associ ated wi th output number 1:
n = 0 : The col umn i s a spectr um.
n = 50: The col umn contai ns standard devi ati ons of a spectrum.
n = 100: The col umn contai ns frequenci es for the spectrum.
n = k, wher e k i s val ue between 1 and 19: The col umn contai ns ampl i tude
val ues for the transfer functi on associ ated wi th i nput number k.
n = k + 20: The col umn contai ns phase val ues (i n degr ees) for i nput number k.
n = k + 50: The col umn contai ns ampl i tude standard devi ati ons for i nput
number k.
n = k + 70: The col umn contai ns phase standard devi ati ons for i nput number
k.
n = k + 100: The col umn contai ns the fr equency val ues for i nput number k.
For the same quanti ti es associ ated wi th output number , add 1000
to the number s above.
ky ky 1 ( )
freqfunc
4-38
The speci fi ed fr equenci es are for a di scr ete-ti me model , whi ch i s by defaul t,
equal l y spaced from 0 (excl uded) to over 128 val ues. Here T i s the
sampl i ng i nterval (defaul t = 1). For a conti nuous-ti me model , the fr equenci es
ar e 128 val ues, l ogar i thmi cal l y spr ead over thr ee decades, up to a decade over
the underl yi ng Nyqui st fr equency (see t h2f f ).
Examples You can compute and graph the frequency functi ons at arbi trar y frequency w (a
row vector wi th an ar bi tr ary number of el ements) wi th
g = s pa( z , M, w)
g = t h2f f ( t h, ku, w)
The MATLAB functi on l ogs pac e i s useful for creati ng such frequency vector s.
See Also bodepl ot , e t f e , f f pl ot , get f f , nyqpl ot , s et t , s pa, t h2f f
T
getff
4-39
getff
Purpose Retri eve fr equency functi ons and spectr a fr om the fr eqfunc for mat.
Syntax [ w, amp, phas ] = get f f ( g)
[ w, amp, phas , s damp, s dphas ] = get f f ( g, ku, ky)
Description Thi s functi on extr acts i nformati on fr om the fr eqfunc for mat for pl otti ng as an
al ter nati ve to bodepl ot , f f pl ot , and ny qpl ot . Resul ts i n the fr eqfunc format
ar e obtai ned by e t f e, s pa, and t h2f f .
The argument g i s the fr equency functi on or spectrum gi ven i n the freqfunc
format. ku i s the chosen i nput number (onl y one) and ky i s the chosen output
number. The noi se source i s counted as i nput number 0, so that ku = 0 wi l l
extr act spectral i nfor mati on.
w i s a vector contai ni ng the frequency val ues (i n r adi ans/second). amp contai ns
the val ues of the magni tude (ampl i tude) of the fr equency functi on and phas
contai ns the phase val ues (i n degrees). The output ar guments s damp and
s dphas contai n the corr espondi ng standard devi ati ons. Al l thi s i nfor mati on i s
for i nput number ku and output number ky . I f several entr i es i n g cor respond
to the same i nput-output pai r , then w, amp, phas , s damp, and s dphas have the
cor respondi ng number of col umns. The defaul t val ues of ku and ky are both 1,
unl ess g contai ns onl y spectra. I n that case get f f extracts i nfor mati on about
the spectrum cor respondi ng to output number ky.
Examples Make your own pl ot of the per i odogram wi th l i near scal es:
per = e t f e( y ) ;
[ w, amp] = ge t f f ( pe r ) ;
pl ot ( w, amp)
t i t l e ( ' Pe r i odogr am of s ei s mi c dat a' )
getzp
4-40
getzp
Purpose Extract zer os and pol es from the zepo format.
Syntax [ z e , po] = get z p( z e po)
[ z e , po] = get z p( z e po, ku, ky)
Description The basi c use of ge t z p i s to extract the pol es and zer os of the coded for mat that
t h2z p r esul ts i n. z epo contai ns thi s i nfor mati on and i s typi cal l y the output of
t h2z p. ku contai ns the i nput number (just one) and ky the output number. The
noi se source number k i s here counted as i nput number k.
z e contai ns the zer os and po the pol es of the dynami cs associ ated wi th i nput
number ku and output number ky . The defaul t val ues of ku and ky ar e both 1.
Note that for the noi se dynami cs, z e po normal l y just contai ns i nfor mati on
about the zer os and pol es from noi se sour ce k to output number k, (no cr oss
terms). To extr act thi s i nfor mati on enter
[ z e , po] = ge t z p( z e po, 0, k)
See Also t h2z p, z pf or m, z ppl ot
getmfth, getncap, gett
4-41
getmfth , getncap, gett
Purpose Extract i nformati on fr om the theta for mat.
Syntax my mf i l e = get mf t h( t h)
N = get nc ap( t h)
T = get t ( t h)
Description These functi ons retr i eve some i nfor mati on that i s coded i nto the theta format.
my mf i l e i s the name of the M-fi l e that you wr i te to defi ne a model str uctur e
cr eated by mf 2t h.
N i s the number of data, from whi ch a cer tai n model t h i s esti mated. I f the
model i s not esti mated N i s r etur ned as [ ] .
T i s the sampl i ng i nterval of the model t h. I f T i s negati ve, the model i s a
conti nuous-ti me one that has been esti mated from data wi th the sampl i ng
i nter val abs ( T) .
See Also mf 2t h, s e t t
ident
4-42
i dent
Purpose Open the graphi cal user i nter face
Syntax i de nt
i de nt ( s es s i on, di r e ct or y)
Description i de nt by i tsel f opens the mai n i nter face wi ndow, or bri ngs i t forward i f i t i s
al r eady open.
s es s i on i s the name of a pr evi ous sessi on wi th the graphi cal i nter face, and
typi cal l y has extensi on . s i d. di r ec t or y i s the compl ete path for the l ocati on of
thi s fi l e. I f the sessi on fi l e i s on the MATLABPATH, di r e ct or y can be omi tted.
When the sessi on i s speci fi ed, the i nterface wi l l open wi th thi s sessi on acti ve.
Typi ng i dent ( s e s s i on, di r ec t or y ) on the MATLAB command l i ne, when the
i nterface i s acti ve, wi l l l oad and open the sessi on i n questi on.
For more i nformati on about the graphi cal user i nterface, see Chapter 2 of thi s
manual .
Examples i de nt ( i ddat a1. s i d )
i de nt ( my dat a. s i d , \mat l ab\dat a\cdpl aye r \ )
idfilt
4-43
i dfi l t
Purpose Fi l ter data usi ng Butterworth fi l ter s.
Syntax z f = i df i l t ( z , or d, Wn)
[ z f , t hf ] = i df i l t ( z , or d, Wn, hs )
Description i df i l t computes a Butterworth fi l ter of order or d and fi l ter s al l col umns of the
data matr i x
z = [ y u]
through thi s fi l ter .
I f hs i s not speci fi ed and Wn contai ns just one el ement, a l ow pass fi l ter wi th
cutoff fr equency Wn (measured as a fr acti on of the Nyqui st frequency) i s
obtai ned. I f hs =' hi gh' a hi gh pass fi l ter wi th thi s cutoff fr equency i s
obtai ned i nstead.
I f Wn = [ Wnl Wnh] i s a vector wi th two el ements, a fi l ter (of or der 2*or d) wi th
passband between Wnl and Wnh i s obtai ned i s hs i s not speci fi ed. I f
hs = ' s t op' a bandstop fi l ter wi th stop band between these two fr equenci es i s
obtai ned i nstead.
The output ar gument t hf i s the fi l ter gi ven i n the theta for mat.
I t i s common pr acti ce i n i denti fi cati on to sel ect a fr equency band where the fi t
between model and data i s concentr ated. Often thi s cor responds to bandpass
fi l teri ng wi th a pass band over the i nter esti ng br eakpoi nts i n a Bode di agr am.
I f or d i s a posi ti ve i nteger , a non-causal , zero-phase fi l ter i s used for the
fi l teri ng. I f or d i s a negati ve i nteger, a causal fi l ter (of or der abs ( or d) ) i s used
i nstead.
Algorithm The used fi l ter i s the same as but t er i n the Si gnal Pr ocessi ng Tool box woul d
gi ve. Al so, the zer o-phase fi l ter i s equi val ent to f i l t f i l t i n that tool box.
References Ljung (1987), Chapter 13.
idinput
4-44
i di nput
Purpose Gener ate si gnal s, typi cal l y to be used as i nputs for i denti fi cati on.
Syntax u = i di nput ( N)
u = i di nput ( N, t y pe , band, l ev el s )
u = i di nput ( N, ' s i ne' , band, l ev el s , aux var )
Description i di nput generates i nput si gnal s of di ffer ent ki nds, that ar e typi cal l y used for
i denti fi cati on purposes. Onl y scal ar i nputs are gener ated.
N i s the number of data poi nts gener ated, i .e., the l ength of u.
t ype defi nes the type of i nput si gnal to be generated. Thi s argument takes one
of the fol l owi ng val ues:
t y pe = ' r s ' : Thi s gi ves a random, Gaussi an si gnal .
t ype = ' r bs ' : Thi s gi ves a r andom, bi nary si gnal .
t ype = ' pr bs ' : Thi s gi ves a pseudo-random, bi nary si gnal .
t y pe = ' s i ne' : Thi s gi ves a si gnal whi ch i s a sum of si nusoi ds.
Defaul t i s t y pe = ' r bs ' .
The frequency contents of the si gnal i s determi ned by the argument band. For
the choi ces t y pe = ' r s ' , ' r bs ' , and ' s i ne' , thi s ar gument i s a r ow-vector wi th
two entr i es
band = [ wl ow, whi gh]
that deter mi ne the l ower and upper bound of the pass-band. The frequenci es
wl ow and whi gh ar e expr essed i n fr acti ons of the Nyqui st fr equency. A whi te
noi se char acter i nput i s thus obtai ned for band = [ 0 1] , whi ch al so i s the
defaul t val ue.
For the choi ce t y pe = ' pr bs ' we have
band = [ t wol ogp, M]
where the per i odi ci ty of the gener ated PRBS i s 2^t wol ogp 1, and Mi s such
that the si gnal i s constant over i nter val s of l ength 1/M. t wol ogp = 0 gi ves the
maxi mum l ength PRBS, corr espondi ng to t wol ogp = 18. Al so i n thi s case the
defaul t i s band = [ 0 1] .
idinput
4-45
The argument l ev el s defi nes the i nput l evel . I t i s a r ow vector
l ev el s = [ mi nu, maxu]
such that the si gnal u wi l l al ways be between the val ues mi nu and maxu for the
choi ces t y pe = ' r bs ' , ' pr bs ' and ' s i ne ' . For t y pe = ' r s ' , the si gnal l evel
i s such that mi nu i s the mean val ue of the si gnal , mi nus one standar d devi ati on,
whi l e max u i s the mean val ue pl us one standard devi ati on. Gaussi an whi te
noi se wi th zero mean and var i ance one i s thus obtai ned for
l e v el s = [ 1, 1] , whi ch i s al so the defaul t val ue.
For the opti on t y pe = ' s i ne ' , ther e i s a fourth argument
aux var = [ no_of _s i nus oi ds , no_of _t r i al s ]
determi ni ng the number of si nusoi ds to be used i n the i nput si gnal . The
var i abl e no_of _t r i al s deter mi nes how many tri al s to be made to mi ni mi ze the
si gnal ampl i tude by assi gni ng r andom phases to the di fferent si nusoi ds.
Defaul t i s auxv ar = [ 10, 10] .
Algorithm Very si mpl e al gori thms are used. The frequency contents i s achi eved for ' r s '
by an ei ghth order Butterworth, non-causal fi l ter, usi ng i df i l t . Thi s i s qui te
rel i abl e. The same fi l ter i s used for the ' r bs ' case, befor e maki ng the si gnal
bi nary. Thi s means that the fr equency contents i s not guar anteed to be pr eci se
i n thi s case.
For the ' s i ne' case, the frequenci es are sel ected to be equal l y spr ead over the
chosen pass band, and each si nusoi d i s gi ven a random phase. A number of
tr i al s are made, and the phases that gi ve the smal l est si gnal ampl i tude ar e
sel ected. (The ampl i tude i s then scal ed so as to sati sfy the speci fi cati ons of
l e v el s .)
See Also The Fr equency Domai n System I denti fi cati on Tool box contai ns sever al
commands for i nput desi gn that uti l i ze mor e sophi sti cated al gor i thms.
Reference For PRBS, see, e.g., Sder str m and Stoi ca (1989), Chapter C5.3.
idmodred
4-46
i dmodr ed
Purpose Reduce the order of a model i n theta format.
Syntax THRED = i dmodr ed( TH)
THRED = i dmodr ed( TH, ORDER, OE)
Description Thi s functi on reduces the order of any model TH gi ven i n the theta for mat. The
resul ti ng reduced or der model THRED i s al so i n the theta for mat. Thi s r educed
model i s al ways r epr esented i nter nal l y i n state-space for m wi th no free
par ameters, r egar dl ess of the natur e of the model TH.
The functi on requi r es sever al routi nes i n the Control Systems Tool box.
ORDER: The desi red or der (di mensi on of the state-space repr esentati on). I f
ORDER = [ ] , whi ch i s the defaul t, a pl ot wi l l show how the di agonal el ements
of the obser vabi l i ty and contr ol l abi l i ty Grami ans decay wi th the order of the
repr esentati on. You wi l l then be pr ompted to sel ect an order based on thi s pl ot.
The i dea i s that such a smal l el ement wi l l have a negl i gi bl e i nfl uence on the
i nput-output behavi or of the model . I t i s thus suggested that an order i s chosen,
such that onl y l ar ge el ements i n these matr i ces ar e r etai ned.
OE: I f the argument OE has the val ue oe, then an output err or model THRED i s
produced, that i s, one wi th the Kal man gai n equal to zero (see (3.27) and (3.31)
i n Chapter 3, "Tutori al "). Other wi se (defaul t), al so the noi se model i s reduced.
The functi on wi l l r ecogni ze whether TH i s a conti nuous- or di scr ete-ti me model
and per form the r educti on accor di ngl y. The r esul ti ng model THRED wi l l be of the
same ki nd i n thi s r espect as TH.
Algorithm The functi ons ( d) bal r e al and ( d) modr e d from the Contr ol Systems Tool box
ar e used. The pl ot, i n case ORDER = [ ] , shows the vector g as r etur ned fr om
( d) bal r eal .
Examples Bui l d a hi gh order mul ti var i abl e ARX model , r educe i ts order to 3 and compar e
the frequency r esponses of the or i gi nal and reduced model s:
TH = ar x( [ y u] , [ 4one s ( 3, 3) , 4ones ( 3, 2) , one s ( 3, 2) ] ) ;
THRED = i dmodr ed( TH, 3) ;
bodepl ot ( [ t r f ( TH) , t r f ( THRED) ] )
idmodred
4-47
Use the reduced order model as i ni ti al condi ti on for a thi r d or der state-space
model :
THI = s s 2t h( THRED) ;
THSS = pe m( [ y u] , THI ) ;
See Also s s 2t h
idplot
4-48
i dpl ot
Purpose Pl ot i nput-output data.
Syntax i dpl ot ( z )
i dpl ot ( z , i nt , T, ny, pc )
Description z i s the output-i nput data z = [ y u] to be graphed. A spl i t pl ot i s obtai ned wi th
the output on top and the i nputs, one by one i f several , at the bottom. Pr essi ng
the Return key advances the pl ot.
The data poi nts speci fi ed i n the r ow vector i nt are graphed. The defaul t val ue
of i nt i s al l the data. You can use the sampl i ng i nterval T (defaul t T = 1) to
gi ve correct ti me axes.
The argument ny i s the number of outputs i n the data matr i x. Defaul t i s
ny = 1. The i nput i s pi ecewi se constant between sampl i ng poi nts, and i t i s
gr aphed accordi ngl y. I f you pr efer l i near i nter pol ati on between i nput data
poi nts, use pc = ' l i ' . The defaul t val ue i s pc = ' pc ' .
Examples Pl ot onl y a por ti on of the data poi nts:
i dpl ot ( z , 100: 200)
idresamp
4-49
i dresamp
Purpose Resampl e data by i nter pol ati on and deci mati on.
Syntax z r = i dr e s amp( z , R)
[ z r , R_ac t ] = i dr e s amp( z , R, f i l t er _or de r , t ol )
Description z : The data to be resampl ed. Each col umn of z contai ns a si gnal .
z r : The r esampl ed data. The col umns of z r cor respond to those of z .
R : The resampl i ng factor. The new data r ecord wi l l cor respond to a new
sampl i ng i nter val of R ti mes the or i gi nal one. R > 1 thus corr esponds to
deci mati on and R < 1 cor responds to i nter pol ati on. Any posi ti ve r eal number
for R i s al l owed, but i t wi l l be r epl aced by a rati onal approxi mati on (R_ac t ).
R_act : The actual l y achi eved r esampl i ng factor .
f i l t e r _or de r : The or der of the presampl i ng fi l ters used before i nter pol ati on
and deci mati on. Defaul t i s 8.
t ol : The tol erance i n the rati onal appr oxi mati on of R. Defaul t i s 0.1.
Algorithm The resampl i ng factor i s fi r st approxi mated by a r ati onal number by
[ num, de n] = r at ( R, t ol ) . The data ar e then i nterpol ated by a factor de n and
then deci mated by a factor num. The i nterpol ati on and deci mati on are pr eceded
by pr efi l teri ng, and fol l ow the same al gori thms as i n the routi nes i nt e r p and
de c i mat e i n the Si gnal Processi ng Tool box.
Caution For si gnal s that have much energy around the Nyqui st frequency (l i ke
pi ece-wi se constant i nputs), the r esampl ed wavefor m may l ook very di ffer ent,
due to the pr efi l teri ng effects. The frequency and i nformati on contents for
i denti fi cati on i s, however, not mi shandl ed.
Example Resampl e by a factor 1.5 and compar e the si gnal s.
pl ot ( t , u)
[ ur , r a] = i dr e s amp( u, 1. 5) ;
pl ot ( t , u, r at , ur )
idsim
4-50
i dsi m
Purpose Si mul ate systems speci fi ed i n theta format.
Syntax y = i ds i m( [ u e ] , t h)
[ y, y s d] = i ds i m( u, t h)
Description t h descri bes an ar bi tr ar y model i n the theta for mat. i ds i m r etur ns y contai ni ng
the si mul ated output, cor respondi ng to the i nput sequence u (one col umn for
each i nput) and the noi se e . I f e i s omi tted, a noi se-free si mul ati on i s obtai ned.
The noi se-sequence e i s scal ed by , where i s the noi se var i ance (l oss
functi on) as speci fi ed by t h. To achi eve the cor rect noi se effect, gi ve e zero mean
and uni t var i ance.
For mul ti -output systems si mul ated wi th noi se, e shoul d have as many
col umns as the number s of outputs. The noi se i s agai n scal ed usi ng the noi se
covari ance matr i x i n t h.
The second output argument i s the standard devi ati on of the si mul ated output.
Thi s opti on i s however not avai l abl e for state-space model s.
I f t h i s a conti nuous-ti me model , i t i s fi rst conver ted to di scr ete ti me wi th
sampl i ng i nterval abs ( T) . See Some Speci al Topi cs on page 3-68
Examples Si mul ate a gi ven system t h0 (for exampl e created by pol y 2t h):
e = r andn( 500, 1) ;
u = i di nput ( 500, pr bs ) ;
y = i ds i m( [ u e ] , t h0) ;
Val i date a model by compari ng a measured output y wi th one si mul ated usi ng
an esti mated model t h:
y h = i ds i m( u, t h) ;
pl ot ( [ y y h] )
Algorithm I n case the model i s of i nput-output type, i ds i m uses the MATLAB f i l t er
functi on. For state-space model s, i t uses l t i t r .
See Also i ds i ms d, pol y2t h

idsimsd
4-51
i dsi msd
Purpose Si mul ate theta format system wi th uncertai nty.
Syntax i ds i ms d( u, t h)
i ds i ms d( u, t h, N, noi s e )
Description u i s a col umn vector (matri x) contai ni ng the i nput(s). t h i s a model gi ven i n the
theta format (see t het a) . N r andom model s ar e created, accor di ng to the
covari ance i nfor mati on gi ven i n t h. The responses of each of these model s to
the i nput u are computed and gr aphed i n the same di agr am. I f
noi s e = ' noi s e ' , noi se i s added to the si mul ati on, i n accordance wi th the noi se
model of t h, and i ts own uncer tai nty.
The defaul t val ues are
N = 10
noi s e = ' nonoi s e '
Examples Pl ot the step response of the model t h and eval uate how i t var i es i n vi ew of the
model s uncer tai nty:
s t e p1 = [ z e r os ( 5, 1) ; ones ( 20, 1) ] ;
i ds i ms d( s t e p1, t h)
See Also i ds i m, t h2f f , t h2z p
ivar
4-52
i var
Purpose Esti mate the parameter s of an AR model usi ng an appr oxi matel y opti mal
choi ce of i nstr umental vari abl e pr ocedur e.
Syntax t h = i v ar ( y , na)
t h = i v ar ( y , na, nc, maxs i z e , T)
Description The parameter s of an AR model str uctur e
ar e esti mated usi ng the i nstr umental var i abl e method. y i s the si gnal to be
model ed, entered as a col umn vector. na i s the or der of the A pol ynomi al (the
number of A par ameters). The r esul ti ng esti mate i s r etur ned as t h, i n theta
format. The r outi ne i s for scal ar si gnal s onl y.
I n the above model , i s an arbi trar y process, assumed to be a movi ng
aver age process of or der nc , possi bl y ti me varyi ng. (Defaul t i s nc = na.)
I nstruments ar e chosen as appr opr i atel y fi l ter ed outputs, del ayed nc steps.
The opti onal arguments maxs i z e and T ar e expl ai ned under aux var .
Examples Compare spectra for si nusoi ds i n noi se, esti mated by the I V method and
esti mated by the forward-backwar d l east-squares method:
y = s i n( [ 1: 500] ' 1. 2) + s i n( [ 1: 500] ' 1. 5) . . .
+ 0. 2r andn( 500, 1) ;
t hi v = i v ar ( y, 4) ;
t hl s = ar ( y, 4) ;
gi v = t h2f f ( t hi v ) ;
gl s = t h2f f ( t hl s ) ;
bodepl ot ( [ gi v gl s ] )
See Also ar , e t f e, s pa
References Stoi ca, P. et al ., Optimal I nstrumental variable estimates of the AR-parameters
of an ARMA process, I EEE Tr ans. Autom. Contr ol , Vol AC-30, 1985, pp.
1066-1074.
A q ( )y t ( ) v t ( ) =
v t ( )
ivstruc
4-53
i vstr uc
Purpose Compute fi t between si mul ated and measur ed output for a gr oup of model
str uctur es.
Syntax v = i vs t r uc ( z e, z v, NN)
v = i vs t r uc ( z e, z v, NN, p, max s i z e)
Description NN i s a matri x that defi nes a number of di ffer ent str uctur es of the ARX type.
Each row of NN i s of the form
nn = [ na nb nk]
wi th the same i nter pretati on as descri bed for ar x. See s t r uc for easy
gener ati on of typi cal NN matr i ces for si ngl e-i nput systems.
Each of z e and z v ar e matri ces contai ni ng output-i nput data [ y u] . For
mul ti -i nput systems, u has the corr espondi ng number of col umns. Model s for
each model str uctur e defi ned i n NN are esti mated usi ng the i nstrumental
var i abl e (I V) method on data set z e . The esti mated model s are si mul ated usi ng
the i nputs from data set z v . The normal i zed quadrati c fi t between the
si mul ated output and the measured output i n z v i s formed and returned i n v .
The rows bel ow the fi rst row i n v ar e the tr anspose of NN, and the l ast r ow
contai ns the l ogari thms of the condi ti on number s of the I V matri x
A l ar ge condi ti on number i ndi cates that the structure i s of unnecessari l y hi gh
order (see page 415 i n Ljung (1987)).
The i nformati on i n v i s best anal yzed usi ng s e l s t r uc .
I f p i s equal to zero, the computati on of condi ti on numbers i s suppr essed. For
the use of max s i z e, see auxv ar .
The routi ne i s for si ngl e-output systems onl y.
IMPORTANT: The I V method used does not guarantee that the obtai ned
model s are stabl e. The output-err or fi t cal cul ated i n v may then be mi sl eadi ng.
t ( )
T
t ( )

ivstruc
4-54
Examples Compare the effect of di ffer ent orders and del ays, usi ng the same data set for
both the esti mati on and val i dati on:
v = i vs t r uc( z , z , s t r uc( 1: 3, 1: 2, 2: 4) ) ;
nn = s e l s t r uc( v)
t h = i v 4( z , nn) ;
Algorithm A maxi mum or der ARX model i s computed usi ng the l east-squares method.
I nstruments ar e generated by fi l teri ng the i nput(s) thr ough thi s model . The
model s are subsequentl y obtai ned by operati ng on submatri ces i n the
cor respondi ng l ar ge I V matr i x.
See Also ar x s t r uc, i v 4, s el s t r uc , s t r uc
ivx
4-55
i vx
Purpose Esti mate the parameter s of an ARX model usi ng the i nstrumental var i abl e (I V)
method wi th arbi trar y i nstruments.
Syntax t h = i v x( z , nn, x )
t h = i v x( z , nn, x , maxs i z e, T)
Description i v x i s a routi ne anal ogous to the i v4 r outi ne, except that you can use arbi trary
i nstruments. These are contai ned i n the matri x x . Make thi s the same si ze as
the output, i .e., the fi r st col umn(s) of z . The i nstruments used are then
anal ogous to the regr essi on vector i tsel f, except that y i s r epl aced by x.
Note that i v x does not r etur n any esti mated covar i ance matri x for t h, si nce
that r equi r es addi ti onal i nfor mati on.
Use i v4 as the basi c I V r outi ne for ARX model structures. The mai n i nter est i n
i v x l i es i n i ts use for nonstandar d si tuati ons; for exampl e when there i s
feedback pr esent i n the data, or when other i nstruments need to be tri ed out.
Note that there i s al so an I V ver si on that automati cal l y generates i nstr uments
from certai n fi l ter s you defi ne (type he l p i v ).
See Also i v 4, i v ar
References Ljung (1987), page 198.
iv4
4-56
i v4
Purpose Esti mate the parameter s of an ARX model usi ng an appr oxi matel y opti mal
four -stage i nstrumental vari abl e (I V) pr ocedur e.
Syntax t h = i v 4( z , nn)
t h = i v 4( z , nn, maxs i z e, T)
Description Thi s r outi ne i s an al ter nati ve to ar x and the use of the arguments ar e enti rel y
anal ogous to the ar x functi on. The mai n di fference i s that the procedure i s not
sensi ti ve to the col or of the noi se ter m i n the model equati on.
For an i nter pretati on of the l oss functi on (i nnovati ons covari ance matr i x),
consul t Some Speci al Topi cs on page 3-68.
Examples Her e i s an exampl e of a two-i nput one-output system wi th di fferent del ays on
the i nputs and :
z = [ y u1 u2] ;
nb = [ 2 2] ;
nk = [ 0 2] ;
t h = i v 4( z , [ 2 nb nk] ) ;
Algorithm The fi rst stage uses the ar x functi on. The resul ti ng model gener ates the
i nstruments for a second-stage I V esti mate. The resi dual s obtai ned fr om thi s
model ar e model ed as a hi gh-or der AR model . At the fourth stage, the
i nput-output data ar e fi l tered through thi s AR model and then subjected to the
I V functi on wi th the same i nstrument-fi l ter s as i n the second stage.
For the mul ti -output case, opti mal i nstruments ar e obtai ned onl y i f the noi se
sources at the di fferent outputs have the same col or. The esti mates obtai ned
wi th the routi ne are reasonabl y accurate though even i n other cases.
See Also ar x , oe
References Ljung (1987), equati ons (15.21)-(15.26).
e t ( )
u
1
u
2
mf2th
4-57
mf2th
Purpose Package model structures you defi ne i nto the theta model for mat.
Syntax t h = mf 2t h( mode l , c d, par v al )
t h = mf 2t h( mode l , c d, par v al , aux, l ambda, T)
Description t h i s retur ned as a model str uctur e i n the theta for mat. mode l i s the name of
an M-fi l e that defi nes how the state-space matri ces depend on the par ameters
to be esti mated. The for mat of thi s M-fi l e i s gi ven bel ow. The argument c d must
be assi gned ei ther the val ue ' c' whi ch desi gnates that the underl yi ng
parameter i zati on r efer s to a conti nuous-ti me model , or the val ue ' d' ,
i ndi cati ng that the model parameter i zati on i s i nher entl y a di screte-ti me one.
The argument par val contai ns the nomi nal val ues of the parameter s. Thi s i s a
row vector of the same l ength as the number of fr ee par ameters i n the model
str uctur e. The argument aux i s a matr i x of auxi l i ar y var i abl es that the M-fi l e
can use for vari ous pur poses.
T denotes the sampl i ng i nterval of the data, for whi ch the model i s goi ng to be
esti mated (and the sampl i ng i nterval that i s used when the model i s used for
si mul ati on and pr edi cti on). Gi ve T a posi ti ve val ue even i f the underl yi ng model
i s defi ned to be conti nuous ti me.
The model str uctur e corr esponds to the general l i near state-space structur e
The matri ces i n thi s ti me-di scr ete model can be parameter i zed i n an ar bi tr ary
way by the vector . Wr i te the for mat for the M-fi l e as fol l ows:
[ A, B, C, D, K, x 0] = mymf i l e( par s , T, aux )
Her e the r ow vector par s contai ns the par ameters , and the output
ar guments A, B, C, D, K, and x 0 ar e the matr i ces i n the di scr ete-ti me model
descr i pti on that corr espond to thi s val ue of the parameter 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 i s the sampl i ng i nterval , and aux i s any matr i x of auxi l i ar y var i abl es wi th
whi ch you want to wor k. (I n that way you can change certai n constants and
other aspects i n the model structur e wi thout havi ng to edi t the M-fi l e.) Note
that the two arguments T and aux must be i ncl uded i n the functi on head of the
M-fi l e, even i f they ar e not uti l i zed wi thi n the M-fi l e.
I f the under l yi ng parameter i zati on i s a conti nuous-ti me one, i t i s sti l l the
di screte-ti me model matr i ces, cor respondi ng to the sampl i ng i nterval T that
shoul d be del i ver ed by the M-fi l e. However . i t i s desi r abl e that i f the M-fi l e
myf i l e i s cal l ed wi th a negati ve val ue of T, i t outputs the matri ces of the
cor respondi ng conti nuous-ti me state-space model . I f such a featur e i s i ncl uded
i n the M-fi l e, use cd = ' c' . Thi s al l ows for easy transformati ons between
conti nuous and di screte ti me usi ng the normal functi ons t hc 2t hd and t hd2t hc.
Defi ni ng Model Structures on page 3-29 contai ns several exampl es of typi cal
M-fi l es that defi ne model structures.
Examples Use the M-fi l e ' my noi s e ' gi ven i n Secti on 6 to obtai n a physi cal
par ametri zati on of the Kal man gai n:
t hn = mf 2t h( ' mynoi s e ' , ' d' , [ 0. 1, 2, 1, 3, 0. 2] , 1)
t h = pe m( z , t hn)
midprefs
4-59
mi dprefs
Purpose Sel ect a di rectory for i dpr e f s . mat , a fi l e that stor es the graphi cal user
i nter faces star t-up i nfor mati on.
Syntax mi dpr ef s
mi dpr ef s ( pat h)
Description The graphi cal user i nterface i de nt al l ows a l arge number of vari abl es for
customi zed choi ces. These i ncl ude the wi ndow l ayout, the defaul t choi ces of
pl ot opti ons, and names and di rectori es of the four most r ecent sessi ons wi th
i de nt . Thi s i nfor mati on i s stor ed i n the fi l e i dpr e f s . mat , whi ch shoul d be
pl aced on the users MATLABPATH. The defaul t, automati c l ocati on for thi s fi l e i s
i n the same di rectory as the users s t ar t up. m fi l e.
mi dpr ef s i s used to sel ect or change the di rectory where you stor e
i dpr e f s . mat . Ei ther type mi dpr e f s , and fol l ow the i nstructi ons, or gi ve the
di rectory name as the ar gument. I ncl ude al l di r ectory del i mi ter s as i n the PC
case
mi dpr ef s ( ' c : \mat l ab\t ool box \l oc al \' )
or i n the UNI X case
mi dpr ef s ( ' /home/l j ung/mat l ab/' )
Warning The fi l e i dpr e f s . mat contai ns a var i abl e wi th the di r ector y name, whi ch al so
needs to be updated. Ther efor e, do not just move i t usi ng the fi l e system.
Al ways use mi dpr ef s to change the di rectory for i dpr e f s . mat .
modstruc
4-60
modstruc
Purpose Defi ne state-space str uctur e wi th unknown el ements.
Syntax ms = mods t r uc ( A, B, C, D, K)
ms = mods t r uc ( A, B, C, D, K, x 0)
Description mods t r uc i s, l i ke canf or m, a functi on that defi nes model par ameteri zati ons i n
state-space for m, whi ch are used i n ms 2t h to cr eate model structur es i n the
theta for mat. The onl y use of the r esul ti ng matri x ms i s as an i nput to ms 2t h.
The model consi dered i s i n state-space for m:
The functi on appl i es both to the conti nuous and di screte-ti me cases; whi ch one
i s determi ned onl y when the structure i s for med wi th ms 2t h.
The i nput ar guments A, B, C, D, K, and x0 ar e the matri ces of the above
state-space model . Numeri cal val ues i n these matr i ces i ndi cate fi xed (known)
entr i es, whi l e the symbol NaN marks an el ement that i s not known and you
need to esti mate.
The defaul t val ue of the i ni ti al state vector x0 i s the zer o vector , but i t may al so
contai n par ameters you need to esti mate.
Examples Defi ne a conti nuous-ti me model structure i n di agonal for m wi th the two
(real ) pol es and the numer ator unknown:
A = [ NaN, 0; 0, NaN] ;
B = [ NaN; NaN] ;
C = [ 1, 1] ;
D = 0;
K = [ 0; 0] ;
ms = mods t r uc( A, B, C, D, K)
t h = ms 2t h( ms , ' c ' ) ;
See Also c anf or m, f i x par , ms 2t h, t hi ni t , unf i xpar
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
ms2th
Purpose Package standar d state-space parameter i zati ons i nto the theta model for mat.
Syntax t h = ms 2t h( ms )
t h = ms 2t h( ms , c d, par val , l ambda, T)
Description The functi on returns t h as a model str ucture i n the theta for mat for further use
i n esti mati ng, si mul ati ng, and anal yzi ng model s. The ar gument ms defi nes
whi ch parameter s ar e fi xed and whi ch ones you need to esti mate. I t i s typi cal l y
formed by mods t r uc or c anf or m.
The argument c d i ndi cates whether the state-space matr i ces i n ms refer to a
conti nuous-ti me model (c d = ' c ' ) or a di scr ete-ti me model (c d = ' d' ).
cd = ' d' i s the defaul t.
For a conti nuous-ti me model ther e are two opti ons for how to sampl e i t, as i t i s
fi tted to obser ved sampl e data (i n pe m): By sel ecti ng c d = cz oh (conti nuous,
zero or der hol d) the i nput i s assumed to be pi ecewi se constant over the
sampl i ng i nter val . By sel ecti ng c d = cf oh (conti nuous, fi rst or der hol d), the
i nput i s supposed to be pi ecewi se l i near between the sampl es. Thi s means that
the conti nuous-ti me i nput u(t) i s obtai ned by l i near i nterpol ati on between the
sampl ed val ues. Use cd = cz oh (whi ch i s the defaul t for conti nuous-ti me
model s) i f the system has been control l ed usi ng a pi ece-wi se constant i nput.
Use cd = ' cf oh' i f the i nput has been a conti nuous functi on dur i ng the data
acqui si ti on.
The row vector par v al contai ns the nomi nal val ues of the free par ameters
(those that corr espond to NaN i n ms ). These nomi nal val ues are used as i ni ti al
esti mates when the par ameters i n t h are i denti fi ed wi th pe m. They ar e al so
used whenever the model t h i s si mul ated or anal yzed. The defaul t val ue of
par val i s al l zeros.
The number i ng of the par ameters i n par val (as wel l as i n al l other contexts
i n whi ch the model parameter s are l i sted) i s as fol l ows. The matr i x A i s fi rst
scanned, row by row, for fr ee par ameters, then the matri x B i s scanned, agai n
row by r ow, and then C, D, K, and X0 each of them r ow by row. The or der i n
whi ch the fr ee par ameters ar e found by thi s scanni ng defi nes the orderi ng i n
par val .
ms2th
4-62
Note that setti ng al l i ni ti al esti mates equal to zero i s not a good starti ng poi nt
for the i terati ve search for parameter esti mates i n pe m, si nce thi s case often
cor responds to a nonobser vabl e/noncontrol l abl e model . I t i s better to gi ve mor e
real i sti c val ues of par v al or to randomi ze them usi ng t hi ni t .
The argument l ambda gi ves the covar i ance matri x of the i nnovati on for the
sampl i ng i nter val i ndi cated i n T. The defaul t val ue of l ambda i s the uni t matr i x.
T denotes the sampl i ng i nterval of the data, for whi ch the model i s goi ng to be
esti mated (and the sampl i ng i nterval that i s used when the model i s used for
si mul ati on and predi cti on). Gi ve T a posi ti ve val ue even i f the underl yi ng model
i s defi ned to be conti nuous ti me.
Examples Defi ne a conti nuous-ti me model structure corr espondi ng to
wi th i ni ti al val ues
and esti mate the fr ee parameter s:
A = [ NaN, 0; 0, NaN] ;
B = [ NaN; NaN] ;
C = [ 1, 1] ;
ms = mods t r uc( A, B, C, 0, [ 0; 0] ) ;
t h = ms 2t h( ms , ' c ' , [ 0. 2, 0. 3, 2, 4] ) ;
t h = pe m( z , t h) ;
See Also c anf or m, f i x par , mods t r uc , pe m, t hi ni t , unf i x par
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 Sel ect the step si ze for numer i cal di fferenti ati on.
Syntax nds = nuder s t ( par s )
Description The functi on pe m uses numer i cal di fferenti ati on wi th respect to the model
parameter s when appl i ed to state-space structures. The same i s tr ue for the
functi ons t h2f f and t h2z p when the par ameter covar i ance i nformati on i s
tr ansl ated to frequency functi on and zero-pol e accuracy (agai n onl y for
state-space str uctur es). Fi nal l y, the command t hd2t hc uses numer i cal
di ffer enti ati on when transl ati ng the covari ance i nfor mati on for any model
str uctur e.
The step si ze used i n these numer i cal deri vati ves i s deter mi ned by the M-fi l e
nuder s t . The output ar gument nds i s a row vector whose k-th entr y gi ves the
i ncrement to be used when di fferenti ati ng wi th respect the k-th el ement of the
parameter vector par s .
The defaul t versi on of nuder s t uses a very si mpl e method. The step si ze i s the
maxi mum of and ti mes the absol ute val ue of the cur rent parameter .
You can adjust thi s to the actual val ue of the cor respondi ng parameter by
edi ti ng nude r s t . Note that the nomi nal val ue, for exampl e 0, of a par ameter
may not r efl ect i ts normal si ze.
10
7
10
4
nyqplot
4-64
nyqpl ot
Purpose Pl ot Nyqui st cur ve of frequency functi on.
Syntax nyqpl ot ( g)
nyqpl ot ( [ g1 g2 . . . gn] )
nyqpl ot ( g, s d, mode)
Description nyqpl ot i s an al ternati ve to bode pl ot and f f pl ot to graph fr equency functi ons
i n the fr eqfunq format. The Nyqui st di agr am of a frequency functi on i s a graph
of i ts i magi nary par t agai nst i ts r eal par t.
The argument g i s the fr equency functi on i n questi on, gi ven i n the fr eqfunc
format, typi cal l y as the output of t h2f f , s pa, or et f e . Sever al pl ots are
obtai ned i n the same di agram by si mpl y l i sti ng the di ffer ent frequency
functi ons after each other . These need not be speci fi ed at the same fr equenci es
(al though they have to be of the same l ength).
I f the fr equency functi on(s) contai ns i nfor mati on about several di fferent
i nput-output pai rs, the defaul t i s that the Nyqui st pl ot for each pai r i s graphed
separ atel y. Pressi ng the Return key advances fr om one pai r to the next. Wi th
mode = ' s ame ' al l pl ots corr espondi ng to the same i nput ar e gi ven i n the same
di agr am.
I f s d i s gi ven a val ue l ar ger than 0, a confi dence regi on ar ound the nomi nal
Nyqui st pl ot i s marked wi th dash-dotted l i nes. Thi s r egi on cor responds to s d
standar d devi ati ons. (The i nfor mati on i n g does not contai n the cor rel ati on
between the magni tude and phase esti mates. The confi dence r egi on i s
ther efor e onl y appr oxi mate. I t i s computed by pl otti ng the two curves ,
where i s the standar d devi ati on (magni tude and phase) of g.)
Examples g = t h2f f ( t hmod)
nypl ot ( g, 3)
See Also bodepl ot , e t f e , f f pl ot , f r e qf unc , s pa, t h2f f
g sd g t
g
n4sid
4-65
n4si d
Purpose Esti mate state-space model s usi ng a subspace method.
Syntax TH = n4s i d( z )
[ TH, AO] = n4s i d( z , or de r , ny , auxor d, dkx , maxs i z e, T, ' t r ac e' )
Description The functi on n4s i d esti mates model s i n state-space form, and returns them i n
the theta for mat. I t handl es an arbi trar y number of i nput and outputs,
i ncl udi ng the ti me seri es case (no i nput). The state-space model i s i n the
i nnovati ons 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 resul ti ng model i n theta for mat. No covar i ance i nformati on about the
uncer tai nty of the model i s contai ned i n TH.
AO: See under aux or d bel ow.
z : A matri x that contai ns the output-i nput data: z = [ y u] , where y and u ar e
col umn vector s. I n the mul ti -var i abl e case, u and y contai n one col umn for each
output and i nput. I n the ti me seri es case z = y .
or der : The desi red or der of the state-space model . I f or der i s entered as a row
vector (l i ke or de r = [ 1: 10] , whi ch i s the defaul t choi ce), pr el i mi nary
cal cul ati ons for al l the i ndi cated orders ar e carr i ed out. A pl ot wi l l then be
gi ven that shows the rel ati ve i mportance of the di mensi on of the state vector.
Mor e preci sel y, the si ngul ar val ues of the Hankel matr i ces of the i mpul se
response for di fferent or der s are graphed. You wi l l be prompted to sel ect the
order, based on thi s pl ot. The i dea i s to choose an order such that the si ngul ar
val ues for hi gher or der s are comparati vel y smal l . I f or der = ' be s t ' , a model
of best (defaul t choi ce) order i s computed, among the or ders 1:10.
ny : The number of outputs i n the data set z. Defaul t i s ny = 1.
aux or d: An auxi l i ar y or der used by the al gor i thm. Thi s can be seen as a
predi cti on hori zon, and i t shoul d be l ar ger than the order . The defaul t val ue i s
aux or d = 1. 2or der +3. The choi ce of aux or d coul d have a substanti al i nfl uence
on the model qual i ty, and there ar e no si mpl e rul es for how to choose i t. I f you
enter aux or d as a row vector (l i ke aux or d = [ 5: 15] ), model s for al l these val ues
wi l l be computed. The pr edi cti on err or for each of the model s ar e computed
usi ng the data z, and that val ue of auxor d that mi ni mi zes the fi t wi l l be
sel ected. Thi s val ue i s r etur ned as the output ar gument AO. I f the l ast gi ven
n4sid
4-66
ar gument to n4s i d i s ' t r ace ' , i nformati on about the di ffer ent choi ces of
aux or d wi l l be gi ven to the screen. Note that aux or d can be chosen as a vector,
onl y i f or de r i s a gi ven val ue (no vector ).
dkx : The ar gument dkx determi nes some addi ti onal structure of the matr i ces
of the state-space model to be esti mated. I t i s a row vector wi th thr ee entr i es:
dkx = [ d, k, x ]
The entr i es r efer to the matr i ces K, D, and the i ni ti al state X(0) of the
state-space model gi ven above.
k = 1 i ndi cates that the K-matri x i n the model (the Kal man Gai n) wi l l be
esti mated, whi l e k = 0 means that thi s matr i x wi l l be fi xed to zero. Thi s wi l l
gi ve a so cal l ed output er ror model .
d = 1 i ndi cates that D-matri x i n the model (the di rect ter m fr om i nput to
output) wi l l be esti mated, whi l e d = 0 means that thi s matri x i s fi xed to zero.
Thi s al so i mpl i es that there wi l l be a del ay of (at l east) one sampl e between the
i nput and the output.
x = 1 i ndi cates that the i ni ti al state x(0) wi l l be esti mated and stor ed i n the
model TH, whi l e x = 0 means that the i ni ti al state wi l l be taken as zero. Note
that the i ni ti al state i s somethi ng that r el ates to the par ti cul ar data set for
whi ch the model was esti mated, and may not be rel evant when the model i s
eval uated on a new set of data.
Defaul t i s
dkx = [ 0, 1, 0]
The opti onal var i abl es max s i z e and T are expl ai ned under AUXVAR.
t r ace : Letti ng the l ast i nput ar gument be ' t r ac e' , gi ves i nfor mati on to the
command l i ne about the choi ce of auxi l i ar y order, i n case thi s i s gi ven as a
vector.
Algorithm The functi on i mpl ements the methods descr i bed i n P. Van Overschee and B. De
Moor: N4SI D:Subspace al gor i thms for the i denti cati on of combi ned
detemi ni sti c-stochasti c systems. Automatica, Vol . 30, No 1, pp. 75-93, 1994.
The al gor i thm i s compl emented wi th a separ ate l i near l east-squares step to
re-esti mate the matri ces B, D, and X(0), whi ch enter l i near l y.
n4sid
4-67
Examples Bui l d a fi fth order model fr om data wi th thr ee i nputs and two outputs. Tr y
sever al choi ces of auxi l i ary orders. Look at the fr equency r esponse of the model .
(Note that ther e wi l l be no confi dence i nter val s!)
z = [ y1 y 2 u1 u2 u3] ;
t h = n4s i d( z , 5, 2, 7: 15, t r ac e ) ;
bodepl ot ( t r f ( t h) )
Use the r esul ti ng model as i ni ti al val ues for esti mati ng a state-space model of
the same order usi ng the pr edi cti on err or method:
t hi = s s 2t h( t h) ;
t hp = pem( z , t hi ) ;
See Also aux var , c ans t ar t , pe m, t het a
oe
4-68
oe
Purpose Esti mate the parameter s of an Output-Er ror model .
Syntax t h = oe ( z , nn)
t h = oe ( z , nn, t r ac e )
[ t h, i t er _i nf o] = oe ( z , nn, max i t er , t ol , l i m, maxs i z e , T, ' t r ac e ' )
Description The parameter s of the Output-Er ror model structur e
ar e esti mated usi ng a predi cti on err or method.
Matri x z contai ns the output-i nput data z = [ y u] wher e y and u are col umn
vectors. nn can be gi ven ei ther as
nn = [ nb nf nk]
or as
nn = t hi
I n the former case, nb, and nf are the or ders of the Output-Er ror model and nk
i s the del ay. I n the l atter case, thi s i s an i ni ti al val ue for the esti mate, gi ven i n
theta format. See The System I denti fi cati on Probl em on page 3-8 for an exact
defi ni ti on of the orders and del ay.
t h i s returned wi th the resul ti ng parameter esti mates and esti mated
covari ances, stor ed i n theta for mat.
The opti onal var i abl es i t e r _i nf o, l i m, maxi t er , maxs i z e , t ol , and T are
expl ai ned under aux var .
For mul ti -i nput model s, nb, nf , and nk ar e r ow vectors, such that entry number
i gi ves the or der s and del ays associ ated wi th the i -th i nput.
oe does not suppor t mul ti -output model s. Use state-space model for thi s case
(see c ans t ar t , n4s i d, and pe m)
I f a l ast ar gument ' t r ace ' i s suppl i ed, i nformati on about the progr ess of the
i ter ati ve sear ch for the model wi l l be fur ni shed to the MATLAB command
wi ndow.
y t ( )
B q ( )
F q ( )
----------- u t nk ( ) e t ( ) + =
oe
4-69
Algorithm oe uses essenti al l y the same al gori thm as ar max wi th modi fi cati ons to the
computati on of pr edi cti on er rors and gradi ents.
See Also ar max , auxv ar , bj , pe m, t he t a
pe
4-70
pe
Purpose Compute the predi cti on err or s associ ated wi th a model and a data set.
Syntax e = pe( z , t h)
Description Matri x z i s the output-i nput data set, z = [ y u] , and t h i s a model speci fi ed i n
theta for mat. e i s r etur ned contai ni ng the predi cti on er ror s that r esul t when
model t h i s appl i ed to the data,
See Also r es i d, t het a
e t ( ) H
1
q ( ) y t ( ) G q ( )u t ( ) [ ] =
pem
4-71
pem
Purpose Esti mate the par ameters of gener al l i near model s.
Syntax t h = pe m( z , nn)
t h = pe m( z , nn, ' t r ace ' )
[ t h, i t er _i nf o] = pe m( z , nn, i nde x, maxi t er , t ol , l i m, . . .
maxs i z e, T, ' t r ac e' )
Description The functi on pe m handl es al l model structures, i ncl udi ng the general
mul ti -i nput-si ngl e-output structure
and gener al str uctur es defi ned by f i x par , mf 2t h, ms 2t h, t hi ni t , and
unf i x par . Mul ti var i abl e ARX str uctur es defi ned by ar x2t h are al so cover ed.
The matri x z contai ns the output-i nput data z = [ y u] , wher e y and u are
col umn vector s (i n the mul ti -var i abl e case u and y contai n one col umn for each
i nput and output).
nn i s gi ven ei ther as
nn = [ na nb nc nd nf nk]
or as
nn = t hi
I n the for mer case, na, nb, nc , nd, and nf are the orders of the model and nk i s
the del ay(s). For mul ti -i nput systems, nb, nf , and nk are row vectors gi vi ng the
orders and del ays of each i nput. (See Secti on 3 of the Tutorial for exact
defi ni ti ons of the orders).
I n the l atter case, t hi defi nes a model structure and an i ni ti al val ue for the
esti mate, gi ven i n theta format.
t h i s retur ned wi th the resul ti ng par ameter esti mates and esti mated
covari ances, stored i n theta format.
The opti onal argument i ndex i s a r ow vector that contai ns the i ndi ces of the
parameter s that ar e to be esti mated. The other s r emai n fi xed to thei r nomi nal
val ues. The orderi ng of the par ameters i s defi ned under t h2par . The defaul t
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
val ue of i nde x i s that al l free par ameters ar e esti mated. The opti onal var i abl es
i t e r _i nf o, l i m, maxi t er , maxs i z e , t ol , and T are expl ai ned under auxv ar .
I f a l ast ar gument t r ace i s suppl i ed, i nformati on about the progr ess of the
i ter ati ve sear ch for the model wi l l be fur ni shed to the MATLAB command
wi ndow.
For the speci al cases of si ngl e-i nput model s of Output-Er ror, ARMAX, and
Box-Jenki ns type, i t i s more effi ci ent to use oe , ar max , and bj .
Examples Her e i s an exampl e of a system wi th thr ee i nputs and two outputs. A canoni cal
form state-space model of order 5 i s sought.
z = [ y1 y 2 u1 u2 u3] ;
t hc = c ans t ar t ( z , 5, 3)
t h = pe m( z , t hc ) ;
Algorithm pem uses essenti al l y the same al gor i thm as ar max wi th modi fi cati ons to the
computati on of pr edi cti on er rors and gradi ents.
See Also ar max , auxv ar , bj , oe , t het a
poly2th
4-73
pol y2th
Purpose Construct theta format matri x for i nput-output model s.
Syntax t h = pol y 2t h( A, B)
t h = pol y 2t h( A, B, C, D, F, l am, T)
Description pol y2t h creates a matr i x contai ni ng parameters that descri be the general
mul ti -i nput-si ngl e-output model structur e:
A, B, C, D, and F speci fy the pol ynomi al coeffi ci ents.
For si ngl e-i nput systems, these are al l row vectors i n the standar d MATLAB
format:
A = [ 1 a1 a2 . . . ana]
A, C, D, and F al l star t wi th 1, whi l e B contai ns l eadi ng zeros to i ndi cate the
del ays. See Defi ni ng Model Str uctures on page 3-29.
For mul ti -i nput systems, B and F are matr i ces wi th one r ow for each i nput.
For ti me ser i es, B and F are entered as empty matri ces:
B = [ ] ; F = [ ] ;
l am i s the vari ance of the whi te noi se sequence , whi l e T i s the sampl i ng
i nter val .
A negati ve val ue of T i ndi cates that the model i s a conti nuous-ti me one. Then
the i nterpretati on of the ar guments i s that
A = [ 1 2 3 4]
cor responds to the pol ynomi al i n the Lapl ace vari abl e s, and so
on. For conti nuous-ti me systems l am i ndi cates the l evel of the spectr al densi ty
of the i nnovati ons. (A sampl ed ver si on of the model has the i nnovati ons
var i ance l am/T, wher e T i s the sampl i ng i nterval . The conti nuous-ti me model
must have a whi te noi se component i n i ts noi se descr i pti on. See Some Speci al
Topi cs 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
Trai l i ng ar guments C, D, F, l am, and T can be omi tted, i n whi ch case they are
taken as 1. (I f B=[ ] , then F i s taken as [ ] .)
For di screte-ti me model s (T>0), note the fol l owi ng: pol y 2t h stri ps any tr ai l i ng
zeros fr om the pol ynomi al s when determi ni ng the order s. I t al so stri ps l eadi ng
zeros from the B pol ynomi al to determi ne the del ays. Keep thi s i n mi nd when
you use pol y2t h and t h2pol y to modi fy ear l i er esti mates to ser ve as i ni ti al
condi ti ons for esti mati ng new structur es. See Some Speci al Topi cs on page
3-68.
Examples To create a system of ARMAX type (the str m system):
A = [ 1 1. 5 0. 7] ;
B = [ 0 1 0. 5] ;
C = [ 1 1 0. 2] ;
t h0 = pol y 2t h( A, B, C) ;
Thi s gi ves a system wi th one del ay ( nk = 1) .
Cr eate the conti nuous-ti me model
Sampl e i t wi th T=0. 1 and then si mul ate i t wi thout noi se:
B=[ 0 1; 1 3] ;
F=[ 1 1 0; 1 2 4]
t h=pol y 2t h( 1, B, 1, 1, F, 1, 1)
t hd=t hc 2t hd( t h, 0. 1)
y =i ds i m( [ u1 u2] , t hd) ;
See Also i ds i m, t het a

y(t )
1
s(s+ 1)
u
1
t ( ) +
s+ 3
s
2
+ 2s+ 4
u
2
(t) + e(t )
predict
4-75
pr edi ct
Purpose Predi ct the output k-step ahead.
Syntax p = pr e di ct ( z , t h)
[ y p, t hpr e d] = pr edi c t ( z , t h, k)
Description z i s the output-i nput data i n the usual for mat
z = [ y u]
where y i s a matri x whose r -th col umn i s the r -th output si gnal and
cor respondi ngl y for the i nput u.
The ar gument k i ndi cates that the k-step ahead pr edi cti on of y accordi ng to the
model t h (i n the theta for mat) i s computed. I n the cal cul ati on of yp(t) the model
can use outputs up to ti me
: ,
and i nputs up to the cur rent ti me t. The defaul t val ue of k i s 1.
The output y p i s a matr i x of the same si ze as y, and i ts i,j el ement contai ns the
predi cted val ue of the cor respondi ng el ement i n y. The output argument
t hpr e d contai ns the k-step ahead predi ctor i n the theta for mat, i n the case that
t h corr esponds to an i nput-output model . (The pr edi ctor i s a system wi th
i nputs and outputs, bei ng the number of outputs and the
number of i nputs to t h.)
An i mportant use of pr e di c t i s to eval uate a model s properti es i n the
mi d-frequency range. Si mul ati on wi th i ds i m (whi ch conceptual l y corresponds
to k = i nf ) can l ead to l evel s that dr i ft apar t, si nce the l ow frequency behavi or
i s emphasi zed. One step ahead pr edi cti on i s not a power ful test of the model s
properti es, si nce the hi gh frequency behavi or i s str essed. The tr i vi al predi ctor
can gi ve good predi cti ons i n case the sampl i ng of the data i s fast.
Another i mportant use of pr e di ct i s to eval uate model s of ti me ser i es. The
natur al way of studyi ng a ti me seri es model s abi l i ty to repr oduce observati ons
i s to compare i ts k-step ahead predi cti ons wi th actual data.
Note that for output-er ror model s, there i s no di ffer ence between the k-step
ahead predi cti ons and the si mul ated output, si nce, by defi ni ti on, output-er ror
model s onl y use past i nputs to pr edi ct futur e outputs.
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 t h that i s an i nput-output model , the for mul a (3.31) i n Ljung
(1987) i s appl i ed to compute the pr edi ctor . For state-space model s, the state
equati ons ar e si mul ated k-steps ahead wi th i ni ti al val ue ,
where i s the Kal man fi l ter state esti mate.
Examples Si mul ate a ti me ser i es, esti mate a model based on the fi r st hal f of the data, and
eval uate the four step ahead predi cti ons on the second hal f:
t h0 = pol y 2t h( [ 1 0. 99] , [ ] , [ 1 1 0. 2] ) ;
y = i ds i m( r andn( 400, 1) , t h0) ;
t h = ar max ( y ( 1: 200) , [ 1 2] ) ;
y p = pr edi ct ( y , t h, 4) ;
pl ot ( [ y ( 201: 400) , y p( 201: 400) ] )
Note that the l ast two commands al so ar e achi eved by
c ompar e ( y , t h, 4, 201: 400) ;
See Also c ompar e , i ds i m, pe
x t k ( ) x t k ( ) =
x t k ( )
present
4-77
pr esent
Purpose Di spl ay the i nfor mati on i n a theta matri x.
Syntax pr e s e nt ( t h)
Description Thi s functi on di spl ays the pol ynomi al s of the model t h, together wi th thei r
standar d devi ati ons, l oss functi on, and Akai kes Fi nal Pr edi cti on Er ror
Cri teri on (FPE) (whi ch essenti al l y equal s the AI C). I t al so di spl ays i nformati on
about how t h was cr eated.
Leadi ng zeros i n B cor respond to del ays; ther efor e, the del ay i s nk i f B starts
wi th nk exact zer os.
For i nput-output model s, the esti mated standard devi ati ons ar e gi ven just
bel ow the esti mated parameter s. (Note that l eadi ng zeros and ones are exact
and have zer o standar d devi ati on.)
For state-space model s and mul ti var i abl e ARX model s, the standar d
devi ati ons are gi ven as fake, i magi nary parts of the parameter esti mates.
See Also t he t a
rarmax
4-78
rarmax
Purpose Esti mate r ecursi vel y the parameter s of an ARMAX or ARMA model .
Syntax t hm = r ar max( z , nn, adm, adg)
[ t hm, yhat , P, phi , ps i ] = . . .
r ar max( z , nn, adm, adg, t h0, P0, phi 0, ps i 0)
Description The parameter s of the ARMAX model structur e
ar e esti mated usi ng a r ecur si ve predi cti on err or method.
Matri x z contai ns the output-i nput data z = [ y u] wher e y and u are col umn
vectors. nn i s gi ven as
nn = [ na nb nc nk]
where na, nb, and nc are the or ders of the ARMAX model , and nk i s the del ay.
See equati ons (3.16)-(3.18) i n Chapter 3, "Tutor i al " for an exact defi ni ti on of the
orders.
I f z = y and nn = [ na nc] , r ar max esti mates the par ameters of an ARMA
model for y :
Onl y si ngl e-i nput, si ngl e-output model s ar e handl ed by r ar max. Use r pe m for
the mul ti -i nput case.
The esti mated parameter s ar e r etur ned i n the matr i x t hm. The k-th r ow of t hm
contai ns the par ameters associ ated wi th ti me k, i .e., they ar e based on the data
i n the r ows up to and i ncl udi ng r ow k i n z . Each r ow of t hm contai ns the
esti mated par ameters i n the fol l owi ng order:
t hm( k, : ) = [ a1, a2, . . . , ana, b1, . . . , bnb, c 1, . . . , c nc ]
See equati ons (3.16),(3.18) i n Chapter 3, "Tutori al " for more i nfor mati on.
y hat i s the predi cted val ue of the output, accordi ng to the cur rent model , i .e.,
row k of y hat contai ns the pr edi cted val ue of z ( k, 1) based on al l past data.
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 actual al gor i thm i s sel ected wi th the two arguments adm and adg. These
ar e descr i bed under r ar x.
The i nput ar gument t h0 contai ns the i ni ti al val ue of the par ameters, a r ow
vector, consi stent wi th the rows of t hm. The defaul t val ue of t h0 i s al l zeros.
The arguments P0 and P ar e the i ni ti al and fi nal val ues, respecti vel y, of the
scal ed covar i ance matr i x of the parameter s. See r ar x. The defaul t val ue of P0
i s 10
4
ti mes the uni t matri x. The arguments phi 0, ps i 0, phi , and ps i contai n
i ni ti al and fi nal val ues of the data vector and the gr adi ent vector, respecti vel y.
The si zes of these depend i n a r ather compl i cated way on the chosen model
orders. The normal choi ce of phi 0 and ps i 0 i s to use the outputs from a
previ ous cal l to r ar max wi th the same model or ders. (Thi s cal l coul d of cour se
be a dummy cal l wi th defaul t i nput ar guments.) The defaul t val ues of phi 0 and
ps i 0 are al l zeros.
Note that the functi on requi res that the del ay nk be l ar ger than 0. I f you want
nk=0, shi ft the i nput sequence appr opr i atel y and use nk=1.
Algorithm The general r ecursi ve pr edi cti on err or al gor i thm (11.44), (11.47)-(11.49) of
Ljung (1987) i s i mpl emented. See Recursi ve Par ameter Esti mati on on page
3-61 for mor e i nformati on.
Examples Compute and pl ot, as functi ons of ti me, the four par ameters i n a second order
ARMA model of a ti me ser i es gi ven i n the vector y . The for getti ng factor
al gor i thm wi th a for getti ng factor of 0.98 i s appl i ed.
t hm = r ar max ( y , [ 2 2] , ' f f ' , 0. 98) ;
pl ot ( t hm)
rarx
4-80
rarx
Purpose Esti mate r ecursi vel y the parameter s of an ARX or AR model .
Syntax t hm = r ar x( z , nn, adm, adg)
[ t hm, yhat , P, phi ] = r ar x( z , nn, adm, adg, t h0, P0, phi 0)
Description The parameter s of the ARX model structure
ar e esti mated usi ng di fferent vari ants of the recursi ve l east-squares method.
Matri x z contai ns the output-i nput data z = [ y u] where y and u are col umn
vectors. nn i s gi ven as
nn = [ na nb nk]
where na and nb ar e the order s of the ARX model , and nk i s the del ay. See
equati on (3.16) i n the Tutorial for an exact defi ni ti on of the orders.
I f z = y and nn = na, r ar x esti mates the par ameters of an AR model for y :
Model s wi th several i nputs
ar e handl ed by al l owi ng u to contai n each i nput as a col umn vector ,
u = [ u1 . . . unu]
and by al l owi ng nb and nk to be row vectors defi ni ng the orders and del ays
associ ated wi th each i nput.
Onl y si ngl e-output model s ar e handl ed by r ar x .
The esti mated par ameters ar e returned i n the matr i x t hm. The k-th row of t hm
contai ns the par ameters associ ated wi th ti me k, i .e., they ar e based on the data
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
i n the r ows up to and i ncl udi ng r ow k i n z . Each r ow of t hm contai ns the
esti mated par ameters i n the fol l owi ng order:
t hm( k, : ) = [ a1, a2, . . . , ana, b1, . . . , bnb]
See equati on (3.16) i n Chapter 3, "Tutor i al ". I n the case of a mul ti -i nput model ,
al l the b par ameters associ ated wi th i nput number 1 ar e gi ven fi rst, and then
al l the b parameter s associ ated wi th i nput number 2, and so on.
yhat i s the predi cted val ue of the output, accordi ng to the cur rent model , i .e.,
row k of yhat contai ns the predi cted val ue of z ( k, 1) based on al l past data.
The actual al gor i thm i s sel ected wi th the two arguments adg and adm. These
ar e descr i bed i n Recursi ve Par ameter Esti mati on on page 3-61. The opti ons
ar e as fol l ows:
Wi th adm =' f f ' and adg = l am the forgetting factor al gor i thm (10.6abd)+(10.8)
i s obtai ned wi th for getti ng factor = l am. Thi s i s what i s often referr ed to as
Recursi ve Least Squar es, RLS. I n thi s case the matr i x P (see bel ow) has the
fol l owi ng i nter pretati on: /2 P i s approxi matel y equal to the covari ance
matr i x of the esti mated parameter s. Here i s the var i ance of the i nnovati ons
(the true pr edi cti on er rors e(t) i n (10.3)).
Wi th adm =' ug' and adg = gam the unnormalized gradient al gor i thm
(10.6abc)+(10.9) i s obtai ned wi th gai n gamma= gam. Thi s al gor i thm i s
commonl y known as unnor mal i zed Least Mean Squar es, LMS. Si mi l ar l y
adm =' ng' and adg = gam gi ves the normalized gradient or Nor mal i zed Least
Mean Squar es, NLMS al gor i thm (10.6abc) + (10.10). I n these cases P i s not
defi ned or appl i cabl e.
Wi th adm =' kf ' and adg = R1 the Kalman Filter Based al gori thm (10.6) i s
obtai ned wi th R
2
=

1 and R
1
= R1. I f the var i ance of the i nnovati ons e(t) i s not
uni ty but , then P i s the covar i ance matr i x of the par ameter esti mates,
whi l e =R1 / i s the covari ance matri x of the parameter changes i n (10.4).
The i nput ar gument t h0 contai ns the i ni ti al val ue of the par ameters; a r ow
vector, consi stent wi th the r ows of t hm. (See above.) The defaul t val ue of t h0 i s
al l zeros.
The arguments P0 and P ar e the i ni ti al and fi nal val ues, respecti vel y, of the
scal ed covar i ance matr i x of the par ameters. The defaul t val ue of P0 i s 10
4
ti mes
the i denti ty matr i x.

R
2
R
2
R
2
R
2
R
1
R
2
rarx
4-82
The arguments phi 0 and phi contai n i ni ti al and fi nal val ues, r especti vel y, of
the data vector:
Then, i f
z = [ y( 1) , u( 1) ; . . . ; y ( N) , u( N) ]
you have phi 0 = and phi = . The defaul t val ue of phi 0 i s al l zer os. For
onl i ne use of r ar x, use phi 0, t h0, and P0 as the previ ous outputs phi , t hm (l ast
row), and P.
Note that the functi on r equi r es that the del ay nk be l arger than 0. I f you want
nk=0, shi ft the i nput sequence appropr i atel y and use nk=1.
Examples Adapti ve noi se cancel i ng: The si gnal y contai ns a component that has i ts
ori gi n i n a known si gnal r. Remove thi s component by esti mati ng, r ecur si vel y,
the system that rel ates r to y usi ng a si xth order FI R model together wi th the
NLMS al gor i thm:
z = [ y r ] ;
[ t hm, noi s e ] = r ar x ( z , [ 0 6 1] , ' ng' , 0. 1) ;
%noi s e i s t he adapt i ve es t i mat e of t he noi s e
%component of y
pl ot ( ynoi s e )
t ( ) y t 1 ( ) y t na ( ) u t 1 ( ) u t nb nk 1 + ( ) , , , , [ ] =
1 ( ) N ( )
rarx
4-83
I f the above appl i cati on i s a tr ue onl i ne one, so that you want to pl ot the best
esti mate of the si gnal y noi s e at the same ti me as the data y and u become
avai l abl e, pr oceed as fol l ows:
phi = z er os ( 6, 1) ; P=1000ey e( 6) ;
t h = z e r os ( 1, 6) ; axi s ( [ 0 100 2 2] ) ;
pl ot ( 0, 0, ' ' ) , hol d
%The l oop:
whi l e ~abor t
[ y, r , abor t ] = r e adAD( t i me ) ;
[ t h, ns , P, phi ] = r ar x ( [ y r ] , ' f f ' , 0. 98, t h, P, phi ) ;
pl ot ( t i me , y ns , ' ' )
t i me = t i me +Dt
e nd
Thi s exampl e uses a for getti ng factor al gori thm wi th a forgetti ng factor of 0.98.
r e adAD represents an M-fi l e that r eads the val ue of an A/D conver ter at the
i ndi cated ti me i nstance.
rbj
4-84
rbj
Purpose Esti mate r ecursi vel y the parameter s of a Box-Jenki ns model .
Syntax t hm = r bj ( z , nn, adm, adg)
[ t hm, yhat , P, phi , ps i ] = . . .
r bj ( z , nn, adm, adg, t h0, P0, phi 0, ps i 0)
Description The parameter s of the ARMAX model structur e
ar e esti mated usi ng a r ecur si ve predi cti on err or method.
Matri x z contai ns the output-i nput data z = [ y u] wher e y and u are col umn
vectors. nn i s gi ven as
nn = [ nb nc nd nf nk]
where nb, nc , nd, and nf are the orders of the Box-Jenki ns model , and nk i s the
del ay. See equati ons (3.21) and (3.14),(3.18), (3.22) and (3.29) i n the Tutorial
for an exact defi ni ti on of the or der s.
Onl y si ngl e-i nput, si ngl e-output model s ar e handl ed by r bj . Use r pem for the
mul ti -i nput case.
The esti mated par ameters ar e returned i n the matr i x t hm. The k-th row of t hm
contai ns the par ameters associ ated wi th ti me k, i .e., they ar e based on the data
i n the r ows up to and i ncl udi ng r ow k i n z . Each r ow of t hm contai ns the
esti mated par ameters i n the fol l owi ng order:
t hm( k, : ) = [ b1, . . . , bnb, c1, . . . , c nc , d1, . . . , dnd, f 1, . . . , f nf ]
(See equati ons (3.14),(3.18),(3.22) and (3.20) i n the Tutorial.)
y hat i s the predi cted val ue of the output, accordi ng to the cur rent model , i .e.,
row k of y hat contai ns the pr edi cted val ue of z ( k, 1) based on al l past data.
The actual al gor i thm i s sel ected wi th the two arguments adm and adg. These
ar e descri bed under r ar x.
y t ( )
B q ( )
F q ( )
----------- u t nk ( )
C q ( )
D q ( )
------------e t ( ) + =
rbj
4-85
The i nput ar gument t h0 contai ns the i ni ti al val ue of the par ameters, a r ow
vector, consi stent wi th the r ows of t hm. (See above.) The defaul t val ue of t h0 i s
al l zeros.
The arguments P0 and P ar e the i ni ti al and fi nal val ues, respecti vel y of the
scal ed covar i ance matri x of the par ameters. See r ar x . The defaul t val ue of P0
i s 10
4
ti mes the uni t matri x. The arguments phi 0, ps i 0, phi , and ps i contai n
i ni ti al and fi nal val ues of the data vector and the gr adi ent vector, respecti vel y.
The si zes of these depend i n a r ather compl i cated way on the chosen model
orders. The normal choi ce of phi 0 and ps i 0 i s to use the outputs from a
previ ous cal l to r bj wi th the same model orders. (Thi s cal l coul d, of cour se, be
a dummy cal l wi th defaul t i nput ar guments.) The defaul t val ues of phi 0 and
ps i 0 are al l zeros.
Note that the functi on requi res that the del ay nk i s l ar ger than 0. I f you want
nk=0, shi ft the i nput sequence appr opr i atel y and use nk=1.
Algorithm The general r ecursi ve pr edi cti on err or al gor i thm (11.44) of Ljung (1987) i s
i mpl emented. See al so Recursi ve Par ameter Esti mati on on page 3-61.
resid
4-86
resi d
Purpose Compute and test the r esi dual s (predi cti on err ors) of a model .
Syntax [ e, r ] = r es i d( z , t h)
[ e, r ] = r es i d( z , t h, M, max s i z e)
r es i d( r ) ;
Description Matri x z contai ns the output-i nput data z = [ y u] , wher e y and u are col umn
vectors. I n the mul ti var i abl e case, y and u are matr i ces, wi th col umns
cor respondi ng to the di ffer ent i nputs and outputs.
t h i s the model to be eval uated on the gi ven data set, defi ned i n theta for mat.
e i s r etur ned wi th the r esi dual s (pr edi cti on err ors) associ ated wi th the model
and the data.
The autocorrel ati on functi on of e and the cr oss corr el ati on between e and the
i nput(s) u are computed and di spl ayed. The 99% confi dence i nter val s for these
val ues are al so computed and di spl ayed as dotted (r ed) cur ves. The
computati on of these val ues i s done assumi ng e to be whi te and i ndependent of
u. The functi ons ar e di spl ayed up to l ag M, whi ch i s 25 by defaul t.
The cor rel ati on i nformati on i s returned wi th r . The pl ots can then be r evi ewed
by
r es i d( r ) ;
See Model Structure Sel ecti on and Val i dati on on page 3-49 for mor e
i nfor mati on.
The argument max s i z e i s expl ai ned under aux v ar .
Examples Her e are some typi cal model val i dati on commands:
e = r es i d( z , t h) ;
pl ot ( e)
c ompar e ( z , t h) ;
See Also aux var , c ompar e, pem, t he t a
References Ljung (1987), Secti on 16.5.
roe
4-87
roe
Purpose Esti mate r ecursi vel y the parameter s of an Output-Err or model .
Syntax t hm = r oe ( z , nn, adm, adg)
[ t hm, yhat , P, phi , ps i ] = r oe ( z , nn, adm, adg, t h0, P0, phi 0, ps i 0)
Description The parameter s of the Output-Er ror model structure
ar e esti mated usi ng a recur si ve predi cti on err or method.
Matri x z contai ns the output-i nput data z = [ y u] where y and u are col umn
vectors. nn i s gi ven as
nn = [ nb nf nk]
where nb and nf are the orders of the Output-Err or model , and nk i s the del ay.
See equati ons (3.14) and (3.19)-(3.20) i n the Tutorial for an exact defi ni ti on of
the orders.
Onl y si ngl e-i nput, si ngl e-output model s ar e handl ed by r oe. Use r pe m for the
mul ti -i nput case.
The esti mated par ameters ar e returned i n the matri x t hm. The k-th row of t hm
contai ns the par ameters associ ated wi th ti me k, i .e., they ar e based on the data
i n the r ows up to and i ncl udi ng r ow k i n z .
Each row of t hm contai ns the esti mated par ameters i n the fol l owi ng order:
t hm( k, : ) = [ b1, . . . , bnb, f 1, . . . , f nf ]
See equati ons (3.14), (3.20) i n the Tutorial.
yhat i s the predi cted val ue of the output, accordi ng to the cur rent model , i .e.,
row k of yhat contai ns the predi cted val ue of z ( k, 1) based on al l past data.
The actual al gor i thm i s sel ected wi th the two arguments adg and adm. These
ar e descr i bed under r ar x.
The i nput ar gument t h0 contai ns the i ni ti al val ue of the par ameters, a r ow
vector, consi stent wi th the r ows of t hm. (See above.) The defaul t val ue of t h0 i s
al l zeros.
y t ( )
B q ( )
F q ( )
-----------u t nk ( ) =
roe
4-88
The arguments P0 and P ar e the i ni ti al and fi nal val ues, respecti vel y, of the
scal ed covar i ance matr i x of the parameter s. See r ar x. The defaul t val ue of P0
i s 10
4
ti mes the uni t matr i x. The arguments phi 0, ps i 0, phi , and ps i contai n
i ni ti al and fi nal val ues of the data vector and the gr adi ent vector, respecti vel y.
The si zes of these depend i n a r ather compl i cated way on the chosen model
orders. The normal choi ce of phi 0 and ps i 0 i s to use the outputs from a
previ ous cal l to r oe wi th the same model or ders. (Thi s cal l coul d be a dummy
cal l wi th defaul t i nput arguments.) The defaul t val ues of phi 0 and ps i 0 are al l
zeros.
Note that the functi on r equi r es that the del ay nk i s l ar ger than 0. I f you want
nk=0, shi ft the i nput sequence appr opri atel y and use nk=1.
Algorithm The gener al r ecursi ve pr edi cti on err or al gor i thm (11.44) of Ljung (1987) i s
i mpl emented. See al so Recursi ve Par ameter Esti mati on on page 3-61.
See Also oe, r ar x, r bj , r pl r ,
rpem
4-89
rpem
Purpose Esti mate r ecursi vel y the parameter s of a gener al mul ti -i nput si ngl e-output
l i near model .
Syntax t hm = r pe m( z , nn, adm, adg)
[ t hm, yhat , P, phi , ps i ] = r pe m( z , nn, adm, adg, t h0, P0, phi 0, ps i 0)
Description The parameter s of the gener al l i near model str uctur e
ar e esti mated usi ng a recur si ve predi cti on err or method.
Matri x z contai ns the output-i nput data z = [ y u] where y and u are col umn
vectors (i n the mul ti -i nput case u contai ns one col umn for each i nput). nn i s
gi ven as
nn = [ na nb nc nd nf nk]
where na, nb, nc , nd, and nf ar e the or der s of the model , and nk i s the del ay.
For mul ti -i nput systems nb, nf , and nk ar e r ow vector s gi vi ng the orders and
del ays of each i nput. See equati ons (3.13)-(3.23) i n the Tutorial for an exact
defi ni ti on of the or ders.
The esti mated par ameters ar e returned i n the matri x t hm. The k-th row of t hm
contai ns the par ameters associ ated wi th ti me k, i .e., they ar e based on the data
i n the r ows up to and i ncl udi ng r ow k i n z . Each r ow of t hm contai ns the
esti mated par ameters i n the fol l owi ng order:
t hm( k, : ) = [ a1, a2, . . . , ana, b1, . . . , bnb, . . .
c 1, . . . , cnc , d1, . . . , dnd, f 1, . . . , f nf ]
See equati ons (3.13)-(3.23) i n the Tutorial. For mul ti -i nput systems the B par t
i n the above expressi on i s r epeated for each i nput before the C par t begi ns, and
al so the F par t i s repeated for each i nput. Thi s i s the same orderi ng as i n
t h2par .
yhat i s the predi cted val ue of the output, accordi ng to the cur rent model , i .e.,
row k of yhat contai ns the predi cted val ue of z ( k, 1) based on al l past data.
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 actual al gor i thm i s sel ected wi th the two arguments adg and adm. These
ar e descri bed under r ar x
The i nput ar gument t h0 contai ns the i ni ti al val ue of the par ameters;, a r ow
vector, consi stent wi th the rows of t hm. (See above.) The defaul t val ue of t h0 i s
al l zeros.
The arguments P0 and P ar e the i ni ti al and fi nal val ues, respecti vel y, of the
scal ed covar i ance matr i x of the parameter s. See r ar x. The defaul t val ue of P0
i s 10
4
ti mes the uni t matri x. The arguments phi 0, ps i 0, phi , and ps i contai n
i ni ti al and fi nal val ues of the data vector and the gr adi ent vector, respecti vel y.
The si zes of these depend i n a r ather compl i cated way on the chosen model
orders. The normal choi ce of phi 0 and ps i 0 i s to use the outputs fr om a
previ ous cal l to r pe m wi th the same model order s. (Thi s cal l coul d be a dummy
cal l wi th defaul t i nput arguments.) The defaul t val ues of phi 0 and ps i 0 are al l
zeros.
Note that the functi on r equi r es that the del ay nk i s l ar ger than 0. I f you want
nk=0 , shi ft the i nput sequence appropr i atel y and use nk=1.
Algorithm The gener al r ecursi ve pr edi cti on err or al gor i thm (11.44) of Ljung (1987) i s
i mpl emented. See al so Recursi ve Par ameter Esti mati on on page 3-61.
For the speci al cases of ARX/AR model s, and of si ngl e-i nput ARMAX/ARMA,
Box-Jenki ns, and Output-Err or model s, i t i s more effi ci ent to use r ar x ,
r ar max, r bj , and r oe .
See Also pem, r ar max , r ar x, r bj , r oe , r pl r
rplr
4-91
rpl r
Purpose Esti mate r ecursi vel y the parameter s of a gener al mul ti -i nput si ngl e-output
l i near model .
Syntax t hm = r pl r ( z , nn, adm, adg)
[ t hm, yhat , P, phi ] = r pl r ( z , nn, adm, adg, t h0, P0, phi 0)
Description Thi s i s a di rect al ternati ve to r pem and has essenti al l y the same syntax. See
r pe m for an expl anati on of the i nput and output arguments.
r pl r di ffer s fr om r pe m i n that i t uses another gr adi ent appr oxi mati on. See
Secti on 11.5 i n Ljung (1987). Sever al of the speci al cases are wel l known
al gor i thms.
When appl i ed to ARMAX model s, ( nn = [ na nb nc 0 0 nk] ) , r pl r gi ves the
Extended Least Squares, ELS method. When appl i ed to the output er ror
str uctur e (nn = [ 0 nb 0 0 nf nk] ) the method i s known as HARF i n the adm
= ' f f ' case and SHARF i n the adm = ' ng' case.
r pl r can al so be appl i ed to the ti me seri es case i n whi ch an ARMA model i s
esti mated wi th
z = y
nn = [ na nc ]
You can thus use r pl r as an al ter nati ve to r ar max for thi s case.
See Also pe m, r ar max , r ar x, r bj , r oe , r pe m
segment
4-92
segment
Purpose Segment data and esti mate model s for each segment.
Syntax s egm = s e gment ( z , nn)
[ s e gm, V, t hm, R2e] = s egme nt ( z , nn, R2, q, R1, M, t h0, P0, l l , mu)
Description s egme nt bui l ds model s of AR, ARX, or ARMAX/ARMA,
assumi ng that the model parameter s are pi ece-wi se constant over ti me. I t
resul ts i n a model that has spl i t the data recor d i nto segments over whi ch the
model r emai ns constant. The functi on model s si gnal s and systems that may
undergo abr upt changes.
The argument z i s the output-i nput data
z = [ y u]
where y i s a col umn vector contai ni ng the outputs and u i s a col umn vector
contai ni ng the i nputs. I f the system has sever al i nputs, u has the corr espondi ng
number of col umns.
The argument nn defi nes the model order. For the ARMAX model
nn = [ na nb nc nk]
where na, nb, and nc are the orders of the corr espondi ng pol ynomi al s. See
(3.13)-(3.18) i n Chapter 3, "Tutori al ". Mor eover nk i s the del ay. I f the model has
sever al i nputs, nb and nk ar e r ow vector s, gi vi ng the or der s and del ays for each
i nput.
For an ARX model (nc = 0) enter
nn = [ na nb nk]
For an ARMA model of a ti me ser i es
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 output ar gument s e gm i s a matr i x, whose k-r ow contai ns the par ameters
cor respondi ng to ti me k. Thi s i s anal ogous to the output ar gument t hm i n r ar x
and r ar max. The output argument t hm of s e gment contai ns the corr espondi ng
model par ameters that have not yet been segmented. That i s, they are not
pi ecewi se constant, and therefore cor respond to the outputs of the functi ons
r ar max and r ar x . I n fact, s egme nt i s an al ternati ve to these two al gor i thms,
and has a better capabi l i ty to deal wi th ti me vari ati ons that may be abrupt.
The output ar gument V contai ns the sum of the squared pr edi cti on er ror s of the
segmented model . I t i s a measure of how successful the segmentati on has been.
The i nput ar gument R2 i s the assumed var i ance of the i nnovati ons e(t) i n the
model . The defaul t val ue of R2 i s that i t i s esti mated. Then the output
ar gument R2e i s a vector whose k-th el ement contai ns the esti mate of R2 at ti me
k.
The argument q i s the pr obabi l i ty that the model undergoes at an abrupt
change at any gi ven ti me. The defaul t val ue i s 0.01.
R1 i s the assumed covari ance matr i x of the parameter jumps when they occur .
The defaul t val ue i s the i denti ty matri x wi th di mensi on equal to the number
of esti mated par ameters.
Mi s the number of par al l el model s used i n the al gori thm (see bel ow). I ts defaul t
val ue i s 5.
t h0 i s the i ni ti al val ue of the parameter s. I ts defaul t i s zer o. P0 i s the i ni ti al
covari ance matr i x of the par ameters. The defaul t i s 10 ti mes the i denti ty
matr i x.
l l i s the guaranteed l i fe of each of the model s. That i s, any cr eated candi date
model i s not abol i shed unti l after at l east l l ti me steps. The defaul t i s l l = 1.
Mu i s a for getti ng par ameter that i s used i n the scheme that esti mates R2. The
defaul t i s 0.97.
The most cri ti cal par ameter for you to choose i s R2. I t i s usual l y mor e r obust
to have a reasonabl e guess of R2 than to esti mate i t. Typi cal l y, you need to try
di ffer ent val ues of R2 and eval uate the r esul ts. (See the exampl e bel ow.)
s qr t ( R2) cor responds to a change i n the val ue y(t) that i s nor mal , gi vi ng no
i ndi cati on that the system or the i nput mi ght have changed.
segment
4-94
Algorithm The al gori thm i s based on M paral l el model s, each r ecursi vel y esti mated by an
al gor i thm of Kal man fi l ter type. Each i s updated i ndependentl y, and i ts
posteri or probabi l i ty i s computed. The ti me var yi ng esti mate t hm i s for med by
wei ghti ng together the Mdi fferent model s wi th wei ghts equal to thei r poster i or
probabi l i ty. At each ti me step the model (among those that have l i ved at l east
l l sampl es) that has the l owest poster i or pr obabi l i ty i s abol i shed. A new model
i s star ted, assumi ng that the system parameter s have jumped, wi th pr obabi l i ty
q, a r andom jump from the most l i kel y among the model s. The covari ance
matr i x of the par ameter change i s set to R1.
After al l the data are exami ned, the survi vi ng model wi th the hi ghest poster i or
probabi l i ty i s tr acked back and the ti me i nstances wher e i t jumped are mar ked.
Thi s defi nes the di fferent segments of the data. (I f no model s had been
abol i shed i n the al gori thm, thi s woul d have been the maxi mum l i kel i hood
esti mates of the jump i nstances.) The segmented model s egm i s then for med by
smoothi ng the par ameter esti mate, assumi ng that the jump i nstances ar e
cor rect. I n other wor ds, the l ast esti mate over a segment i s chosen to repr esent
the whol e segment.
Examples Check how the al gori thm segments a si nusoi d i nto segments of constant l evel s.
Then use a ver y si mpl e model y(t) =b
1
* 1, wher e 1 i s a faked i nput and
descr i bes the pi ecewi se constant l evel of the si gnal y(t) (whi ch i s si mul ated as
a si nusoi d).
y = s i n( [ 1: 50] /3) ' ;
t hm = s egment ( [ y , one s ( y ) ] , [ 0 1 1] , 0. 1) ;
pl ot ( [ t hm, y] )
By tr yi ng var i ous val ues of R2 (0.1 i n the above exampl e), more l evel s are
cr eated as R2 decr eases.
b
1
selstruc
4-95
sel str uc
Purpose Sel ect model or der (structure).
Syntax [ nn, v mod] = s el s t r uc ( v )
[ nn, v mod] = s el s t r uc ( v , c )
Description s e l s t r uc i s a functi on to hel p choose a model str uctur e (order ) from the
i nfor mati on contai ned i n the matri x v obtai ned as the output from ar xs t r uc or
i v s t r uc .
The defaul t val ue of c i s ' pl ot ' . Thi s gr aphs the val ues of the l oss functi ons i n
v agai nst the total number of par ameters i n the cor respondi ng model structure.
I f v was gener ated by i v s t r uc, so that i t al so contai ns the condi ti on numbers
of the I V matr i ces, then these ar e al so graphed agai nst the number of
parameter s. Based on i nspecti on of these pl ots, you can choose a sui tabl e
number of par ameters, and nn r etur ns the best structure wi th thi s number of
parameter s.
I f c = ' l og' , the l ogari thms of the l oss functi ons ar e gr aphed i nstead.
c = ' ai c' gi ves no pl ots, but returns i n nn the structure that mi ni mi zes
Akai kes I nformati on Theoreti c Cr i teri on (AI C),
where V i s the l oss functi on, d i s the total number of parameter s i n the
str uctur e i n questi on, and N i s the number of data poi nts used for the
esti mati on.
c = ' mdl ' r etur ns i n nn the str ucture that mi ni mi zes Ri ssanens Mi ni mum
Descri pti on Length (MDL) cr i ter i on.
When c equal s a numer i cal val ue, the structure that mi ni mi zes
i s sel ected.
The output ar gument vmod has the same for mat as v, but i t contai ns the
l ogar i thms of the accordi ngl y modi fi ed cri ter i a.
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 grounds for appl yi ng AI C or MDL r equi r e that v be generated by
ar x s t r uc wi th z e = z v. When cross-val i dati on i s used (z e di ffer ent from z v),
the l ogi cal choi ce i s c = 0.
When sel ecti ng model str uctur es, i t i s i mportant to assess careful l y whether
the benefi t of a better fi t i s wor th the addi ti onal compl exi ty of a hi gher or der
model . See Chapter 3, "Tutori al " for more i nfor mati on.
Examples Her e i s a typi cal sequence of commands for fi ndi ng a sui tabl e model str uctur e:
NN = s t r uc ( 2, 2, 1: 8) ;
v = ar x s t r uc ( z ( 1: 200, : ) , z ( 201: 400, : ) , NN) ;
nn = s e l s t r uc( v, 0) ;
nk = nn( 3) ;
NN = s t r uc ( 1: 4, 1: 4, nk) ;
v a = ar xs t r uc( z ( 1: 200, : ) , z ( 201: 400, : ) , NN) ;
v i = i v s t r uc ( z ( 1: 200, : ) , z ( 201: 400, : ) , NN) ;
nna = s el s t r uc ( v a) ;
nni = s el s t r uc ( v i ) ;
See Also ar x s t r uc, i v s t r uc, s t r uc
sett
4-97
sett
Purpose Set the sampl i ng i nter val di r ectl y.
Syntax modn = s e t t ( mod, T)
Description Al l functi ons that create model descri pti ons i n the theta or fr eqfunc format set
the sampl i ng i nter val T i n thei r l ast ar gument. For conveni ence s e t t offers an
al ter nati ve to set i t di rectl y. I t can be appl i ed both to the case where mod i s a
model i n the theta format and to the case wher e mod i s a frequency functi on or
spectrum i n the fr eqfunc for mat, wi th a defaul t choi ce of frequenci es.
t h = ar max( z , nn) ;
t h = s e t t ( t h, T) ;
i s equi val ent to
t h = ar max( z , nn, [ ] , [ ] , [ ] , [ ] , T)
Si mi l arl y,
g = s pa( z ) ;
g = s et t ( g, T) ;
i s equi val ent to
g = s pa( z , [ ] , [ ] , [ ] , T)
Note that you cannot use s e t t to recal cul ate model s to a new sampl i ng
i nter val . Use t hc 2t hd or t hd2t hc i nstead.
See Also f r e qf unc, t he t a
spa
4-98
spa
Purpose Esti mate fr equency response and spectr um by spectr al anal ysi s.
Syntax [ g, phi v ] = s pa( z )
[ g, phi v , z _s pe ] = s pa( z , M, w, maxs i z e, T)
Description s pa esti mates the transfer functi on g and the noi se spectrum phi v = of the
gener al l i near model
where i s the spectr um of (t).
Matri x z contai ns the output-i nput data z = [ y u] , where y and u are col umn
vectors. I f ther e ar e several i nputs, u i s a matri x wi th one col umn for each
i nput. The data may be compl ex-val ued.
g i s r etur ned i n the fr equency functi on for mat (see f r eqf unc ) wi th the
esti mate of at the fr equenci es speci fi ed by r ow vector w. The defaul t
val ue of w i s
w = [ 1: 128] /128pi /T
phi v i s returned wi th the autospectrum esti mate of at the same
frequenci es. Both outputs ar e returned wi th esti mated standar d devi ati ons
(see f r e qf unc ).
M i s the l ength of the l ag wi ndow used i n the cal cul ati ons. The defaul t val ue i s
M = mi n( 30, l engt h( z ) /10)
Changi ng the val ue of Mexchanges bi as for var i ance i n the spectr al esti mate.
As Mi s i ncr eased, the esti mated functi ons show more detai l , but are more
cor rupted by noi se. The shar per peaks a true fr equency functi on has, the
hi gher M i t needs. See e t f e as an al ter nati ve for narr owband si gnal s and
systems.
T i s the sampl i ng i nterval and maxs i z e control s the memory-speed tr ade-off
(see aux var ).

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

v
( )
G e
i
( )

v
( )
spa
4-99
For ti me ser i es z = y, g i s r etur ned wi th the esti mated output spectrum and
i ts esti mated standar d devi ati on.
IMPORTANT: For mul ti -output data the ar gument Mmust be enter ed as a row
vector of the same l ength as the number of outputs. Thi s i s the way the
di sti ncti on between i nputs and outputs i n z i s cl ar i fi ed. For defaul t wi ndow
si ze use i n the mul ti -output case
M = [ 1, 1, . . . , 1]
The opti onal thi r d output argument z _s pe gi ves di rectl y the spectrum matr i x
of z as fol l ows:
r e s hape ( z _s pe ( : , k) , nz , nz ) = The spectr um S at fr equency W(k)
where nz i s the number of channel s i n the data matri x z and
Her e win(m) i s wei ght at l ag m of an M-si ze Hammi ng wi ndow and W(k) i s the
frequency val ue i rad/s. Note that ' denotes compl ex-conjugate tr anspose.
The normal i zati on of the spectrum di ffer s fr om the one used by s pe ct r um i n the
Si gnal Processi ng Tool box . See Some Speci al Topi cs on page 3-68 for a more
preci se defi ni ti on.
Examples Wi th defaul t fr equenci es
g = s pa( z ) ;
bodepl ot ( g)
Wi th l ogari thmi cal l y spaced frequenci es
w = l ogs pac e ( 2, pi , 128) ;
[ g, phi v ] = s pa( z , [ ] , w) ;
% ( empt y mat r i x gi ve s def aul t )
bodepl ot ( [ g phi v ] , 3)
pl ots the esti mated spectrum together wi th confi dence i nter val s of three
standar d devi ati ons.
S Ez t m + ( )z t ( ) iW k ( )mT ( ) exp win m ( )
m M =
M

=
spa
4-100
Algorithm The covar i ance functi on esti mates are computed usi ng cov f . These ar e
mul ti pl i ed by a Hammi ng wi ndow of l ag si ze M and then Four i er transformed.
The rel evant rati os and di fferences are then for med. For the defaul t
frequenci es, thi s i s done usi ng FFT, whi ch i s mor e effi ci ent than for
user-defi ned fr equenci es. For mul ti -var i abl e systems, a str ai ghtforward
for-l oop i s used.
Note that M = i s i n Tabl e 6.1 of Ljung (1987). The standard devi ati ons are
computed as on pages 155-156 and 264 of Ljung (1987).
See Also aux var , bode pl ot , et f e, f f pl ot , f r eqf unc , t h2f f
References Ljung (1987), Secti on 6.4.

ss2th
4-101
ss2th
Purpose Create a model str ucture parametr i zed i n canoni cal form.
Syntax THS = s s 2t h( TH)
THS = s s 2t h( TH, or der s )
Description Thi s functi on conver ts any model i n theta for mat to a canoni cal l y
parameter i zed state-space model , al so i n theta for mat. I t i s useful when a
model has been obtai ned i n some way, and you want to use i t as an i ni ti al model
for predi cti on er ror esti mati on usi ng pem.
TH: The gi ven model , whi ch can be any model i n theta for mat.
THS: The resul ti ng model , al so i n theta format. A canoni cal parametr i zati on i n
observer for m, based on the pseudo-observabi l i ty i ndi ces or de r s .
or der s : The pseudo-obser vabi l i ty i ndi ces. A row vector, wi th as many el ements
as ther e ar e outputs i n the model TH. Thei r sum must be equal to the or der of
the model TH. See canf or m for more detai l s. I f or der s i s omi tted, a defaul t
choi ce of i ndi ces i s made.
I f the model TH i s an output err or model (i ts Kal man gai n equal to zer o), then
so i s THS. Al so i f there i s a del ay from i nput to output i n TH (cor respondi ng to a
state-space representati on (3.27) i n the Tutorial wi th D=0) then THS wi l l al so
have such a structure.
Examples Make a par ametri zed state-space model from gi ven matri ces A, B, C, D, and K
and use i t as i ni ti al condi ti on for pe m esti mati on:
t h1 = ms 2t h( mods t r uc ( A, B, C, D, K) , d ) ;
t hi = s s 2t h( t h1) ;
t h = pe m( z , t hi ) ;
Let the model obtai ned from n4s i d be used as the i ni ti al val ue for pr edi cti on
err or esti mati on:
t hn = n4s i d( z , 3) ;
t hp = pem( z , s s 2t h( t hn) ) ;
See Also canf or m, cans t ar t , ms 2t h, n4s i d
struc
4-102
str uc
Purpose Gener ate model str ucture matri ces.
Syntax NN = s t r uc( NA, NB, NK)
Description s t r uc r etur ns i n NN the set of model structures compr i sed of al l combi nati ons
of the order s and del ays gi ven i n row vector s NA, NB, and NK. The for mat of NN
i s consi stent wi th the i nput format used by ar x s t r uc and i vs t r uc. The
command i s i ntended for si ngl e-i nput systems onl y.
Examples The statement
NN = s t r uc ( 1: 2, 1: 2, 4: 5) ;
produces
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
th c2thd
Purpose Conver t a model from conti nuous ti me to di screte ti me.
Syntax t hd = t hc 2t hd( t hc, T)
Description t hc i s a conti nuous-ti me model i n the theta for mat. t hd i s what i s obtai ned
when i t i s sampl ed wi th sampl i ng i nter val T. I f t hc i s of i nput-output type, the
covari ance matr i x of the par ameters i s not tr ansl ated.
Note that the i nnovati ons var i ance of the conti nuous-ti me model i s
i nter preted as the i ntensi ty of the spectr al densi ty of the noi se spectr um. The
i nnovati ons var i ance i n t hd wi l l thus be gi ven as /T.
Examples Defi ne a conti nuous-ti me system and study the pol es and zeros of the sampl ed
counter part:
t hc = pol y2t h( 1, 1, 1, 1, [ 1 1 0] , 1, 1) ;
t hd = t hc 2t hd( t hc, 0. 5) ;
z ppl ot ( t h2z p( t hd) )
See Also t hd2t hc

thd2thc
4-104
th d2thc
Purpose Conver t a model from di scr ete to conti nuous ti me.
Syntax t hc = t hd2t hc ( t hd)
t hc = t hd2t hc ( t hd, de l ay, NoP)
Description The di scr ete-ti me model t hd, gi ven i n the theta for mat, i s conver ted to a
conti nuous-ti me counter part t hc . The covar i ance matri x of the parameter s i n
the model i s al so tr ansl ated usi ng Gauss appr oxi mati on for mul a and
numeri cal der i vati ves of the tr ansfor mati on. The step si zes i n the numer i cal
deri vati ves are deter mi ned by the functi on nude r s t . To i nhi bi t the transl ati on
of the covar i ance matri x and save ti me, enter NoP = 1.
I f the di screte-ti me model contai ns pure ti me del ays, i .e., , then these are
fi rst r emoved before the transformati on i s made. These del ays shoul d then be
appended as pure ti me-del ay (deadti me) to the conti nuous-ti me model . Thi s i s
done automati cal l y by t h2f f . To have the ti me del ay approxi mated by a
fi ni te-di mensi onal conti nuous system, enter de l ay = ' de l ' . The defaul t i s
del ay = ' node l ' .
I f the i nnovati ons var i ance i s i n t hd, and i ts sampl i ng i nterval i s T, then the
conti nuous-ti me model has an i ndi cated l evel of i nnovati ons spectr al densi ty
equal to T .
IMPORTANT: The tr ansfor mati on fr om di screte to conti nuous ti me i s not
uni que. t hd2t hc sel ects the conti nuous-ti me counter part wi th the sl owest
ti me constants, consi stent wi th the di scr ete-ti me model . The l ack of
uni queness al so means that the tr ansfor mati on may be i l l -condi ti oned or even
si ngul ar. I n par ti cul ar, pol es on the negati ve r eal axi s, i n the or i gi n, or i n the
poi nt 1, ar e l i kel y to cause pr obl ems. I nterpr et the r esul ts wi th care.
Examples Transform an i denti fi ed model to conti nuous ti me and compar e the frequency
responses of the two model s:
gd = t h2f f ( t h) ;
t hc = t hd2t hc( t h) ;
gc = t h2f f ( t hc ) ;
bodepl ot ( [ gd, gc ] , 3)
See Also nuder s t , t hc 2t hd
References See Some Speci al Topi cs on page 3-68.
nk 1 >

theta
4-105
th eta
Purpose Descri be the theta for mat.
Syntax he l p t het a
he l p t hs s
Description t he t a i s a packed matri x contai ni ng i nformati on about both a model str uctur e
and i ts nomi nal or esti mated parameter s. I t al so contai ns other rel evant
i nfor mati on about the i denti fi cati on resul t.
Thi s model for mat i s the basi c format wi th the System I denti fi cati on Tool box.
I t i s used by al l par ametri c i denti fi cati on methods and i t can be tr ansfor med to
many other model r epr esentati ons. See the tabl es i n the begi nni ng of thi s
chapter for more detai l s.
The i nter nal format of the theta for mat i s i ntended to be tr ansparent to the
user . The basi c way to di spl ay the i nformati on i s to use the pr e s e nt command.
Some speci fi c i nfor mati on i s r etri eved from the for mat by the functi ons
ge t mf t h, ge t ncap, get t , and t h2par . Thi s entry gi ves the detai l s of the i nter nal
repr esentati on, but thi s i nfor mati on i s not necessar y for most user s of the
System I denti fi cati on Tool box. The formats di ffer whether the under l yi ng
model i s i n state-space form or of the i nput-output bl ack box character.
I. For the general multi-input single-output linear model structure
A, B, C, D, and F are pol ynomi al s i n the del ay oper ator of or ders na, nb, nc, nd,
and nf, respecti vel y. I f the system has nu i nputs, nb, nf and nk ar e row vector s
of di mensi on nu contai ni ng i nformati on about the order s and del ays associ ated
wi th each of the i nputs. I n the case of a ti me ser i es (no u), B and F are not
defi ned.
Let n be the sum of al l the or der s (the number of esti mated par ameters) and l et
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 t he t a i s a (3+n) r matri x organi zed as fol l ows:
Row 1 has entr i es: esti mated vari ance of e, sampl i ng i nter val T, nu, na, nb,
nc, nd, nf, and nk.
Row 2 has entr i es: FPE (Akai kes Fi nal Predi cti on Err or), year, month,
date, hour, mi nute and command by whi ch the model was gener ated. The
matr i x entry (2,7) thus contai ns the coded number of whi ch command gener-
ated the model . Thi s number i s l ess than 20 for the bl ack-box model s of the
type above.
Row 3 i s the vector of esti mated parameter s, A, B ,C, D, and F, (excl udi ng
l eadi ng 1s and 0s).
Rows 4 to 3+n contai n the esti mated covari ance matr i x.
For conti nuous-ti me model s, a possi bl e el ement (4+n,1) contai ns a dead-ti me
for the system. Thi s i s used when computi ng frequency functi ons i n t h2f f .
II. For model s that ar e defi ned as state-space structures there i s an under l yi ng
M-fi l e that defi nes the structure. Thi s M-fi l e i s cal l ed by
[ A, B, C, D, K, X0] = mf name ( par , T, aux )
(See mf 2t h.) For model str uctures that ar e defi ned by ms 2t h, the name of thi s
M-fi l e i s s s modx 9 or s s modx8 and the argument aux i s the actual model
str ucture ms created by mods t r uc . Noti ce i n par ti cul ar that mul ti -output ARX
model s are i nter nal l y r epresented as state-space model s wi th the ai d of
s s modx9.
Suppose that the number of esti mated parameter s i s n and that the l ength of
the name of your M-fi l e mf name i s r. Suppose al so that the model has ny outputs
and that the si ze of the argument aux above i s nr ti mes nc. Then t het a i s a
matr i x of di mensi on
max(n, ny, nc, 7 + r) by 3+n +nr +ny)
organi zed as fol l ows:
Row 1 has entr i es: deter mi nant of i nnovati ons covari ance, sampl i ng i nter-
val , number of i nputs, number of outputs, number of esti mated parameter s,
number of rows of aux , number of col umns of aux, and name of
M-fi l e that defi nes the str uctur e.
theta
4-107
Row 2 contai ns the entr i es: FPE (Akai kes Fi nal Pr edi cti on Er ror), year,
month, date, hour, mi nute, and command by whi ch the model was generated.
Thi s l ast one i s a number l arger than 20 for state-space str uctur es.
Entr y ( 2, 8) i s i nterpr eted as fol l ows: 1 means that the underl yi ng par am-
eter i zati on i s i n conti nuous ti me, usi ng s s modx9. l l means that the under-
l yi ng parameter i zati on i s i n conti nuous ti me, to be sampl ed by
fi rst-or der -hol d, usi ng s s modx 8. 2 means that i t i s i n di scr ete ti me, agai n
usi ng s s modx9. 3 means that the model i s a mul ti vari ate ARX model . 4
means that the under l yi ng par ameteri zati on i s i n di screte ti me and user de-
fi ned. 5 means that the model i s a user -defi ned conti nuous-ti me par ame-
teri zati on, equi pped wi th sampl i ng i nhi bi ti on when cal l ed wi th a negati ve
val ue of T.
Row 3 contai ns the esti mated (nomi nal ) val ues of the par ameters.
Rows 4 to 3 + n contai n the esti mated covari ance matr i x of the par ameters.
Rows 4 + n to 3 + n + nr contai n the matr i x aux.
Rows 4 +n + nr to 3+n + nr + ny contai n the covar i ance matri x of the i nno-
vati ons of the model .
thinit
4-108
th i ni t
Purpose Set i ni ti al val ues for the par ameters to be esti mated.
Syntax t h = t hi ni t ( t h0)
t h = t hi ni t ( t h0, R, par s , s p)
Description Thi s functi on r andomi zes i ni ti al par ameter esti mates for model structur es t h0
i n the theta format that cor respond to state-space model s. t h i s the same model
str ucture as t h0, but wi th a di ffer ent nomi nal par ameter vector. Thi s vector i s
used as the i ni ti al esti mate by pem.
The par ameters are randomi zed around par s wi th var i ances gi ven by the r ow
vector R. Par ameter number k i s randomi zed as par s ( k) + e *s qr t ( R( k) ) ,
where e i s a normal random vari abl e wi th zer o mean and a vari ance of 1. The
defaul t val ue of R i s al l ones, and the defaul t val ue of par s i s the nomi nal
par ameter vector i n t h0.
Onl y model s that gi ve stabl e predi ctor s are accepted. I f s p = ' b' , onl y model s
that are both stabl e and have stabl e predi ctors ar e accepted.
s p = ' s ' requi res stabi l i ty onl y of the model , and s p = ' p' requi res stabi l i ty
onl y of the predi ctor . Sp = ' p' i s the defaul t.
A maxi mum of 100 tri al s ar e made by t hi ni t . I t may be di ffi cul t to fi nd a stabl e
predi ctor for hi gh or der systems just by tri al and er ror . An al ternati ve i s then
to compute the Kal man fi l ter predi ctor for a r andomi zed model .
See Also c ans t ar t , mf 2t h, ms 2t h, pem
th2arx
4-109
th 2arx
Purpose Extract the ARX parameter s fr om a theta for mat model .
Syntax [ A, B] = t h2ar x( t h)
[ A, B, dA, dB] = t h2ar x ( t h)
Description t h i s the model i n the theta for mat. A and B ar e returned as the matri ces that
defi ne the ARX structur e:
A = [ I A1 A2 . . . Ana]
B = [ B0 B1 . . . Bnb]
where
Del ays i n the system ar e i ndi cated by l eadi ng zeros i n the B matri ces. See
Secti on 6 i n the Tutorial.
dA and dB ar e the standard devi ati ons of A and B.
See Also ar x 2t h
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
th 2ff, trf
Purpose Compute the frequency r esponse and standar d devi ati ons of a theta format
model .
Syntax [ g, phi v ] = t h2f f ( t h)
[ g, phi v ] = t h2f f ( t h, ku, w, ky )
Description t h2f f computes the frequency functi ons of t h, wher e t h i s a matr i x i n theta
format contai ni ng a gener al model .
g i s returned wi th the transfer functi on esti mate (see (3.4), (3.23), and (3.25) i n
the Tutorial)
computed at the frequenci es gi ven i n row vector w. I f t h has several i nputs
and outputs, g i s computed for the i nput and output number s speci fi ed i n row
vectors ku and ky , respecti vel y. The for mat of g i s detai l ed under f r e qf unc.
The defaul t val ues of ku and ky are al l i nput and output pai r s contai ned i n t h.
For a ti me conti nuous model the fr equency functi on i s obtai ned i nstead.
Phi v ( ) i s r etur ned wi th the esti mated noi se spectr um for each of the outputs
where i s the esti mated var i ance of e(t) (the l oss functi on) speci fi ed by t h.
phi v i s computed at the same frequenci es as g. The normal i zati on of the
spectrum di ffers from the one used by s pec t r um i n the Si gnal Processi ng
Tool box. See Some Speci al Topi cs on page 3-68, for a pr eci se defi ni ti on. Note
that no cross-spectr a between di ffer ent outputs are computed.
The standard devi ati ons of the frequency functi on(s) and the spectra are al so
computed, usi ng the Gauss appr oxi mati on formul a. For model s wi th
compl i cated par ameter dependenci es, numer i cal di fferenti ati on i s appl i ed. The
step si zes for the numer i cal der i vati ves are deter mi ned by nude r s t .
G e
i
( )

G i ( )

v
( )

H e
i wt
( )
2
=

th2ff, trf
4-111
The defaul t val ues of the frequenci es ar e i n the di scr ete-ti me case ar e
w = [ 1: 128] /128pi /T
where T i s the sampl i ng i nter val speci fi ed by t h (defaul t = 1) and for the
conti nuous-ti me case
w = l ogs pac e ( l og10( pi /abs ( T) /100) , l og10( 10*pi / abs ( T) ) , 128)
where abs ( T) i s the underl yi ng sampl i ng i nterval for the conti nuous-ti me
model .
The fr equency functi ons can be gr aphed wi th bodepl ot , f f pl ot , and
ny qpl ot .
IMPORTANT: The command t r f has the same syntax as t h2f f but does not
cal cul ate the standard devi ati ons, and can be consi der abl y faster.
Examples Compare the resul ts from spectr al anal ysi s and an ARMAX model
(i nput-output dynami cs onl y).
t h = ar max( z , [ 2 2 2 1] ) ;
gp = t h2f f ( t h) ;
gs = s pa( z ) ;
bodepl ot ( [ gs gp] )
Pl ot, but dont stor e, the fr equency functi on g associ ated wi th t h:
bode pl ot ( t h2f f ( t h) )
See Also bodepl ot , e t f e , f f pl ot , nyqpl ot , s et t , s pa
th2par
4-112
th 2par
Purpose Extract the parameter s fr om the theta for mat.
Syntax [ par , P, l am] = t h2par ( t h)
Description t h i s a model , defi ned i n the theta format. par i s r etur ned as the nomi nal or
esti mated val ues of the free parameter s i n t h. The covar i ance matri x of the
par ameters i s obtai ned as P, and l am i s the var i ance (covari ance matr i x) of the
i nnovati ons.
The or deri ng for the par ameters i s as fol l ows. For the gener al i nput-output
model (7.2), you have
Her e, super scri pt refers to the i nput number.
For a state-space structure, defi ned by ms 2t h, the parameter s i n par s ar e
obtai ned i n the fol l owi ng order : The A matr i x i s fi rst scanned r ow by row for
free parameter s. Then the B matri x i s scanned row by row, and so on for the C,
D, K, and X0 matr i ces. (See ms 2t h.)
For a state-space matr i x that i s defi ned by mf 2t h, the order i ng of the
par ameters i s the same as i n your M-fi l e.
Mul ti vari ate ARX model s are i nter nal l y represented i n state-space form. The
orderi ng of the par ameters may not be tr ansparent i n thi s case; i t i s better to
use t h2ar x.
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
th 2pol y
Purpose Conver t theta matr i x i nto i ts component pol ynomi al s.
Syntax [ A, B, C, D, F, LAM, T] = t h2pol y ( t h)
Description Thi s i s essenti al l y the i nver se of the pol y 2t h functi on. I t returns the
pol ynomi al s of the gener al model
as contai ned by the matr i x t h i n theta for mat. See Exami ni ng Model s on page
3-40.
LAM i s the noi se vari ance and T i s the sampl i ng i nterval .
See Also pol y2t h, t h2t f , t het 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 ( ) + + + =
th2ss
4-114
th 2ss
Purpose Transform a model to state-space form.
Syntax [ A, B, C, D, K, X0] = t h2s s ( t h)
[ A, B, C, D, K, X0, dA, dB, dC, dD, dK, dX0] = t h2s s ( t h)
Description t h i s the model gi ven i n the theta format. A, B, C, D, K, and X0 ar e the matri ces
i n the state-space descr i pti on
where i s or dependi ng on whether t h i s a conti nuous or
di screte-ti me model .
dA, dB, dC, dD, dK, and dX0 are the standard devi ati ons of the state-space
matr i ces.
I f the under l yi ng model i tsel f i s a state-space model , the matr i ces corr espond
to the same basi s. I f the underl yi ng model i s an i nput-output model , an
obser ver canoni cal for m r epresentati on i s obtai ned.
Algorithm The computati on of the standard devi ati ons i n the i nput-output case assumes
that an A pol ynomi al i s not used together wi th a F or D pol ynomi al i n (7.2). For
the computati on of standard devi ati ons i n the case that the state-space
par ameters ar e compl i cated functi ons of the par ameters, Gauss approxi mati on
formul a i s used together wi th numeri cal der i vati ves. The step si zes for thi s
di fferenti ati on ar e determi ned by nuder s t .
See Also mf 2t h, ms 2t h, nude r s t
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
th 2tf
Purpose Transform a model to transfer functi on form.
Syntax [ num, de n] = t h2t f ( t h)
[ num, de n] = t h2t f ( t h, i u)
Description t h i s a model gi ven i n the theta format. num i s a matri x whose row number k gi ves
the numerator pol ynomi al associ ated wi th the transfer functi on from i nput
number i u to output number k. de n i s a row vector gi vi ng the (common)
denomi nator pol ynomi al for these transfer functi ons. The defaul t val ue of i u i s 1.
The for mats of num and de n ar e the same as those used by the Si gnal Pr ocessi ng
Tool box and the Control Systems Tool box, both for conti nuous-ti me and
di screte-ti me model s. See Exami ni ng Model s on page 3-40.
To obtai n the transfer functi on fr om noi se source number k, enter i u = k.
Examples For a conti nuous-ti me model
num = [ 1 2]
den = [ 1 3 0]
cor responds to the tr ansfer functi on
For a di scr ete-ti me model
num = [ 2 4 0]
den = [ 1 2 3 5]
cor responds to the tr ansfer functi on
whi ch i s the same as
See Also t h2pol y
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
th 2zp, zp
Purpose Compute zeros, pol es, and stati c gai ns of a theta format model .
Syntax [ z e po, k] = t h2z p( t h)
[ z e po, k] = t h2z p( t h, ku, ky , t hr es h)
Description For any model descri bed i n theta for mat by t h, the pol es and zeros and stati c
gai ns, al ong wi th thei r standar d devi ati ons ar e computed. The pol es and zer os
ar e stored i n coded for m i n the matri x z epo, whi l e the stati c gai ns are r etur ned
i n k.
The best way to di spl ay the i nformati on i n z epo i s to pl ot i t usi ng z ppl ot . The
i nfor mati on can al so be r etri eved wi th ge t z p.
The fi rst r ow of k contai ns the i nteger (jy-1)1000+ju, where jy i s the output
number and ju i s the i nput number for the gai n i n questi on. The second r ow of
k contai ns the corr espondi ng gai ns, and the thi r d r ow the standard devi ati on
of the gai n i n questi on.
NOTE: The gai n her e i s the stati c gai n, i .e., the steady state gai n fr om a step i n
i nput number ju to output number jy. I t i s thus the same for a di screte-ti me
and a conti nuous-ti me repr esentati on of the same model . Thi s i s di ffer ent
from the routi nes s s 2z p and z p2s s i n the Si gnal Processi ng Tool box, whi ch
use the transfer function gain, i .e., the coeffi ci ent of the hi ghest power i n the
numerator.
Row vectors ku and ky contai n the i ndi ces of the i nputs and outputs,
respecti vel y, for whi ch the zer os, pol es and gai ns are to be computed. I n thi s
context, the noi se e(t) i s counted as i nputs wi th negati ve number s. That i s,
noi se source number ju (the ju-th component of e ( t ) i s counted as i nput
number ju. The val ue 0 i n the vector ku i s the defaul t for al l noi se sources.
The defaul t val ues of ku and ky ar e al l i nputs and al l outputs (no noi se i nputs).
The opti onal argument t hr es h i s a thr eshol d for the computati on of the zeros.
Zer os at i nfi ni ty may, due to the numer i cal pr ocedur e, end up as l arge, fi ni te
val ues. To avoi d thi s, any zer o whose absol ute val ue i s l arger than t hr es h i s
regarded to be at i nfi ni ty. The defaul t val ue of t hr e s h i s 100000.
The pr ocedur e handl es both model s i n conti nuous and di screte ti me.
th2zp, zp
4-117
For the gener al di scr ete-ti me mul ti -i nput, si ngl e-output model
the zeros are the roots of (wi th z r epl aci ng the forward shi ft
oper ator q), and the pol es ar e the r oots of . The stati c gai n i s
k =B(1)/ (A(1)F(1)).
For model s that are i nter nal l y represented i n state-space form, the pol es ar e
the ei genval ues of the system matri x. The zer os ar e the zer os of the
cor respondi ng tr ansfer functi on. These zeros may thus di ffer from the
transmission zeros associ ated wi th the mul ti vari abl e system. To fi nd the
tr ans-mi ssi on zeros, fi r st use t h2s s and then appl y t z er o from the Contr ol
System Tool box.
Note that you cannot r el y on i nformati on about zeros and pol es at the or i gi n
and at i nfi ni ty. (Thi s i s a somewhat confusi ng i ssue anyway.)
z e po i s r eturned i n a format that al l ows easy pl otti ng wi th z ppl ot . (Then zer os
and pol es at the ori gi n and at i nfi ni ty are i gnor ed.) The r outi ne z pf or m i s useful
when compari ng di fferent model s.
The al ter nati ve routi ne z p has the same syntax as t h2z p but does not compute
standar d devi ati ons. Thi s can be a useful al ter nati ve, when the standar d
devi ati ons are not of i nterest, and computati on ti me for t h2z p i s l ong.
Mor eover , z p uses s s 2z p fr om the Si gnal Processi ng Tool box, whi ch may gi ve
better numeri cal accur acy i n di ffi cul t cases.
Note: Al though z p computes zer os and pol es for al l combi nati ons of noi se
sour ces and outputs, present i n the i ndi ces ky, ku, the command t h2z p onl y
gi ves i nformati on about pol es and zeros fr om noi se source number ju to output
number ju (i f ku contai ns the number -ju).
Algorithm The standard devi ati ons are computed usi ng Gausss approxi mati on formul a,
usi ng the par ameter covari ance matr i x contai ned i n t h. When the tr ansfer
functi on depends on the parameter s i n a compl i cated way, numer i cal
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
di fferenti ati on i s appl i ed. The step si zes for the di fferenti ati on are deter mi ned
i n the M-fi l e nude r s t .
Note that Gausss approxi mati on formul a gi ves i nfi ni te var i ance to pol es and
zeros that are exactl y repeated.
Examples The statement
z ppl ot ( t h2z p( t h) )
pl ots, but does not store, the pol es and zeros.
To compare the zer os and pol es of second and thi rd or der ARX model s
(i nput-output dynami cs onl y), use
t h2 = ar x ( z , [ 2 2 1] ) ;
t h3 = ar x ( z , [ 3 3 1] ) ;
z p2 = t h2z p( t h2) ;
z p3 = t h2z p( t h3) ;
z ppl ot ( z pf or m( z p2, z p3) )
See Also get z p, t het a, z e po, z pf or m, z ppl ot
unfixpar
4-119
unfi xpar
Purpose Free par ameters i n structures defi ned by ms 2t h and ar x 2t h.
Syntax t hn = unf i x par ( t ho, mat r i x)
t hn = unf i x par ( t ho, mat r i x, e l e me nt s )
Description Thi s functi on i s the i nver se of f i xpar . The i nter pretati on of the ar guments i s
the same. unf i xpar makes the i ndi cated parameter s fr ee par ameters to be
esti mated. The nomi nal /i ni ti al val ues of these parameter s are taken to be
equal to thei r actual val ues i n the structur e t ho.
See Also f i x par , ms 2t h, t he t a, t hi ni t
zepo
4-120
zepo
Purpose Descri be the zer os and pol e for mat.
Syntax hel p z e po
Description The z e po for mat i s created by t h2z p and z p and used by z ppl ot . I t contai ns
i nfor mati on about zeros and pol es and thei r standar d devi ati ons. The i nter nal
format i s i ntended to be transpar ent to the user. The basi c way to di spl ay the
i nfor mati on i s to use the z ppl ot command. Some speci fi c i nfor -mati on i s
retr i eved from the format by the functi on get z p. Thi s entr y gi ves the detai l s of
the i nternal r epresentati on, but thi s i nformati on i s not necessary for most
users of the System I denti fi cati on Tool box.
The fi rst r ow of the matr i x consi sts of i nteger s that gi ve i nformati on about
what the col umn bel ow contai ns. The i nteger s are coded i n the fol l owi ng way:
The zer os associ ated wi th i nput number ku and output number ky cor re-
spond to the number (ky - 1)*1000 + ku.
The standard devi ati ons of these zeros cor respond to the number
(ky-1)*1000 + ku +60.
The pol es associ ated wi th i nput number ku and output number ky corr e-
spond to the number (ky - 1)*1000 + ku + 20.
The standard devi ati on of these pol es cor respond to the number
(ky - 1)*1000 + ku + 80.
The zer os associ ated wi th noi se i nput number ky and output number ky (onl y
these ar e nor mal l y r epr esented) cor respond to the number 500 + ky.
The standard devi ati on of these, the corr espondi ng pol es, and thei r standard
devi ati ons are obtai ned by addi ng 60, 20, and 80, r especti vel y to thi s num-
ber.
Posi ti ons corr espondi ng to nonexi sti ng zeros and pol es (as wel l as zeros and
pol es at i nfi ni ty) are represented by i nf .
I f any of the above numbers i s negati ve, i t i ndi cates that the pol e or zer o rep-
resentati on corr esponds to a conti nuous-ti me model . Then the absol ute val -
ue of the number has the i nter pretati on above.
zepo
4-121
For compl ex conjugated pai r s, the fi rst r ow i n the cor respondi ng entr y for the
standard devi ati on contai ns a compl ex number whose real and i magi nary
parts ar e the standar d devi ati ons of the real and i magi nar y parts, respec-
ti vel y, of the pol e or zero i n questi on. The next row entr y (cor res-pondi ng to
the conjugate pol e or zer o) contai ns a r eal number that i s the corr el ati on be-
tween the real and i magi nary par ts.
See Also ge t z p, t h2z p, z pf or m, z ppl ot
zpform
4-122
zpfor m
Purpose Mer ge zer o-pol e i nformati on from di ffer ent model s.
Syntax z epo = z pf or m( z e po1, z e po2, . . . , ku)
Description The zer os and pol es i n z epo1, z e po2, ... from di ffer ent model s ar e merged i nto
one matri x to be used by z ppl ot . z epo1, z e po2, ... have the for mat as produced
by t h2z p. ku i s an opti onal row vector contai ni ng the i nput number s to be
pi cked out when formi ng z e po. The defaul t val ue i s ku i s equal to al l i nputs
present i n z e po1, z e po2, ... A maxi mum of fi ve i nput arguments to
z pf or m i s possi bl e.
Examples The statement
z ppl ot ( z pf or m( z pbj 2, z pbj 4, z pax2, z pax 4, 0) )
compar es the noi se characteri sti cs fr om four di ffer ent model s.
See Also t h2z p, z ppl ot
zpplot
4-123
zppl ot
Purpose Pl ot zer os and pol es.
Syntax z ppl ot ( z e po)
z ppl ot ( z pf or m( z e po1, z e po2, . . . , z epon) )
z ppl ot ( z e po, s d, mode, ax i s )
Description The zer os and pol es speci fi ed by z epo (see z epo for the format) are gr aphed,
wi th o denoti ng zer os and x denoti ng pol es. Pol es and zeros associ ated wi th the
same i nput, but di fferent model s, are al ways graphed i n the same di agram, and
pressi ng the Return key advances the pl ot fr om one model to the next. On
col or screens pol es, zer os and thei r confi dence r egi ons, corr espondi ng to the
same model al l have the same col or. Pol es and zer os at i nfi ni ty ar e i gnor ed. For
di screte-ti me model s, zeros and pol es at the or i gi n ar e al so i gnor ed.
I f s d has a val ue l arger than zer o, confi dence regi ons around the pol es and
zeros ar e al so gr aphed. The regi ons corr espondi ng to s d standar d devi ati ons
ar e marked. The defaul t val ue i s s d = 0. Note that the confi dence r egi ons may
someti mes str etch outsi de the pl ot, but they are al ways symmetri c around the
i ndi cated zer o or pol e.
I f the pol es and zeros are associ ated wi th a di screte-ti me model , a uni t ci rcl e i s
al so drawn.
When z epo contai ns i nfor mati on about sever al di fferent i nputs, there are some
opti ons:
mode = ' s ub' spl i ts the scr een i nto several pl ots.
mode = ' s ame' gi ves al l pl ots i n the same di agram. Pr essi ng the Return key
advances the pl ots.
mode = ' s ep' erases the pr evi ous pl ot before the next i nput i s treated.
The defaul t val ue i s mode = ' s ub' .
ax i s = [ x1 x 2 y1 y 2] fi xes the axi s scal i ng accordi ngl y. ax i s = m i s the same
as
axi s = [ m m m m]
zpplot
4-124
Examples z pbj = t h2z p( t hbj 2) ;
z pax = t h2z p( t har max 4) ;
z poe = t h2z p( t hoe3) ;
z ppl ot ( z pf or m( z poe , z pax , z pbj ) , 3)
show al l zer os and pol es of three model s al ong wi th the confi dence r egi ons
cor respondi ng to thr ee standar d devi ati ons.
See Also t h2z p, z pf or m
I-125
I ndex
A
adapti ve noi se cancel l i ng 4-82
Akai kes Fi nal Pr edi cti on Err or (FPE) 3-50
AR model 3-23
ARARMAX str ucture 3-12
ARMAX model 2-22
ARMAX str ucture 3-11
ARX model 1-6, 2-20, 3-6, 3-10, 3-17, 3-22, 3-29
B
basi c tool s 3-3
Bode di agram 2-29
Bode pl ot 1-9
Box-Jenki ns (BJ) str ucture 3-11
Box-Jenki ns model 2-22
Bur gs method 3-23
C
canoni cal forms 3-35
communi cati on wi ndow i dent 2-2
compari sons usi ng compar e 3-48
compl ex-val ued data 3-79
corr el ati on anal ysi s 1-4, 2-14, 3-15, 3-20
covar i ance functi on 3-9
covar i ance method 3-23
cr eati ng model s from data 2-2
cr oss cor rel ati on functi on 3-52
cr oss spectrum 3-16
D
Data Board 2-3
data handl i ng checkl i st 2-12
data representati on 2-7, 3-19
data vi ews 1-4
del ays 3-10, 3-31
detr endi ng the data 2-10
di stur bance 1-5
dr i ft matr i x 3-63
dynami c model s, i ntroducti on 1-5
E
esti mati on data 1-4
esti mati on method
i nstumental var i abl es 3-17
pr edi cti on err or appr oach 2-18, 3-17
esti mati on methods
di rect 2-14
par ametri c 2-14
subspace method 3-18, 3-25
exporti ng to the MATLAB wor kspace 2-32
extended l east squar es (ELS) 3-66
F
faul t detecti on 3-67
feedback 1-13
freqfunc format 3-20
frequenci es 3-28
frequency
functi on 2-15
functi ons 3-8, 3-20
pl ots 3-8
r ange 3-8
r esponse 2-15
scal es 3-8
frequency domai n descr i pti on 3-10
frequency response 1-9
Index
I-126
G
Gauss-Newton mi ni mi zati on 3-24
geometr i c l atti ce method 3-23
gr aphi cal user i nterface (GUI ) 2-2
GUI 2-2
topi cs 2-34
H
Hammi ng wi ndow 3-21
I
i dent wi ndow 2-34
i denti fi cati on process, basi c steps 1-10
i mpor ti ng data i nto the GUI 2-9
i mpul se r esponse 1-9, 2-29, 3-8, 3-9, 3-15
I nfor mati on Theor eti c Cr i ter i on (AI C) 3-50
i ni ti al condi ti on 3-24
i ni ti al par ameter val ues 3-37
i nnovati ons for m 3-13, 3-33
i nput si gnal s 1-5
i nstrumental var i abl e 3-17
(I V) method 3-22
techni que 3-23
i terati ons 3-27
i terati ve sear ch 3-24
K
Kal man-gai n matr i x 3-33
L
l ag wi dow 3-16
l ayout 2-35
M
mai n i dent wi ndow 2-34
maxi mum l i kel i hood
cr i teri on 3-26
method 3-17
memory hori zon 3-63
model
output-er r or 1-7
proper ti es 1-9
set 1-4
state-space 1-7
structur e 2-17, 3-3
structur e sel ecti on 3-3
structur es 3-29
uncertai nty 3-53
val i dati on 1-4
vi ew functi ons 2-27
vi ews 1-4, 1-7, 2-4
Model Boar d 2-3
mul ti vari abl e ARX model 3-30
mul ti vari abl e systems 1-16, 3-23
N
noi se 1-5
noi se model 1-7
noi se source 1-7, 2-31
noi se-free si mul ati on 1-8
noi se-free si mul ati ons 3-53
nonparametri c 3-10, 3-19
nonparametri c i denti fi cati on 1-4
Normal i zed Gradi ent (NG) Appr oach 3-64
numer i cal di ffer enti ati on 3-37
O
offsets 3-58
Index
I-127
outl i er s
si gnal s 1-4
output si gnal s 1-5
Output-Err or (OE) structur e 3-11
Output-Err or model 1-7, 2-22
P
par ametr i c i denti fi cati on 1-4
peri odogr am 3-21
pol es 1-9
pr edi cti on
er ror i denti fi cati on 2-18
er ror method 3-17
pr efi l teri ng 2-11
pr efi l teri ng si gnal s 2-11
Q
Qui ckstart menu i tem 2-12
R
r ecursi ve
i denti fi cati on 3-4, 3-61
l east squares 3-64
par ameter esti mati on 3-61
r eferences l i st 1-19
r esampl i ng 2-11
r obust esti mati on techni ques 3-27
S
sampl i ng i nterval 3-30
sel ecti ng data ranges 2-11
Sessi ons 2-5
shi ft oper ator 3-8
si mul ati ng data 2-12
spectr a 3-8, 3-16
spectr al anal ysi s 1-4, 3-16, 3-20
spectr um 3-9, 3-20
star tup i denti fi cati on pr ocedur e 1-12
state vector 3-13
state-space
for m 3-13
model 1-7, 2-24
model i ng 3-4
model s 3-33
step response 1-9, 2-29
str ucture 1-4
subspace method 3-18, 3-25
T
theta for mat 3-22, 3-29
ti me domai n descri pti on 3-9
ti me-conti nuous systems 3-30
transfer functi on 1-6
transi ent response 1-9, 2-29
U
Unnormal i zed Gradi ent (UG) Approach 3-64
V
val i dati on data 1-4
W
whi te noi se 3-9
wi ndow si zes 3-21
Worki ng Data set 2-3
workspace var i abl es 2-6
Index
I-128
Y
Yul e-Wal ker appr oach 3-23
Z
zer os 1-9