Mercurial > hg > ltpda
comparison m-toolbox/test/test_ao_linlsqsvd.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_AO_LINLSQSVD tests the linlsqsvd method of the AO class. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % L Ferraioli 10-11-2010 | |
4 % | |
5 % $Id: test_ao_linlsqsvd.m,v 1.2 2011/02/18 16:15:28 luigi Exp $ | |
6 % | |
7 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
8 | |
9 %% 1) Determine the coefficients of a linear combination of noises and | |
10 %% comapre with lscov: | |
11 % | |
12 % Make some data | |
13 fs = 10; | |
14 nsecs = 10; | |
15 B1 = ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', nsecs, 'yunits', 'T')); | |
16 B1.setName; | |
17 B2 = ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', nsecs, 'yunits', 'T')); | |
18 B2.setName; | |
19 B3 = ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', nsecs, 'yunits', 'T')); | |
20 B3.setName; | |
21 n = ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', nsecs, 'yunits', 'm')); | |
22 c = [ao(1,plist('yunits','m/T')) ao(2,plist('yunits','m/T')) ao(3,plist('yunits','m T^-1'))]; | |
23 y = c(1)*B1 + c(2)*B2 + c(3)*B3 + n; | |
24 y.simplifyYunits; | |
25 %%% Get a fit with linlsqsvd | |
26 pobj1 = linlsqsvd(B1, B2, B3, y); | |
27 % do linear combination: using lincom | |
28 yfit1 = lincom(B1, B2, B3, pobj1); | |
29 yfit1.simplifyYunits; | |
30 %%% do fit using lscov | |
31 pobj2 = lscov(B1, B2, B3, y); | |
32 % do linear combination: using lincom | |
33 yfit2 = lincom(B1, B2, B3, pobj2); | |
34 yfit2.simplifyYunits; | |
35 | |
36 %%% do linear combination: using eval | |
37 yfit3 = pobj1.eval(B1, B2, B3); | |
38 | |
39 | |
40 % Plot (compare data with fit) | |
41 iplot(y, yfit1, yfit2, yfit3) | |
42 | |
43 %% 2) Determine the coefficients of a linear combination of noises: | |
44 % | |
45 % Make some data | |
46 fs = 10; | |
47 nsecs = 10; | |
48 x1 = ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', nsecs, 'yunits', 'T')); | |
49 x1.setName; | |
50 x2 = ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', nsecs, 'yunits', 'm')); | |
51 x2.setName; | |
52 x3 = ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', nsecs, 'yunits', 'C')); | |
53 x3.setName; | |
54 n = ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', nsecs, 'yunits', 'm')); | |
55 c = [ao(1,plist('yunits','m/T')) ao(2,plist('yunits','m/m')) ao(3,plist('yunits','m C^-1'))]; | |
56 y = c(1)*x1 + c(2)*x2 + c(3)*x3 + n; | |
57 y.simplifyYunits; | |
58 | |
59 %%% Get a fit for c | |
60 pobj = linlsqsvd(x1, x2, x3, y); | |
61 % do linear combination: using lincom | |
62 yfit1 = lincom(x1, x2, x3, pobj); | |
63 | |
64 %%% do linear combination: using eval | |
65 pl_split = plist('times', [1 5]); | |
66 yfit2 = pobj.eval(plist('Xdata', {split(x1, pl_split), split(x2, pl_split), split(x3, pl_split)})); | |
67 | |
68 % Plot (compare data with fit) | |
69 iplot(y, yfit1, yfit2, plist('Linestyles', {'-','--'})) | |
70 | |
71 |