Initial commit
[pftoolbox.git] / models / @danl / h_general.m
blobf50339152c7ed408e2c7cc29627fb9cc693c68e8
1 function v=h_general(obj,x,t,u,varargin)\r
2 % Calculates: h(x,t) + e(t)\r
3 %\r
4 % Syntax: (* = optional)\r
5 %\r
6 % y = h_general(model, x, t, u, e*);\r
7 %\r
8 % In arguments:\r
9 %\r
10 % 1. model\r
11 %       Model object\r
12 % 2. x\r
13 %       Column vector or scalar containing x(t)\r
14 % 3. t\r
15 %       Scalar containing the time of the operation.\r
16 % 4. u\r
17 %       Column vector or scalar containing deterministic data for this particular step.\r
18 %       Redundand argument for this model.\r
19 % 5* e\r
20 %       Column vector or scalar containing e(t) for this particular step.\r
21 % 5* []\r
22 %       e(t) is drawn from model.e\r
23 %\r
24 % Out arguments:\r
25 %\r
26 % 1. y\r
27 %       The result of the operation, y(t)\r
29 % Toolbox for nonlinear filtering.\r
30 % Copyright (C) 2005  Jakob Rosén <jakob.rosen@gmail.com>\r
31 %\r
32 % This program is free software; you can redistribute it and/or\r
33 % modify it under the terms of the GNU General Public License\r
34 % as published by the Free Software Foundation; either version 2\r
35 % of the License, or (at your option) any later version.\r
36 %\r
37 % This program is distributed in the hope that it will be useful,\r
38 % but WITHOUT ANY WARRANTY; without even the implied warranty of\r
39 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
40 % GNU General Public License for more details.\r
41 %\r
42 % You should have received a copy of the GNU General Public License\r
43 % along with this program; if not, write to the Free Software\r
44 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\r
46 v=eval(obj.h,x,t,[],[]);\r
48 % Handle the measurement noise\r
49 e=[];\r
51 % Fetch the e parameter\r
52 if nargin>=5\r
53         e=varargin{1};\r
54 end;\r
56 if isempty(e)\r
57         % No e was given. Draw from model.e\r
58         e=random(obj.e, t, 1, size(v,2));\r
59         v=v+e;  % An error message here means that e has wrong dimensions\r
60 else\r
61         % e(t) was supplied. Use that value\r
62         v=v+e;  % An error message here means that the supplied e has wrong dimensions\r
63 end\r
65 if length(u)\r
66         if ~isempty(obj.hu)\r
67                 % If hu is empty, don't use u(t). We just want gu(x,t)*u(t)\r
68                 v=v+eval(obj.hu,x,t,[],[])*u;\r
69         end\r
70 end\r