Mercurial > hg > ltpda
comparison m-toolbox/test/LTPDA_training/topic5/TrainigSession_T5_Ex02.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 % Training session Topic 5 exercise 02 | |
2 % | |
3 % System identification in z-domain 2 | |
4 % | |
5 % 1) Load fsdata object from file | |
6 % 2) Fit loaded TF data with zDomainFit and fixed order | |
7 % 3) Compare results | |
8 % | |
9 % L FERRAIOLI 22-02-09 | |
10 % | |
11 % $Id: TrainigSession_T5_Ex02.m,v 1.3 2009/02/25 18:18:45 luigi Exp $ | |
12 % | |
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
14 | |
15 %% 1) load fsdata | |
16 | |
17 % load AO from file | |
18 rfilt = ao(plist('filename', 'topic5\T5_Ex02_rfilt.xml')); | |
19 iplot(rfilt) | |
20 | |
21 %% 2) Fitting TF - fixed model order | |
22 | |
23 % Loaded fsdata are the response of an order 19 partial fractioned filter. | |
24 % We now try to fitting the loaded filter response with zDomainFit with a | |
25 % fixed model order. | |
26 % We set Autosearch to off, in this case the function do not perform | |
27 % accuracy test but simply run how far maximum number of iteration is | |
28 % reached. Model order is fixed by minorder parameter. | |
29 | |
30 plfit1 = plist('FS',10,... % Sampling frequency for the model filters | |
31 'AutoSearch','off',... % Automatically search for a good model | |
32 'StartPolesOpt','c1',... % Define the properties of the starting poles - complex distributed in the unitary circle | |
33 'maxiter',30,... % maximum number of iteration per model order | |
34 'minorder',19,... % fixed model order | |
35 'weightparam','abs',... % assign weights as 1./abs(data) | |
36 'Plot','on',... % set the plot on or off | |
37 'ForceStability','on',... % force to output a stable ploes model | |
38 'CheckProgress','off'); % display fitting progress on the command window | |
39 | |
40 % Do the fit | |
41 fobj = zDomainFit(rfilt,plfit1); | |
42 % setting input and output units for fitted model | |
43 | |
44 %% 3) Compare results | |
45 | |
46 % Extracting residues and poles from fit results | |
47 fRes = zeros(numel(fobj),1); % fit residue vector initialization | |
48 fPoles = zeros(numel(fobj),1); % fit poles vector initialization | |
49 | |
50 % extracting data from fitted filters | |
51 for ii = 1:numel(fobj) | |
52 fRes(ii,1) = fobj(ii).a(1); | |
53 fPoles(ii,1) = -1*fobj(ii).b(2); | |
54 end | |
55 [fRes,idx] = sort(fRes); | |
56 fPoles = fPoles(idx); | |
57 | |
58 % starting model residues and poles | |
59 mRes = [2.44554138162509e-011 - 1.79482547894083e-011i; | |
60 2.44554138162509e-011 + 1.79482547894083e-011i; | |
61 2.66402334803101e-009 + 1.1025122049153e-009i; | |
62 2.66402334803101e-009 - 1.1025122049153e-009i; | |
63 -7.3560293387644e-009; | |
64 -1.82811618589835e-009 - 1.21803627800855e-009i; | |
65 -1.82811618589835e-009 + 1.21803627800855e-009i; | |
66 1.16258677367555e-009; | |
67 1.65216557639319e-016; | |
68 -1.78092396888606e-016; | |
69 -2.80420398962379e-017; | |
70 9.21305973049041e-013 - 8.24686706827269e-014i; | |
71 9.21305973049041e-013 + 8.24686706827269e-014i; | |
72 5.10730060739905e-010 - 3.76571756625722e-011i; | |
73 5.10730060739905e-010 + 3.76571756625722e-011i; | |
74 3.45893698149735e-009; | |
75 3.98139182134446e-014 - 8.25503935419059e-014i; | |
76 3.98139182134446e-014 + 8.25503935419059e-014i; | |
77 -1.40595719147164e-011]; | |
78 [mRes,idx] = sort(mRes); | |
79 | |
80 mPoles = [0.843464045655194 - 0.0959986292915475i; | |
81 0.843464045655194 + 0.0959986292915475i; | |
82 0.953187595424927 - 0.0190043625473383i; | |
83 0.953187595424927 + 0.0190043625473383i; | |
84 0.967176277937188; | |
85 0.995012027005247 - 0.00268322602801729i; | |
86 0.995012027005247 + 0.00268322602801729i; | |
87 0.996564761885673; | |
88 0.999999366165445; | |
89 0.999981722418555; | |
90 0.999921882627659; | |
91 0.999624431675213 - 0.000813407848742761i; | |
92 0.999624431675213 + 0.000813407848742761i; | |
93 0.997312006278751 - 0.00265611346834941i; | |
94 0.997312006278751 + 0.00265611346834941i; | |
95 0.990516544257531; | |
96 0.477796923118318 - 0.311064085401834i; | |
97 0.477796923118318 + 0.311064085401834i; | |
98 0]; | |
99 mPoles = mPoles(idx); | |
100 | |
101 % Check the relative difference | |
102 (mRes-fRes)./abs(mRes) | |
103 (mPoles-fPoles)./abs(mPoles) | |
104 % Results are accurate to the 7th decimal digit | |
105 |