Mercurial > hg > ltpda
comparison m-toolbox/test/smallvector/test_smallvectorfit.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/smallvectorfit functionality. | |
2 % | |
3 % A Monsky, M Hueller 29-03-10 | |
4 % | |
5 % $Id: test_smallvectorfit.m,v 1.5 2010/04/01 08:29:21 anneke Exp $ | |
6 % | |
7 | |
8 % Parameters | |
9 datafiles = '2008-07-11_12-26'; | |
10 test_data = sprintf('%s/example_file.dat', datafiles); | |
11 fs = 800000.0/24640.0; | |
12 %% Load data | |
13 % unfiltered Data | |
14 disp('*** Loading phase data....') | |
15 dpl = plist('filename', test_data, 'fs', fs, 'columns', 1, 'yunits', ''); | |
16 dpl2 = plist('filename', test_data, 'fs', fs, 'columns', 2, 'yunits', ''); | |
17 dpl3 = plist('filename', test_data, 'fs', fs, 'columns', 3, 'yunits', ''); | |
18 | |
19 phir = ao(dpl); | |
20 phi1 = ao(dpl2); | |
21 phi12 = ao(dpl3); | |
22 iplot(phir, phi12) | |
23 | |
24 %% User input | |
25 % starttime = input('enter start time: '); | |
26 % endtime = input('enter end time: '); | |
27 %% | |
28 starttime = 40; | |
29 endtime = 50; | |
30 %% Split and filter | |
31 pl = plist('type', 'lowpass', 'order', 1, 'gain', 1.0, 'fs', fs, 'fc', 1); | |
32 f = mfir(pl); | |
33 spl = plist('split_type', 'times', 'times',[starttime endtime]); | |
34 phi1_split = split(filter(phi1,f), spl); | |
35 phi12_split = split(filter(phi12,f), spl); | |
36 phir_split = split(filter(phir,f), spl); | |
37 | |
38 | |
39 %% Compute psi | |
40 psi1_split = phi1_split - phir_split; | |
41 psi12_split = phi12_split - phir_split; | |
42 %% XYdata | |
43 xy_psi1 = ao(plist('xvals', phir_split.data.y, 'yvals', psi1_split.data.y, ... | |
44 'xunits', phir_split.yunits, 'yunits', psi1_split.yunits)); % This could be replaced by ao/scatterData | |
45 xy_psi12 = ao(plist('xvals', phir_split.data.y, 'yvals', psi12_split.data.y, ... | |
46 'xunits', phir_split.yunits, 'yunits', psi1_split.yunits)); % This could be replaced by ao/scatterData | |
47 %% correct for Doppler effect | |
48 phir_doppler = dopplercorr(phir_split, plist('bin',50)); | |
49 phi1_doppler = dopplercorr(phi1_split, plist('bin',50)); | |
50 phi12_doppler = dopplercorr(phi12_split, plist('bin',50)); | |
51 %% Psi | |
52 psi1_doppler = phi1_doppler - phir_doppler; | |
53 psi12_doppler = phi12_doppler - phir_doppler; | |
54 psi12_doppler.data.growT; | |
55 %% XYdata | |
56 xy_psi1_doppler = ao(plist('xvals', phir_doppler.data.y, 'yvals', psi1_doppler.data.y, ... | |
57 'xunits', phir_doppler.yunits, 'yunits', psi1_doppler.yunits)); % This could be replaced by ao/scatterData | |
58 xy_psi12_doppler = ao(plist('xvals', phir_doppler.data.y, 'yvals', psi12_doppler.data.y, ... | |
59 'xunits', phir_doppler.yunits, 'yunits', psi12_doppler.yunits)); % This could be replaced by ao/scatterData | |
60 iplot(xy_psi1, xy_psi1_doppler) | |
61 %% Fit | |
62 [fit_psi1 fit_psi12] = smallvectorfit(phir_doppler, phi1_doppler, psi1_doppler, phi12_doppler, psi12_doppler); | |
63 %% Linear combination | |
64 [svec_psi1 svec_psi12] = smallvector_lincom(... | |
65 phir_doppler, phi1_doppler, psi1_doppler, phi12_doppler, psi12_doppler, fit_psi1, fit_psi12); | |
66 | |
67 %% create an xy data object from the linear combination | |
68 xy_klvek_psi1 = scatterData(phir_doppler,svec_psi1); | |
69 xy_klvek_psi12 = scatterData(phir_doppler,svec_psi12); | |
70 %% Plot data and fit together | |
71 iplot(xy_psi1_doppler, xy_klvek_psi1) | |
72 iplot(xy_psi12_doppler, xy_klvek_psi12) | |
73 %% read out small vector coefficiients | |
74 fit_klvek_psi1 = find(fit_psi1.procinfo,'coef_psi1'); | |
75 fit_klvek_psi12 = find(fit_psi12.procinfo,'coef_psi12'); |