1 function obj = pfsys(varargin)
\r
2 % Constructor for the DANL (Discrete Additive Non-Linear) model
\r
4 % x(t+T) = f(x,t) + gu(x,t)*u(t) + gw(x,t)*w(t)
\r
5 % y(t) = h(x,t) + hu(x,t)*u(t) + e(t)
\r
7 % Syntax: (* = optional)
\r
9 % model = danl(f, gw, gu, h, hu, x0, w, e, p0*, T*, xvars*);
\r
10 % model = danl(ltiobj);
\r
15 % Data object containing f.
\r
16 % If a double (matrix), or a cell array of strings (or inlines) is given, it will be
\r
17 % used to create an apropriate expression object.
\r
18 % Note: if a double is given, a xlinear object will be created with 'evalvar' set to 1,
\r
19 % i.e. the matrix will be multiplied with x when evaluating f(x,t).
\r
21 % A LTI object (ss, tf or zpk), from the control toolbox.
\r
22 % Necessary data will be extracted, and normally distributed noise with variance
\r
25 % Data object containing gw
\r
26 % If a double (matrix), or a cell array of strings (or inlines) is given, it will be
\r
27 % used to create an apropriate expression object.
\r
28 % Note: if a double is given, a xlinear object will be created with 'evalvar' set to 0,
\r
29 % i.e. gw(x,t) is constant and does NOT depend on x.
\r
31 % Data object containing gu
\r
32 % If a double (matrix), or a cell array of strings (or inlines) is given, it will be
\r
33 % used to create an apropriate data object.
\r
34 % Note: if a double is given, a xlinear object will be created with 'evalvar' set to 0,
\r
35 % ie gu(x,t) is constant and does NOT depend on x.
\r
37 % Data object containing h
\r
38 % If a double (matrix), or a cell array of strings (or inlines) is given, it will be
\r
39 % used to create an apropriate data object.
\r
40 % Note: if a double is given, a xlinear object will be created with 'evalvar' set to 1,
\r
41 % ie the matrix will be multiplied with x when evaluating h(x,t).
\r
43 % Data object containing hu
\r
44 % If a double (matrix), or a cell array of strings (or inlines) is given, it will be
\r
45 % used to create an apropriate data object.
\r
46 % Note: if a double is given, a xlinear object will be created with 'evalvar' set to 0,
\r
47 % ie hu(x,t) is constant and does NOT depend on x.
\r
49 % A column vector containing the expectation of the initial state estimate.
\r
50 % Each row represents a state.
\r
52 % Noise object containing w.
\r
53 % It can also be a covariance matrix or a vector containing the diagonal of a
\r
54 % diagonal covariance matrix. This will be used to create a gaussian noise object
\r
57 % Noise object containing e
\r
58 % It can also be a covariance matrix or a vector containing the diagonal of a
\r
59 % diagonal covariance matrix. This will be used to create a gaussian noise object
\r
62 % Noise object containing p0, that has to generate tuples of the same size as x0.
\r
63 % It can also be a covariance matrix or a vector containing the diagonal of a
\r
64 % diagonal covariance matrix. This will be used to create a gaussian noise object
\r
67 % 'p0' is set to independent gaussian noise with variance 1.
\r
73 % A cell array containing the names of the states.
\r
75 % 'xvars' is set to {'x1', 'x2', 'x3', ...}
\r
80 % The resulting danl model object.
\r
82 % Toolbox for nonlinear filtering.
\r
83 % Copyright (C) 2005 Jakob Rosén <jakob.rosen@gmail.com>
\r
85 % This program is free software; you can redistribute it and/or
\r
86 % modify it under the terms of the GNU General Public License
\r
87 % as published by the Free Software Foundation; either version 2
\r
88 % of the License, or (at your option) any later version.
\r
90 % This program is distributed in the hope that it will be useful,
\r
91 % but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
92 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
93 % GNU General Public License for more details.
\r
95 % You should have received a copy of the GNU General Public License
\r
96 % along with this program; if not, write to the Free Software
\r
97 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
\r
100 % Empty constructor
\r
101 % Will create a non-sense object, to satisfy Matlab standards
\r
113 obj.description='Discrete Additive Non-Linear model (DANL)';
\r
114 obj=class(obj,'danl');
\r
118 if isa(argin,'danl')
\r
122 elseif isa(argin,'ss')||isa(argin,'tf')||isa(argin,'zpk')
\r
123 % An LTI object was given
\r
124 obj=lti2danl(argin); %Convert
\r
129 error(nargchk(8, 11, nargin));
\r
134 % Gw was empty. Set it to 1 (we can't just leave it out)
\r
140 if (size(x0,1)==1)&&(size(x0,2)>1);
\r
141 x0=x0'; % A column vector was supplied. Transpose it!
\r
144 % Declare the arguments
\r
149 % Fetch arguments, if they exist
\r
150 if nargin>=9; p0temp=varargin{9}; end;
\r
151 if nargin>=10; T=varargin{10}; end;
\r
152 if nargin>=11; xvars=varargin{11}; end;
\r
154 % If an empty argument, or no argument at all, was supplied - use its default value!
\r
156 p0temp=eye(length(x0)); % p0 default, ind. gaussian noise with variance 1
\r
164 % Generate a xvar vector
\r
166 xvars=cell(1,states);
\r
168 xvars{i}=['x',num2str(i)];
\r
170 elseif length(xvars)~=length(x0)
\r
171 error('The number of elements in ''xvars'' does not match the number of states');
\r
174 % Initialize the noise (supplied as an argument or generated above)
\r
175 p0=initnoise(p0temp);
\r
176 w=initnoise(varargin{7});
\r
177 e=initnoise(varargin{8});
\r
179 % Initialize data. If xvars={}, default xvars will be calculated
\r
180 f=initdata(varargin{1},xvars,{},{},1);
\r
181 gw=initdata(gwobj,xvars,{},{},0);
\r
182 gu=initdata(varargin{3},xvars,{},{},0);
\r
183 h=initdata(varargin{4},xvars,{},{},1);
\r
184 hu=initdata(varargin{5},xvars,{},{},0);
\r
186 %Initialize object data
\r
198 obj.description='Discrete Additive Non-Linear model (DANL)';
\r
199 obj=class(obj,'danl');
\r