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