1 function v=gradx(obj,varargin)
\r
2 % Evaluates the gradient object at time t, with respect to x.
\r
4 % Syntax: (* = optional)
\r
6 % v = gradx(obj, x, t, w, u);
\r
11 % The xltv object containing the gradient.
\r
12 % Must be generated by a call to the 'initgradx' method before use.
\r
14 % A column vector or a scalar containing x(t).
\r
16 % A scalar containing the time t.
\r
18 % A column vector or scalar containing u(t).
\r
20 % A column vector or scalar containing w(t)
\r
25 % A matrix containing the gradient at time t.
\r
27 % Toolbox for nonlinear filtering.
\r
28 % Copyright (C) 2005 Jakob Rosén <jakob.rosen@gmail.com>
\r
30 % This program is free software; you can redistribute it and/or
\r
31 % modify it under the terms of the GNU General Public License
\r
32 % as published by the Free Software Foundation; either version 2
\r
33 % of the License, or (at your option) any later version.
\r
35 % This program is distributed in the hope that it will be useful,
\r
36 % but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
37 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
38 % GNU General Public License for more details.
\r
40 % You should have received a copy of the GNU General Public License
\r
41 % along with this program; if not, write to the Free Software
\r
42 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
\r
47 tvec=find(obj.Ts>=t);
\r
56 tlow=Ts(idxlow); % An error here means that Ts contains too few elements for interpolation
\r
57 vlow=array(:,:,idxlow);
\r
58 vup=array(:,:,idxup);
\r
59 v=vup+(vup-vlow)./(tup-tlow).*(t-tup);
\r
67 % Right on target. No interpolation needed.
\r
68 v=obj.array(:,:,idxup);
\r
70 % t is somewhere in Ts
\r
74 vlow=array(:,:,idxlow);
\r
75 vup=array(:,:,idxup);
\r
76 v=vlow+(vup-vlow)./(tup-tlow).*(t-tlow);
\r
78 % idxup==1 and t~=tup, so t<Ts(min)
\r
80 v=array(:,:,1)+(array(:,:,2)-array(:,:,1))./(Ts(2)-tup).*(t-tup);
\r
83 tvec=find(obj.Ts>=t);
\r
85 v=obj.array(:,:,obj.Ts(end));
\r
87 v=obj.array(:,:,tvec(1));
\r
91 idxlength=obj.gradx_idxlength;
\r
93 if isempty(idxlength)
\r
97 v=v(:,1+obj.gradx_idxstart:i+idxlength);
\r