1 function obj=xsymbolic(varargin)
\r
2 % Holds an inline object, a symbolic expression or just a string.
\r
3 % Will be treated as inlines internally.
\r
5 % Syntax: (* = optional)
\r
7 % obj = xsymbolic(expression, xvars*, uvars*, wvars*);
\r
12 % An inline object, a symbolic expression or a string.
\r
14 % A cell array containing the names of the states.
\r
16 % 'xvars' is set to {'x1', 'x2', 'x3', ...}
\r
18 % A cell array containing the name of the elements forming u(t).
\r
20 % 'uvars' is set to {'u1', 'u2', 'u3', ...}
\r
22 % A cell array containing the name of the elements forming w(t).
\r
24 % 'wvars' is set to {'w1', 'w2', 'w3', ...}
\r
29 % The resulting data object.
\r
31 % Toolbox for nonlinear filtering.
\r
32 % Copyright (C) 2005 Jakob Rosén <jakob.rosen@gmail.com>
\r
34 % This program is free software; you can redistribute it and/or
\r
35 % modify it under the terms of the GNU General Public License
\r
36 % as published by the Free Software Foundation; either version 2
\r
37 % of the License, or (at your option) any later version.
\r
39 % This program is distributed in the hope that it will be useful,
\r
40 % but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
41 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
42 % GNU General Public License for more details.
\r
44 % You should have received a copy of the GNU General Public License
\r
45 % along with this program; if not, write to the Free Software
\r
46 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
\r
51 elseif isa(varargin{1},'xsymbolic')
\r
53 obj = varargin{1}; %Copy
\r
56 expression=varargin{1};
\r
59 if isempty(expression)
\r
60 % Either the empty constructor was called, or the user supplied an
\r
73 obj.description='Symbolic expression';
\r
74 obj.wvars_auto=true; % PRIVATE
\r
75 obj=class(obj,'xsymbolic');
\r
77 % Ok, the expression is not empty. Let's move on!
\r
79 wchar='w'; % For use in the future
\r
81 % Calculate the amount of subexpressions
\r
82 if isa(expression,'cell')
\r
83 n=length(expression);
\r
85 % A single object was supplied
\r
87 expression={expression};
\r
93 if nargin>=2; xvars=varargin{2}; end;
\r
94 if nargin>=3; uvars=varargin{3}; end;
\r
95 if nargin>=4; wvars=varargin{4}; end;
\r
97 % Convert all subexpressions to char
\r
98 charexpr=convert2char(expression);
\r
100 % If *vars is empty, calculate default values.
\r
101 if isempty(xvars); xvars=getvars(charexpr,'x'); end;
\r
103 wvars=getvars(charexpr,'w');
\r
108 if isempty(uvars); uvars=getvars(charexpr,'u'); end;
\r
110 % Generate the internal expression, for use with the feval command.
\r
111 intexpr=char2oneline(ext2int(charexpr,xvars,'x',wvars,'w',uvars,'u')');
\r
113 obj.expression=expression;
\r
114 obj.intexpr=intexpr;
\r
115 obj.str=expr2str(expression);
\r
116 obj.exprsize=[n,0];
\r
122 obj.islinear=false;
\r
124 obj.description='Symbolic expression';
\r
125 obj.wvars_auto=wvars_auto; % PRIVATE
\r
126 obj=class(obj,'xsymbolic');
\r