Initial commit
[pftoolbox.git] / filters / @ekf / reset.m
blobd1345f50a419a668248540fdde5970b844957799
1 function objout=reset(obj,varargin)\r
2 % Resets the Extended Kalman Filter (EKF).\r
3 % When this function is called, the filter forgets all previous information about\r
4 % the states.\r
5 %\r
6 % Syntax: (* = optional)\r
7 %\r
8 % obj* = reset(obj, t*);\r
9 %\r
10 % In arguments:\r
11 %\r
12 % 1. obj\r
13 %       The filter object to reset.\r
14 % 2* t\r
15 %       Sets the time property t to the given value.\r
16 % 2* []\r
17 %       If the object contains sample point data Ts, t will be set to Ts(1). If not, the\r
18 %       stored t property will not be altered by the reset.\r
19 %\r
20 % Out arguments:\r
21 %\r
22 % 1* obj\r
23 %       The reset filter object.\r
24 %       If no output argument is specified, the input object in the caller's workspace\r
25 %       will be modified.\r
27 % Toolbox for nonlinear filtering.\r
28 % Copyright (C) 2005  Jakob Rosén <jakob.rosen@gmail.com>\r
29 %\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
34 %\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
39 %\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
44 if nargin>1\r
45         obj.t=varargin{1};\r
46 elseif length(obj.Ts)\r
47         obj.t=obj.Ts(1);\r
48 end\r
49 model=obj.model;\r
50 obj.xpred=calc_x0(model,1);             % Calculate x0\r
51 obj.Ppred=get(model,'P0');              % Copy P0 from the model\r
53 if nargout==0\r
54         % No output variable was specified by the user.\r
55         % We'll do the assignment manually in the caller's workspace.\r
56         objname = inputname(1);\r
57         assignin('caller',objname,obj)\r
58 else\r
59         objout=obj;\r
60 end;\r