0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 % Test script for ao/lincom
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 % $Id: test_ao_lincom.m,v 1.5 2010/03/19 16:56:24 ingo Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 %% Make some data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 ple = plist('Exceptions', {'created', 'proctime', 'UUID', 'methodInvars', 'plistUsed', 'ao/name'});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 fs = 10;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 nsecs = 10;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 x1 = ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', nsecs, 'yunits', 'T'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 x2 = ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', nsecs, 'yunits', 'm'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 x3 = ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', nsecs, 'yunits', 'C'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 n = ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', nsecs, 'yunits', 'm'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 c = [ao(1,plist('yunits','m/T')) ao(2,plist('yunits','m/m')) ao(3,plist('yunits','m C^-1'))];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 y = c(1)*x1 + c(2)*x2 + c(3)*x3 + n;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 y.simplifyYunits;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 % Get a fit for c
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 p_m = lscov(x1, x2, x3, y);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 % do linear combination: list + plist with pest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 yfit_01 = lincom(x1, x2, x3, plist('coeffs', p_m));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 r01 = yfit_01.rebuild();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 eq(yfit_01, r01, ple)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 % do linear combination: list + plist with vector of cdata aos
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 yfit_02 = lincom(x1, x2, x3, plist('coeffs', p_m.find));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 r02 = yfit_02.rebuild();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 eq(yfit_02, r02, ple)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 % do linear combination: vector + plist with pest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 yfit_03 = lincom([x1, x2, x3], plist('coeffs', p_m));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 r03 = yfit_03.rebuild();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 eq(yfit_03, r03, ple)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 % do linear combination: vector + plist with vector of cdata aos
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 yfit_04 = lincom([x1, x2, x3], plist('coeffs', p_m.find));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 r04 = yfit_04.rebuild();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 eq(yfit_04, r04, ple)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 % do linear combination: list + pest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 yfit_05 = lincom(x1, x2, x3, p_m);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 r05 = yfit_05.rebuild();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 eq(yfit_05, r05, ple)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47 % do linear combination: list + vector of cdata aos
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 yfit_06 = lincom(x1, x2, x3, p_m.find);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 r06 = yfit_06.rebuild();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 eq(yfit_06, r06, ple)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52 % do linear combination: vector pest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 yfit_07 = lincom([x1, x2, x3], p_m);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 r07 = yfit_07.rebuild();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 eq(yfit_07, r07, ple)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57 % % do linear combination: vector + vector of cdata aos
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 yfit_08 = lincom([x1, x2, x3], p_m.find);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 r08 = yfit_08.rebuild();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60 eq(yfit_08, r08, ple)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 %% Make some data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63 fs = 10;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64 nsecs = 10;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 B1 = ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', nsecs, 'yunits', 'T'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66 B2 = ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', nsecs, 'yunits', 'T'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67 B3 = ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', nsecs, 'yunits', 'T'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68 n = ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', nsecs, 'yunits', 'm'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69 c = ao([1 2 3], plist('yunits','m/T'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71 % do linear combination: list + cdata ao with coefficients
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 yfit_11 = lincom(B1, B2, B3, c);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 r11 = yfit_11.rebuild();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74 eq(yfit_11, r11, ple)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
76 % do linear combination: vector + cdata ao with coefficients
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
77 yfit_12 = lincom([B1, B2, B3], c);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
78 r12 = yfit_12.rebuild();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
79 eq(yfit_12, r12, ple)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
80
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
81 % do linear combination: list + plist with vector of double
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
82 yfit_13 = lincom(B1, B2, B3, plist('coeffs', p_m.y));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
83 r13 = yfit_13.rebuild();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
84 eq(yfit_13, r13, ple)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
85
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
86 % do linear combination: vector + plist with vector of double
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
87 yfit_14 = lincom([B1, B2, B3], plist('coeffs', p_m.y));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
88 r14 = yfit_14.rebuild();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
89 eq(yfit_14, r14, ple)
|