www.gusucode.com > control 案例程序 matlab源码代码 > control/SpecifyAdditionalInputsStateTransitionMeasurementFcnsExample.m

    %% Specify Additional Inputs in State Transition and Measurement Functions
%%
% Consider a nonlinear system with input |u| whose
% state |x| and measurement |y|
% evolve according to the folowing state transition and measurement
% equations:
%%
%
% $$x[k] = \sqrt{x[k-1]+u[k-1]}+w[k-1]$$
%
%%
%
% $$y[k] = x[k]+2*u[k]+v[k]^2$$
%
%%
% The process noise |w| of the system is additive while the measurement 
% noise |v| is nonadditive.
%%
% Create the state transition function and measurement function for the
% system. Specify the functions with an additional input |u|.
f = @(x,u)(sqrt(x+u));
h = @(x,v,u)(x+2*u+v^2);
%%
% |f| and |h| are function handles to the anonymous functions that store
% the state transition and measurement functions, respectively.
% In the measurement function, because the measurement noise is
% nonadditive, |v| is also specified as an input. Note that |v| is
% specified as an input before the additional input |u|.
%%
% Create an unscented Kalman filter object for estimating the state of the
% nonlinear system using the specified functions. Specify the initial value
% of the state as 1, and the measurement noise as nonadditive.
obj = unscentedKalmanFilter(f,h,1,'HasAdditiveMeasurementNoise',false);
%%
% Specify the measurement noise covariance.
obj.MeasurementNoise = 0.01;
%%
% You can now estimate the state of the system using the |predict| and
% |correct| commands.
% You pass the values of |u| to |predict| and
% |correct|, which in turn pass them to the state transition and
% measurement functions, respectively.
%%
% Correct the state estimate with measurement y[k]=0.8 and input u[k]=0.2 at 
% time step k.
correct(obj,0.8,0.2)
%%
% Predict the state at next time step, given u[k]=0.2.
predict(obj,0.2)