So I am new to kalman filters. This is my first experience with it.

I have some measurements but sometimes due to external factors those measurements become totally wrong (hence the peak when you run my matlab code). If I understand the principles of kalman filtering correctly, I can compensate this incorrect measurements by setting the measurement covariance matrix R as a variable, where R represents the accuracy of the measurement devide. But so far I am not sure about where I should add or how I should include this measurement covariance matrix in my measurements.

Could anybody help me out?

I have tried as follows: https://pastebin.com/KQEx5T10 But am totally not sure about my results.To me it looks like both of the outputs of my kalman filter are too far away from the actual measurements once the peak happened... I would have expected the output curves to be between the "toothshaped" curve and not above it.


1 Answer 1


If you are so new to Kalman filtering, the best first suggestion should be the most readable book on the topic: Fundamentals of Kalman Filtering, from Zarchan.

In the mean time, the measurement noise covariance matrix $R$ is adjusted according to the a priori known (either empirically or theoretically) characteristics of the measurement device (the sensors). When these characteristics change during the operation time of the filter, then you would expectedly reflect that in an update of the measurement noise matrix $R$ according to the new settings.

You will include this measurement noise covariance matrix into the Kalman update equations. Which previously using fixed $R$ will now be using variable $R$ matrix, as a matter of fact.

  • $\begingroup$ A few questions before I accept this good answer. Would it be ok to recalculate the covariance at every new measurements (+/- 40 times per second) ? At every 1/40th of a second 15 measurements are carried out. I have 1 kalman filter for every of those measurements to individually check those values, i.e.15 kalman filters. Do you think that's OK? I feel like that's overkill... $\endgroup$
    – bitmumbler
    Apr 2, 2017 at 19:24
  • $\begingroup$ You need to recalculate the measurment error covariance matrix $R$, only when the measurement noise variance (of a white gaussian noise for example) changes. If that changes for every sampling instant, you should recalculate $R$ in accordance. Normally 1 filter or 15 (parallel) filters do not matter. This is true for each filter. $\endgroup$
    – Fat32
    Apr 2, 2017 at 20:12
  • $\begingroup$ don't you think implementing 15 parallel kalman filters is exaggerated? Initially there are 200 measurements, so 200 kalman filters would be a possibility as well... $\endgroup$
    – bitmumbler
    Apr 2, 2017 at 20:18
  • $\begingroup$ sorry you said that you have 15 Kalman filters. I can't know your reasoning. you may well merge all of them into a single filter as well. But that's your decision. Number of Kalman filters is related on what you want to estimate if you want to estimate a single thing, then 1 filter is ok. You can also estimate multiple variables (which constitude the state) with a single Kalman filter. But also, for each estimated variable (possibly being unrelated to each other) then you can use a separate Kalman filter. That can only be decided by the nature of your problem. $\endgroup$
    – Fat32
    Apr 2, 2017 at 20:28
  • $\begingroup$ Any suggestions about from where this book can be downloaded? $\endgroup$ Apr 4, 2017 at 20:35

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.