1 [obj, x, P]=mupdate(obj, y, varargin)
\r
2 % Measurement update method for the EKF (Extended Kalman Filter)
\r
4 % Syntax: (* = optional)
\r
6 % [ekfobj, xhat, Phat] = mupdate(ekfobj, y, u*, xpred*, Ppred*, t*);
\r
11 % EKF filter object that will be used for the filtering
\r
13 % The data, y(t), to be filtered, for this particular step.
\r
15 % A scalar or vector u(t) containg the deterministic data, for this particular step.
\r
17 % No u(t) will be used in the calculations.
\r
19 % One-step prediction of x
\r
21 % xpred will be set to ekfobj.xpred(:,end), ie the prediction of the last filter step.
\r
23 % One-step prediction of P
\r
25 % Ppred will be set to ekfobj.Ppred(:,:,end), ie the prediction of the last filter step.
\r
27 % The time of the actual filtering step. Ts will be set to this value
\r
29 % t will be set to ekfobj.t, and also Ts will be set to this value
\r
34 % EKF object containg the result of the measurement update operation.
\r
37 % This can also be accessed from the object using the ekfobj.xhat property
\r
40 % This can also be accessed from the object using the ekfobj.Phat property
\r
42 % For more help, type 'props(ekf)'
\r
44 % Toolbox for nonlinear filtering.
\r
45 % Copyright (C) 2005 Jakob Rosén <jakob.rosen@gmail.com>
\r
47 % This program is free software; you can redistribute it and/or
\r
48 % modify it under the terms of the GNU General Public License
\r
49 % as published by the Free Software Foundation; either version 2
\r
50 % of the License, or (at your option) any later version.
\r
52 % This program is distributed in the hope that it will be useful,
\r
53 % but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
54 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
55 % GNU General Public License for more details.
\r
57 % You should have received a copy of the GNU General Public License
\r
58 % along with this program; if not, write to the Free Software
\r
59 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
\r
61 % Since ue defaults to [], we don't have to go through the long procedure with it
\r
62 if nargin>=3; ue=varargin{1}; else; ue=[]; end;
\r
64 % Declare the arguments
\r
69 % Fetch arguments, if they exist
\r
70 if nargin>=4; xpred=varargin{2}; end;
\r
71 if nargin>=5; Ppred=varargin{3}; end;
\r
72 if nargin>=6; t=varargin{4}; end;
\r
74 % If an empty argument, or no argument at all, was supplied - use its default value!
\r
76 xpred=xpred=obj.xpred(:,end); % xpred default
\r
80 Ppred=obj.Ppred(:,:,end); % Ppred default
\r
84 t=obj.t; % t default
\r
87 % Measurement update block
\r
91 H=hgradx_general(model,xpred, t, ue);
\r
92 V=hgrade_general(model,xpred, t, ue); % only relevant for the DGNL model
\r
93 K=Ppred*H'*inv(H*Ppred*H'+V*R*V');
\r
94 x=xpred+K*(y(:,k)-h_general(model,xpred,t,ue,[]));
\r
97 Ts=t; % One samplepoint used.
\r
99 % Are the history buffers enabled?
\r
101 % Not supported yet.
\r
102 % A good solution is to write to the history at the time update. Investigate it...
\r
103 warning('This operation does not support history buffers');
\r
106 % Store relevant variables in the object
\r