Initial commit
[pftoolbox.git] / models / @dgnl / private / initdata.m
blob6d1ecd930e4fd1bdc18fece9d48ee7786d0c641b
1 function newexpr=initdata(expr, xvars, uvars, wvars, evalvar);\r
2 % Assigns the expression to the appropriate data object. If an unknown expression type\r
3 % (such as a custom data object) is given, it will be returned without modifications.\r
4 %\r
5 % Syntax: (* = optional)\r
6 %\r
7 % dataobj = initdata(expr, xvars, wvars, uvars, evalvar);\r
8 %\r
9 % In arguments:\r
10 %\r
11 % 1. expr\r
12 %       An expression\r
13 % 2. xvars\r
14 %       A cell (char) array containing the state variables\r
15 % 3. uvars\r
16 %       A cell (char) array containing the u(t) variables\r
17 % 4. wvars\r
18 %       A cell (char) array containing the w(t) variables\r
19 % 5. evalvar\r
20 %       Some data objects, such as xlinear that use matrix multiplication, don't support\r
21 %       xvars, uvars and wvars. These objects need to know what variable(s) to use in the\r
22 %       evaluation. 'evalvar' contains this information. evalvar=1 means that x will be used in\r
23 %       the evaluation. evalvar=[1 3] means that [x; u] will be used (x and u are, like always,\r
24 %       row vectors or scalars). evalvar=0 means that no variable is used.\r
25 %       For arguments that uses xvars, uvars and wvars, this argument is redundant.\r
26 %       Example - the eval command of xlinear ('expression' is a matrix):\r
27 %       evalvar=0 returns expression\r
28 %       evalvar=1 returns expression*x\r
29 %       evalvar=[1 3 2] returns expression*[x; u; w]\r
30 %\r
31 % Out arguments:\r
32 %\r
33 % 1. dataobj\r
34 %       The resulting data object.\r
36 % Toolbox for nonlinear filtering.\r
37 % Copyright (C) 2005  Jakob Rosén <jakob.rosen@gmail.com>\r
38 %\r
39 % This program is free software; you can redistribute it and/or\r
40 % modify it under the terms of the GNU General Public License\r
41 % as published by the Free Software Foundation; either version 2\r
42 % of the License, or (at your option) any later version.\r
43 %\r
44 % This program is distributed in the hope that it will be useful,\r
45 % but WITHOUT ANY WARRANTY; without even the implied warranty of\r
46 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
47 % GNU General Public License for more details.\r
48 %\r
49 % You should have received a copy of the GNU General Public License\r
50 % along with this program; if not, write to the Free Software\r
51 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\r
53 switch class(expr)\r
54 case 'char';\r
55         newexpr=xsymbolic(expr,xvars,uvars,wvars);\r
56 case 'cell';\r
57         newexpr=xsymbolic(expr,xvars,uvars,wvars);\r
58 case 'inline';\r
59         newexpr=xsymbolic(expr,xvars,uvars,wvars);\r
60 case 'sym';\r
61         newexpr=xsymbolic(expr,xvars,uvars,wvars);\r
62 case 'double';\r
63         newexpr=xlinear(expr,evalvar);\r
64 otherwise\r
65         newexpr=expr;\r
66 end\r