Mercurial > hg > ltpda
comparison m-toolbox/test/test_ltpdamodel_inv.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 % Test script for ltpdamodel/inv | |
2 % | |
3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
4 % HISTORY: 02-10-2008 L Ferraioli | |
5 % Creation | |
6 % | |
7 % $Id: test_ltpdamodel_inv.m,v 1.2 2009/05/25 15:11:33 luigi Exp $ | |
8 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
9 %% Build numeric test matrix | |
10 | |
11 a=1;b=2;c=3; | |
12 d=5;e=2;f=6; | |
13 g=1;h=3;i=5; | |
14 M=[a,b,c;d,e,f;g,h,i]; | |
15 iM = inv(M); | |
16 | |
17 %% Equivalent ltpdamodel matrix | |
18 | |
19 A = [ltpdamodel(plist('expression','a','params',{'a'},'values',{1},'xvar','x','xvals',[1:10].','xunits','Hz','yunits',unit('m'))),... | |
20 ltpdamodel(plist('expression','b','params','b','values',2,'xvar','x','xvals',[1:10].','xunits','Hz','yunits',unit('m'))),... | |
21 ltpdamodel(plist('expression','c','params',{'c'},'values',{3},'xvar','x','xvals',[1:10].','xunits','Hz','yunits',unit('m')));... | |
22 ltpdamodel(plist('expression','d','params',{'d'},'values',{5},'xvar','x','xvals',[1:10].','xunits','Hz','yunits',unit('m'))),... | |
23 ltpdamodel(plist('expression','e','params','e','values',2,'xvar','x','xvals',[1:10].','xunits','Hz','yunits',unit('m'))),... | |
24 ltpdamodel(plist('expression','f','params',{'f'},'values',{6},'xvar','x','xvals',[1:10].','xunits','Hz','yunits',unit('m')));... | |
25 ltpdamodel(plist('expression','g','params',{'g'},'values',{1},'xvar','x','xvals',[1:10].','xunits','Hz','yunits',unit('m'))),... | |
26 ltpdamodel(plist('expression','h','params','h','values',3,'xvar','x','xvals',[1:10].','xunits','Hz','yunits',unit('m'))),... | |
27 ltpdamodel(plist('expression','i','params',{'i'},'values',{5},'xvar','x','xvals',[1:10].','xunits','Hz','yunits',unit('m')))]; | |
28 | |
29 %% Do inverse and eval | |
30 | |
31 iA = inv(A); | |
32 | |
33 %% Numeric eval | |
34 | |
35 imat = zeros(3,3); | |
36 for ii=1:3 | |
37 for jj=1:3 | |
38 imat(ii,jj)=eval(iA(ii,jj).expr.s); | |
39 end | |
40 end | |
41 | |
42 imat-iM | |
43 | |
44 %% Symbolic test | |
45 | |
46 B = A*iA; | |
47 | |
48 %% Numeric eval | |
49 | |
50 imat2 = zeros(3,3); | |
51 for ii=1:3 | |
52 for jj=1:3 | |
53 imat2(ii,jj)=eval(B(ii,jj).expr.s); | |
54 end | |
55 end |