I have position and acceleration measurements and I would like to apply a Kalman filter to estimate the velocity of the system.

I am not sure yet about how to procede, but I will check the already answered questions on this website (like Estimating velocity from known position and acceleration , Kalman filter with accelerometer with DC offset and Applying Kalman filter to a data set).

Once I have understood how to procede, I will implement it using Matlab. There I saw there are 2 different types of Kalman filter: discrete and continuous. What is the difference? I mean, what is the difference of working with one or the other?

EDIT to be more clear, I am referring to function kalman and kalmd

Since I work with a set of data, should I use the discrete one?


2 Answers 2


I don't have experience with continuous time kalman filters. However from your description it sounds like you are making measurements of position and acceleration over time. If these measurements are sampled, meaning you have individual measurements associated with time, you should be using the discrete time kalman filter. I feel comfortable broadly stating if you are trying to implement the filter on a pc (matlab), microcontroller, fpga, or dsp based on a set of measurements you are implementing the discrete time filter.


Based on your edits, I more clearly understand your question. I don't have experience with Matlab's built-in kalman filter functions but a quick read of the comments in kalmd seem to indicate to me you want to use kalman and not kalmd. Below is a snippet pasted from kalmd that should make it clear.

%   The LTI system SYS specifies the plant data (A,[B G],C,[D 0]).
%   The continuous plant and covariance matrices (Q,R) are first 
%   discretized using the sample time Ts and zero-order hold 
%   approximation, and the discrete Kalman estimator for the 
%   resulting discrete plant is then calculated with KALMAN.

This text tells me the function is expecting a continuous function which it then evaluates/discretizes, and then calls the kalman function to create a discrete filter. From the sounds of it you already have discrete data (measurements over time). Hence kalman is what you want to use.


The difference is simple. In a discrete Kalman Filter you have discrete System dynamics and in a continuous Kalman Filter, also called Hybrid Kalman Filter, the system's dynamics are continuous. For your case the latter is what you are going to need.

Difference in implementation:

The discrete Kalman filter is the "classic" version of the filter. The prediction (or prior) update step simply propagates the system state from [k] to [k+1] using the discrete system dynamics.

With a continuous time system you can't do that since the system is given as a set of differential equations. With a continuous system the prediction step of the Kalman Filter changes as you now need to solve the ODE for the times corresponding to k. The way you solve the ODE is up to you. The easiest is probably the Euler Method and some more advanced ways are the Runge Kutta schemes for example. The equations you are solving are

x_dot(t) = f(t, x(t))
P_dot(t) = F(t)*P(t) + P(t)*F(t)' + Q(t)

Using Euler Method the prior update would look as follows:

x[k+1] = x[k] + dT * f(k, x[k])
P[k+1] = P[k] + dT * ( F[k]*P[k] + P[k]*F[k]' + Q[k])

for the sake of simplicity I just set t=k which in reality is of course not the case and depends on your sampling Time.

The measurement update is the same for discrete and continuous time Kalman since the measurements are assumed to always be discrete (sensors will always send at some rate < infinity) and the internal states of the filter are also discrete.

Note: Doing Continuous Time Kalman Filter is NOT the same as discretizing your continuous system and then apply discrete time Kalman Filter.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.