Académique Documents
Professionnel Documents
Culture Documents
Chiara Masiero
http://automatica.dei.unipd.it/people/chiara-masiero/teaching.html Department of Information Engineering University of Padova, Italy 16 febbraio 2012 Version 1.0
1 / 23
System Identication
We need a better model
No
Data
Identication data
Candidate model
Performances analysis
Yes
Done!
Validation data
Matlab System Identication Toolbox: help ident GUI (Graphical User Interface) version: ident
C. Masiero (DEI - UniPD) Matlab SysId tutorial 2 / 23
Outline
3 / 23
Data management
e = m+s*randn(100,1) Creates 100 samples of WGN with mean m and variance s 2 . u = idinput(N,TYPE) Generates input signals for identication. In particular:
N = [Ns Nu] Input signal with Nu channels (each of Ns samples); N = [P Nu M] Input signal with Nu channels, with period P, of length M P ; TYPE = RGS Random Gaussian Signal TYPE = RBS Random Binary Sequence TYPE = PRBS Pseudo Random Binary Signal TYPE = SINE Sum-of-sinusoid Signal
4 / 23
Data management
A(z ) b0 +b1 z +b2 z Fed the lter H (z ) = B (z ) = a0 +a1 z 1 +a2 z 2 +a3 z 3 with input u : A = [a0 a1 a2 a3]; B = [b0 b1 b2]; In order to compute the output signal y in Matlab you can. . .
1 2
. . . use the command filter: y=filter(B,A,u); . . . dene H = H (z ) by means of z=tf(z), then y = lsim(H,u); . . . create a Simulink model.
5 / 23
Data management
Let u and y be the available input/output sequence (arrays or matrices). First, put it in the form of an iddata object data=iddata(y,u,Ts) % Ts is the sampling time. Elaborate example data = iddata(y,u,0.08,InputName,Power,InputUnit,... Watt,OutputName,Temperature,OutputUnit,C); The available data should be split into identication and validation data.
6 / 23
Data management
Usually you should remove osets and linear trends from the data (e.g. if you want a linearized model which describes the system in the neighbourhood of an equilibrium point) [detData, Trend]=detrend(data,TYPE) where data is the iddata object to process and TYPE can be either 0 (oset removal) or 1 (linear trend removal) Simulate the identied model in proximity of the working point input = detData(:,[],:) % Input signal ylin = sim(model,input) % No trend is considered ytotal = retrend(ylin,Trend) % Add trend
7 / 23
Model selection
System Identication
Our framework: parametric identication Starting point choose a model class (ARMA, AR, BJ, etc. . . ); x the model complexity. Lets give a look to frequently used model classes. . .
8 / 23
Model selection
ARX: A(z )y (t ) = B (z )u (t nk ) + e (t ) A(z ) = 1 + a1 z 1 + + ana z na , B (z ) = b1 + b2 z 1 + + bnb z nb +1 . Matlab command model=arx(data,[na nb nk]) ARMAX: A(z )y (t ) = B (z )u (t nk ) + C (z )e (t ) A(z ) = 1 + a1 z 1 + + ana z na , B (z ) = b1 + b2 z 1 + + bnb z nb +1 , C (z ) = 1 + c1 z 1 + + cnc z nc . Matlab command model=armax(data,[na nb nc nk])
9 / 23
Model selection
OE: y (t ) =
nk ) + e (t )
nk ) +
C (z ) D (z ) e (t )
10 / 23
Model selection
Numerically ecients routines; Matlab provides useful tools in order to select the best model order; The identied AR models provides a starting point for the identication of other models.
11 / 23
Model selection
for dierent values of nk e selects the value which exhibits the best t.
C. Masiero (DEI - UniPD) Matlab SysId tutorial 12 / 23
Model selection
arxstruc compute the value of a loss function corresponding to ARX models of dierent orders struc generates triples describing the orders of the ARX models to be considered by arxstruc selstruc compares the values of the loss function for dierent choices of the order and select the best Example V = arxstruc(dataId,dataVal,struc(2,2,1:10)); [bestOrders,Vm] = selstruc(V,0);
13 / 23
Model selection
V = arxstruc(dataId,dataVal,struc(1:10,1:10,3)); Compute the loss function for ARX models of orders nA and nB from 1 to 10 and xed delay of 3; The best triple is given by bestOrders = selstruc(V,0) Validation data They are fundamental in prevent overtting.
14 / 23
Model selection
1.5
0.5
10 15 Number of par's
20
25
selctruc also allows to take into account other criteria in order to select the best order, like AIC and MDL.
15 / 23
Performances analysis
10 lag
15
20
25
Cross corr. function between input Power and residuals from output Temperature 0.5
0.5 30
20
10
0 lag
10
20
30
16 / 23
Performances analysis
/T 0 /T 0.2 0.4 0.6 0.8 1 1 0.8/T 0.7/T 0.6/T 0.4/T 0.5/T 0 0.3/T 0.2/T 0.9/T 0.1/T
0.5
0.5
pzmap(arx223,b,arx423,r);
C. Masiero (DEI - UniPD) Matlab SysId tutorial 17 / 23
Performances analysis
5 Temperature (o C)
Fit = 100 1
yh y y y
10
15 52
compare(dataVal,arx223,b,arx423,r)
18 / 23
Performances analysis
0.5
0.5
Overlapping condence intervals suggest the presence of reductions. Therefore, the lower order model could be adequate.
C. Masiero (DEI - UniPD) Matlab SysId tutorial 19 / 23
Performances analysis
5 Temperature (o C)
10
15 52
54
56
58
60
62
64
66
20 / 23
Performances analysis
10
10
10
10
10
10 Frequency (rad/s)
10
bode(arx223,b,arx313,r)
C. Masiero (DEI - UniPD) Matlab SysId tutorial 21 / 23
Conclusion
Are you in a hurry? Micro SysId Toolbox manual: help idhelp Come into action! Ocial demos: iddemo Further readings All Matlab SysId can oer: help ident Ocial manual: http://www.mathworks.it/help/toolbox/ident/
22 / 23
chiara.masiero@dei.unipd.it
http://automatica.dei.unipd.it/people/chiara-masiero/teaching.html