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