Initial commit
[pftoolbox.git] / models / @dgnl / hgrade_general.m
blob0874713902ce82a421fa635c356071ede8146730
1 function v=hgrade_general(obj,x,t,u,varargin)\r
2 % Calculates: grad_e[h(x,t,u,e)]\r
3 %\r
4 % Syntax: (* = optional)\r
5 %\r
6 % grad_e = hgrade_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\r
14 %       Redundant argument for this model, because x is elimiated by the differentiation.\r
15 % 3. t\r
16 %       Scalar containing the time of the operation.\r
17 %       Redundant argument for this model, because t is elimiated by the differentiation.\r
18 % 4. u\r
19 %       Column vector or scalar containing deterministic data for this particular step.\r
20 %       Redundant argument for this model, because u(t) is eliminated by the differentiation.\r
21 % 5* e\r
22 %       Column vector or scalar containing e(t) for this particular step.\r
23 %       Redundant argument for this model, since this is eliminated by the differentiation.\r
24 %\r
25 % Out arguments:\r
26 %\r
27 % 1. grad_w = 1\r
28 %       The result of the operation: the gradient with respect to e.\r
29 %       grad_w always equals one for this model.\r
31 % Toolbox for nonlinear filtering.\r
32 % Copyright (C) 2005  Jakob Rosén <jakob.rosen@gmail.com>\r
33 %\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
38 %\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
43 %\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
48 e=[];           % Default: draw noise from object\r
49 if nargin>=5 \r
50         e=varargin{1};          % w was supplied as an argument\r
51 end;\r
52 if isempty(e)\r
53         % No w was given as an argument. Use model.w to draw random data\r
54         % if size(x,2)>1, we are dealing with a particle swarm and must draw a matrix\r
55         e=random(obj.e, t, 1, size(x,2));\r
56 else\r
57         % We assume that w=0 and no noise is going to be drawn.\r
58         % However, the zero matrix needs to have the same length as x,\r
59         % because we're dealing with a particle swarm.\r
60         e=zeros(get(obj.e,'n'), size(x,2));\r
61 end\r
63 v=gradw(obj.h,x,t,u,e);\r