Mercurial > hg > ltpda
comparison m-toolbox/test/test_ltpdamodel.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 mc | |
2 | |
3 %% Build a model | |
4 | |
5 | |
6 m = ltpdamodel('a+b*t'); | |
7 m.params = {'a', 'b'}; | |
8 m.values = {1, 1}; | |
9 m.xvar = 't'; | |
10 m.xvals = 0:99; | |
11 | |
12 m | |
13 | |
14 %% Test subs | |
15 ms1 = m.subs(plist('params', 'a', 'values', 1)) | |
16 % ms1.subs(plist('params', 'b', 'values', 2)) | |
17 | |
18 %% Test subs | |
19 ms2 = m.subs(plist('params', 'all')) | |
20 | |
21 %% Test subs | |
22 ms3 = m.subs(plist('params', {'a', 'b'}, 'values', {1, 2:10})) | |
23 | |
24 %% ltpdamodel.*ao | |
25 a = ao(1:19) | |
26 md = ltpdamodel('y') | |
27 md.setParams('y', {a.y}) | |
28 | |
29 | |
30 mdd =ms3.*md | |
31 | |
32 % Nicer | |
33 mdd = ms3.*a | |
34 | |
35 % and | |
36 mdd = ms3+3 | |
37 | |
38 | |
39 | |
40 %% Test eval for tsdata | |
41 | |
42 a = eval(m) | |
43 | |
44 %% Test eval for tsdata in a loop | |
45 | |
46 for kk=1:10 | |
47 tic | |
48 ms3 = m.subs(plist('params', {'a', 'b'}, 'values', {kk, kk})); | |
49 toc | |
50 tic | |
51 a = eval(ms3); | |
52 toc | |
53 end | |
54 | |
55 | |
56 %% Test for curvefit | |
57 | |
58 mc | |
59 | |
60 Nsecs = 100; | |
61 fs = 10; | |
62 | |
63 m1 = ltpdamodel('a+b.*t.^1.1 -c*t'); | |
64 m1.setParams({'a', 'b', 'c'}, {1.4, 2, 4}); | |
65 | |
66 m1.setXvar('t'); | |
67 m1.setXvals(linspace(0, Nsecs-1/fs, Nsecs*fs)) | |
68 | |
69 % Make test data | |
70 a = m1.eval + ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', Nsecs)); | |
71 | |
72 p = curvefit2(a, plist('Function', m1, 'p0', [1 1 1])) | |
73 | |
74 b = m1.setValues(p).eval; | |
75 iplot(a,b) | |
76 | |
77 | |
78 |