Mercurial > hg > ltpda
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m-toolbox/test/test_ltpdamodel.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,78 @@ +mc + +%% Build a model + + +m = ltpdamodel('a+b*t'); +m.params = {'a', 'b'}; +m.values = {1, 1}; +m.xvar = 't'; +m.xvals = 0:99; + +m + +%% Test subs +ms1 = m.subs(plist('params', 'a', 'values', 1)) +% ms1.subs(plist('params', 'b', 'values', 2)) + +%% Test subs +ms2 = m.subs(plist('params', 'all')) + +%% Test subs +ms3 = m.subs(plist('params', {'a', 'b'}, 'values', {1, 2:10})) + +%% ltpdamodel.*ao +a = ao(1:19) +md = ltpdamodel('y') +md.setParams('y', {a.y}) + + +mdd =ms3.*md + +% Nicer +mdd = ms3.*a + +% and +mdd = ms3+3 + + + +%% Test eval for tsdata + +a = eval(m) + +%% Test eval for tsdata in a loop + +for kk=1:10 + tic + ms3 = m.subs(plist('params', {'a', 'b'}, 'values', {kk, kk})); + toc + tic + a = eval(ms3); + toc +end + + +%% Test for curvefit + +mc + +Nsecs = 100; +fs = 10; + +m1 = ltpdamodel('a+b.*t.^1.1 -c*t'); +m1.setParams({'a', 'b', 'c'}, {1.4, 2, 4}); + +m1.setXvar('t'); +m1.setXvals(linspace(0, Nsecs-1/fs, Nsecs*fs)) + +% Make test data +a = m1.eval + ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', Nsecs)); + +p = curvefit2(a, plist('Function', m1, 'p0', [1 1 1])) + +b = m1.setValues(p).eval; +iplot(a,b) + + +