Mercurial > hg > ltpda
comparison m-toolbox/test/test_smodel_eval.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_smodel_eval tests the eval method of the SMODEL class. | |
2 % | |
3 % M Hueller 05-05-2011 | |
4 % | |
5 % $Id: test_smodel_eval.m,v 1.1 2011/05/05 21:04:49 mauro Exp $ | |
6 % | |
7 | |
8 % Build the model | |
9 s1 = smodel(plist('expression', 'a + b1*x1 + b2*x2','xvar',{'x1','x2'})); | |
10 s1.setXvals({[1:100], [2:2:200]}); | |
11 s1.setYunits('N'); | |
12 s1.setXunits({'m', 'V'}); | |
13 s1.setParameters({'a','b1','b2'},{1,2,-3}); | |
14 s1.setName('test'); | |
15 | |
16 % Eval the model: output x is tsdata ao | |
17 a1 = ao(plist('xvals',[1:100],'yvals',[0.01:.01:1], 'type', 'tsdata', 'fs', 1)); | |
18 d1 = s1.eval(plist('output x', a1)); | |
19 assert(isequal(class(d1.data), class(a1.data))) | |
20 assert(isequal(d1.yunits, s1.yunits)) | |
21 | |
22 % Eval the model: output x is fsdata ao | |
23 a1 = ao(plist('xvals',[1:100],'yvals',[0.01:.01:1], 'type', 'fsdata')); | |
24 d1 = s1.eval(plist('output x', a1)); | |
25 assert(isequal(class(d1.data), class(a1.data))) | |
26 assert(isequal(d1.yunits, s1.yunits)) | |
27 | |
28 % Eval the model: output x is xydata ao | |
29 a1 = ao(plist('xvals',[1:100],'yvals',[0.01:.01:1], 'type', 'xydata')); | |
30 d1 = s1.eval(plist('output x', a1)); | |
31 assert(isequal(class(d1.data), class(a1.data))) | |
32 assert(isequal(d1.yunits, s1.yunits)) | |
33 | |
34 % Eval the model: output x is double array, no data type set | |
35 a1 = [2:2:200]; | |
36 d1 = s1.eval(plist('output x', a1)); | |
37 assert(isequal(class(d1.data), 'tsdata')) | |
38 assert(isequal(d1.yunits, s1.yunits)) | |
39 | |
40 % Eval the model: output x is double array, data type set to 'tsdata' | |
41 a1 = [2:2:200]; | |
42 d1 = s1.eval(plist('output x', a1, 'output type', 'tsdata')); | |
43 assert(isequal(class(d1.data), 'tsdata')) | |
44 assert(isequal(d1.yunits, s1.yunits)) | |
45 | |
46 % Eval the model: output x is double array, data type set to 'fsdata' | |
47 a1 = [2:2:200]; | |
48 d1 = s1.eval(plist('output x', a1, 'output type', 'fsdata')); | |
49 assert(isequal(class(d1.data), 'fsdata')) | |
50 assert(isequal(d1.yunits, s1.yunits)) | |
51 | |
52 % Eval the model: output x is double array, data type set to 'xydata' | |
53 a1 = [2:2:200]; | |
54 d1 = s1.eval(plist('output x', a1, 'output type', 'xydata')); | |
55 assert(isequal(class(d1.data), 'xydata')) | |
56 assert(isequal(d1.yunits, s1.yunits)) | |
57 | |
58 % Eval the model: output x is double array, no data type set, output xunits set | |
59 a1 = [2:2:200]; | |
60 d1 = s1.eval(plist('output x', a1, 'output xunits', 'ms')); | |
61 assert(isequal(class(d1.data), 'tsdata')) | |
62 assert(isequal(d1.yunits, s1.yunits)) | |
63 assert(isequal(d1.xunits, unit('ms'))) | |
64 | |
65 % Eval the model: output x is double array, data type set to 'tsdata', output xunits set | |
66 a1 = [2:2:200]; | |
67 d1 = s1.eval(plist('output x', a1, 'output type', 'tsdata', 'output xunits', 'ms')); | |
68 assert(isequal(class(d1.data), 'tsdata')) | |
69 assert(isequal(d1.yunits, s1.yunits)) | |
70 assert(isequal(d1.xunits, unit('ms'))) | |
71 | |
72 % Eval the model: output x is double array, data type set to 'fsdata', output xunits set | |
73 a1 = [2:2:200]; | |
74 d1 = s1.eval(plist('output x', a1, 'output type', 'fsdata', 'output xunits', 'ms')); | |
75 assert(isequal(class(d1.data), 'fsdata')) | |
76 assert(isequal(d1.yunits, s1.yunits)) | |
77 assert(isequal(d1.xunits, unit('ms'))) | |
78 | |
79 % Eval the model: output x is double array, data type set to 'xydata', output xunits set | |
80 a1 = [2:2:200]; | |
81 d1 = s1.eval(plist('output x', a1, 'output type', 'xydata', 'output xunits', 'ms')); | |
82 assert(isequal(class(d1.data), 'xydata')) | |
83 assert(isequal(d1.yunits, s1.yunits)) | |
84 assert(isequal(d1.xunits, unit('ms'))) | |
85 | |
86 % Eval the model: output x is left empty, data type should be ignored and always cdata | |
87 d1 = s1.eval(); | |
88 assert(isequal(class(d1.data), 'cdata')) | |
89 assert(isequal(d1.yunits, s1.yunits)) |