view m-toolbox/test/test_ltpdamodel.m @ 35:4be5f7a5316f database-connection-manager

Suppress output messages on preferences loading and saving
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children
line wrap: on
line source

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)