文档

DSP.KalmanFilterSystem object

使用卡尔曼过滤器估算系统测量和状态

Description

Kalmanfilter是用于递归获得线性最佳滤波解决方案的估计器。该估计是在没有精确了解基础动态系统的情况下进行的。卡尔曼过滤器通过状态实现以下线性离散时间过程,X,在kThtime-step: X (( k = 一个 X (( k - 1 + b (( k - 1 + w (( k - 1 ((state equation). This measurement,z,以: z (( k = H X (( k + v (( k (测量方程)。

这Kalman filter algorithm computes the following two steps recursively:

  • Prediction: Process parameters x (state) and P (state error covariance) are estimated using the previous state,

  • 校正:使用当前测量值纠正状态和误差协方差,

To filter each channel of the input:

  1. Define and set up your Kalman filter. See建造

  2. 称呼stepto filter each channel of the input according to the properties ofDSP.KalmanFilter。行为step特定于工具箱中的每个对象。

笔记

从R2016b开始,而不是使用stepmethod to perform the operation defined by the System object™, you can call the object with arguments, as if it were a function. For example,y = step(obj,x)andy = obj(x)执行等效操作。

建造

kalman = dsp.KalmanFilterreturns the Kalman filter System object,kalman,具有参数的默认值。

kalman = dsp.kalmanfilter('属性名称',适当的价值,...))returns an Kalman filter System object,kalman,每个属性设置为指定值。

kalman = dsp.kalmanfilter(STMatrix, MMatrix, PNCovariance, MNCovariance, CIMatrix, 'PropertyName', PropertyValue, ...)返回卡尔曼过滤系统对象,kalman。这StateTransitionMatrixproperty is set toSTMatrix,,,,andMeasurementMatrixproperty is set tommatrix。In addition, theProcessNoisecovariance属性设置为PNCOVARIANCE,,,,MeasurementNoiseCovariance属性设置为MNCovariance,,,,ControlInputMatrix属性设置为CIMatrix。Other specified properties are set to the specified values.

特性

StateTransitionMatrix

国家过渡模型

指定一个in the state equation that relates the state at the previous time step to the state at current time step.一个is a square matrix with each dimension equal to the number of states. The default value is1

ControlInputMatrix

控制输入​​与状态之间的关系模型

指定b在状态方程中,将控件输入与状态相关联。b是一个等于状态数量的行的矩阵。仅在ControlInputPort属性值是true。默认值是1

MeasurementMatrix

Model of relation between states and measurement output

指定H在将状态与测量相关的测量方程式中。H是一个矩阵,具有等于测量数量的列数。默认值是1

ProcessNoisecovariance

Covariance of process noise

指定as a square matrix with each dimension equal to the number of states. This matrix,,,,,is the covariance of the white Gaussian process noise,w,,,,in the state equation. The default value is0。1

MeasurementNoiseCovariance

测量噪声的协方差

指定ras a square matrix with each dimension equal to the number of states. This matrix,r,,,,is the covariance of the white Gaussian process noise,v,在测量方程中。默认值是0。1

初始面积

状态的初始值

指定an initial estimate of the states of the model as a column vector with length equal to the number of states. The default value is0

初始ErrorCovariancerSestimate

Initial value for state error covariance

指定an initial estimate for covariance of the state error, as a square matrix with each dimension equal to the number of states. The default value is0。1

DisableCorrection

禁用过滤器

指定as a scalar logical value, disabling System object filters from performing the correction step after the prediction step in the Kalman filter algorithm. The default value isfalse

ControlInputPort

Presence of a control input

使用标量逻辑值指定是否存在控件输入。默认值是true

Methods

reset 重置卡尔曼过滤器的内部状态
step 使用Kalman过滤对象输入过滤器
Common to All System Objects
release

一个llow System object property value changes

Examples

expand all

笔记: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalentstep句法。例如,myObject(x)变为步骤(myObject,x)。

Create the System objects for the changing scalar input, the Kalman filter, and the scope (for plotting).

numsamples = 4000;r = 0.02;src = dsp.SignalSource;src.Signal = [ones(numSamples/4,1); -3*ones(numSamples/4,1);...4 * 1 (numSamples / 4,1);-0.5*一个(numsamples/4,1)];tscope = dsp.timescope('NumInputPorts',3,'时间跨度',,,,numSamples,...'TimeUnits',,,,“秒”,,,,'YLimits',[-5 5],,...“ Showlegend”, 真的);% Create the Time Scopekalman = dsp.kalmanfilter('ProcessNoiseCovariance',,,,0。0001,,,,...“ MeasurementNoIsecovariance”,r,,...“初始状态”,,,,5,...'InitialErrorCovarianceEstimate',1,...“ ControlInputPort”,错误的);%创建Kalman过滤器

一个dd noise to the scalar, and pass the result to the Kalman filter. Stream the data, and plot the filtered signal.

while(〜ISDONE(src))trueVal = src();noisyval = trueVal + sqrt(r)*randn;estVal = kalman(noisyVal); tScope(noisyVal,trueVal,estVal);结尾

笔记: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalentstep句法。例如,myObject(x)变为步骤(myObject,x)。

Create the signal, Kalman Filter, and Time Scope System objects.

numsamples = 4000;r = 0.02;src = dsp.SignalSource;src.signal = [hons(numsamples/4,1);-3*一个(numsamples/4,1);...4 * 1 (numSamples / 4,1);-0.5*一个(numsamples/4,1)];tscope = dsp.timescope('NumInputPorts',3,'时间跨度',,,,numSamples,...'TimeUnits',,,,“秒”,,,,'YLimits',[-5 5],,...'Title',,,,['true(频道1),嘈杂(频道2)和',,,,...'estimated(channel 3) values'],...“ Showlegend”, 真的);kalman = dsp.kalmanfilter('ProcessNoiseCovariance',,,,0。0001,,,,...“ MeasurementNoIsecovariance”,r,,...“初始状态”,,,,5,...'InitialErrorCovarianceEstimate',1,...“ ControlInputPort”,错误的);ctr = 0;

一个dd noise to the signal. Stream the data, and plot the filtered signal.

while(〜ISDONE(src))trueVal = src();noisyval = trueVal + sqrt(r)*randn;estVal = kalman(noisyVal); tScope(trueVal,noisyVal,estVal);%禁用中间的第二个过滤器的校正步骤% one-third of the simulationifctr ==地板(numsamples/3)kalman.disableCorrection = true;结尾ifctr ==地板(2*numsamples/3)kalman.disableCorrection = false;结尾ctr = ctr + 1;结尾

笔记: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalentstep句法。例如,myObject(x)becomesstep(myObject,x)

创建信号,其中列是要跟踪的两个标量值。还可以创建卡尔曼过滤器和时间范围。

numsamples = 4000;r = 0.02;src = dsp.SignalSource;sig1 = [一个(numsamples/4,1);-3*一个(numsamples/4,1);...4 * 1 (numSamples / 4,1);-0.5*一个(numsamples/4,1)];sig2 = [-2*一个(numsamples/4,1);4*一个(Numsamples/4,1);...-3*一个(numsamples/4,1);1.5*一个(numsamples/4,1)];src.signal = [Sig1,sig2];tscope1 = dsp.timescope('NumInputPorts',3,'时间跨度',,,,numSamples,...'TimeUnits',,,,“秒”,,,,'YLimits',[-5 5],,...'Title',,,,['true(频道1),嘈杂(频道2)和',,,,...'estimated(channel 3) values'],...“ Showlegend”, 真的);tscope2 =克隆(tscope1);kalman = dsp.kalmanfilter('ProcessNoiseCovariance',,,,0。0001,,,,...“ MeasurementNoIsecovariance”,r,,...“初始状态”,,,,-3,...'InitialErrorCovarianceEstimate',1,...“ ControlInputPort”,错误的);

一个dd noise to the signal. Stream the data, and plot the filtered signal.

while(〜ISDONE(src))trueVal = src();noisyVal = trueVal + sqrt(R)*randn(1,2); estVal = kalman(noisyVal);百分比的绘图结果在时间范围内tscope1(trueval(:,1),noisyval(::,1),estval(::,1));% Plot results of second channel on Time ScopetScope2(trueVal(:,2),noisyVal(:,2),estVal(:,2));结尾

笔记: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalentstep句法。例如,myObject(x)变为步骤(myObject,x)。

使用单元步骤作为控件输入来跟踪坡道信号。创建要跟踪的坡道信号,控制输入,时间范围和卡尔曼滤波器。

numsamples = 200;r = 100;src = dsp.SignalSource;src.signal =(1:numsamples)';控制= dsp.SignalSource;control.signal =一个(numsamples,1);tscope = dsp.timescope('NumInputPorts',3,'时间跨度',,,,numSamples,...'TimeUnits',,,,“秒”,,,,'YLimits',,,,[-5 205],...'Title',,,,['Noisy(channel 1), True(channel 2) and ',,,,...'estimated(channel 3) values'],...“ Showlegend”, 真的);kalman = dsp.kalmanfilter('ProcessNoiseCovariance',,,,0。0001,,,,...“ MeasurementNoIsecovariance”,r,,...“初始状态”,1,...'InitialErrorCovarianceEstimate',,,,1);

一个dd noise to the signal. Filter the signal using kalman filter. View the output using time scope.

while(〜ISDONE(src))trueVal = src();ctrl = control();noisyval = trueVal + sqrt(r)*randn;estval = kalman(noisyval,ctrl);tscope(noisyval,trueval,estval);结尾

一个lgorithms

This object implements the algorithm, inputs, and outputs described on the卡尔曼过滤器block reference page. The object properties correspond to the block parameters.

references

[1] Greg Welch and Gary Bishop, An Introduction to the Kalman Filter, Technical Report TR95 041. University of North Carolina at Chapel Hill: Chapel Hill, NC., 1995.

扩展功能

也可以看看

Introduced in R2013b

Was this topic helpful?