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