4.55556

4.6 | 13 ratings Rate this file 225 Downloads (last 30 days) File Size: 82 KB File ID: #18465
image thumbnail

Learning the Kalman Filter in Simulink v2.1

by

 

25 Jan 2008 (Updated )

A Simulink model to learn the Kalman filter for Gassian processes.

| Watch this File

File Information
Description

The zip file contains a Simulink model, which describes a Gassian process and the Kalman filter. A m-script is provided to show how to use this model from the command window. Two examples taken from the File Exchange are included in the m-file to explain how the Kalman filter works.

The package provides a way for beginners to learn the Kalman filter by just editting the model parameters without the need to know the details of calculation. By looking into masked subsystems, you will also be albe to learn how it can be implemented in Simulink.

The model is developed in R14SP1 (MATLAB 7.0.1, Simulink 6.1). If you require it to work with previous version, please let me know.

The new version removes a bug so that it can correctly work with non-zero D.

Acknowledgements

Learning The Kalman Filter and An Intuitive Introduction To Kalman Filter inspired this file.

This file inspired Learning The Kalman Bucy Filter In Simulink and Learning The Kalman Filter: A Feedback Perspective.

Required Products Simulink
MATLAB release MATLAB 7.0.1 (R14SP1)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (21)
21 Jul 2014 Guanlin

thanks a lot!

06 May 2014 Carlos M. Velez S.

A good complement of linear Kalman filter in Simulink: http://www.mathworks.com/matlabcentral/fileexchange/46407-linear-kalman-filter-in-simulink

31 Dec 2012 W. Chong

thanks a lot~ very helpful

31 Dec 2012 W. Chong  
23 Feb 2011 Marzi Azar

Thanks Yi. Can I use the code to minimize the error in the estimated data? I have one estimated data (let's call observation), and another observed data (let's say true). I want to use kalman to update observed values toward true ones.
Thanks

06 Jun 2010 Examples Learn By

Thank you a lot. It's useful for me
http://learnbyexamples.org

08 Apr 2010 Girikrishna

can you tell me based on what equations did you decide the elements of A matrix in your 3rd example.
It would be helpful if you could explain or refer me some material which explains that.

08 Apr 2010 Girikrishna

thank you for all your interest in answering my questions

08 Apr 2010 Girikrishna  
02 Apr 2010 Yi Cao

Simulink does not treat u as 11x2 but a 2x1 vector with 11 sampling points.

01 Apr 2010 Girikrishna

even after considering 1st column as time and discarding it size of u=11*2 and size of B=4*2 how can we multiply when it is like this
B*U <==> [1*2] * [4*2].

30 Mar 2010 Yi Cao

The first column of u is time. This is specified by Simulink.

29 Mar 2010 Girikrishna

Hi Yi Cao thankyou for your great effort in explaining us the simulink model. I will be geratly thank full if you could solve my problem.
In your file runkalmanfilter.m file example :3 for 4 state system you have initialized
tspan=[0 1000];
u=[(0:100:1000)' rand(11,2) ] ;
which generates 11*3 matrix and gives a 1*2 matrix as input matrix for both actual system and to the kalman filter.
our state equations are
x1=Ax+Bu+Q in which
A=4*4 matrix B=4*2 matrix Q=4*4 matrix u=1*2 matrix and x=4*1matrix
in your simulink model where you actually multiplied Ax+Bu+Q how is this possible when matrix dimensions of B and u do not match for multiplication.
stunning part in this is even though matrix dimensions did not match but simulink is executing it how is this possible.
I will be very thank full if you could hell me out.

05 Apr 2009 V. Poor  
22 Jan 2009 Imtiaz Hussain

Thanks a lot........... very useful

16 Jan 2009 Todor Tchangov

Dear Yi Cao,
Knowing your good level, it’s well simplified and definitely a base to get started.

It is properly presented (for the first time in US History) as Bucy and others...
and Rudolf Kalman... who then ...moved in US... and…
Please, read the history, Colleagues:
Who was the American Engineer who made this working... and rectified the Mathematicians Problems ? That way this is the American Invention.

About the Continuous Linear Process:
I think that I have problems, but the major one is with the Process model.

The "A-matrix Process Dynamics- Integration" of X – output of the process, presents the Result of x-dot (or k+1). And this point is “Actuated by U input. How the “u” is presented to all different states (MISO) is presented by B matrix.

After that the Matrix C will present what is measurable and what is Observable.
And then according to “how the “A dynamics” filters the Noise Spectrum presented in point "x-dot" and + + + + will make Kalman Filter to decide “what is true signal and how to restore it”.

Now understanding only “how a (negative) feedback works” and modifies the “Transfer behavior” from Point a to point b… Check out that you made a Positive feedback from X = X+1 (???) to + summing point…!?!?!?! This model has a positive feedback…which in 1985 we had fast “overloading” and had to cold restart our 4 Mb Hard Disk Drive PCs.

But I like your work and I love you guys:
Because it is hard and…
We are big Family.

Sincerely yours,
Todor Tchangov
Sonic Works
todor@sonicworks.com
tezo.spartak@gmail.com
cell: 210 906 5110

21 Mar 2008 Yi Cao

Dear YH Zhang,

Thanks for pointing out these missing files although this is regarding to another submission: Learning the Kalman Filter: A Feedback Perspective. http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=18628&objectType=FILE

These files have been added now.

20 Mar 2008 YH Zhang

Great, but some pictures are missing in The HTML folder
such as,feedbackKF.png,KalmanLTI.png.

06 Feb 2008 Gabrie Tejeda

Excelent, very usefull.
Thanks

27 Jan 2008 Yi Cao

I am sorry you do not like the model. But, I do not understand what you refer to about sample time 1. The first example does not have sample time. The second example has the sample time 0.1 second. This is because the original problem is a continuous time problem. To use the discrete time version Kalman filter, we have to discretize the system, hence need a sample time. A continuous time Simulink model of Kalman filter (Kalman-Bucy filter) has been developed and submitted to the File Exchange. You may wish to try that one to see if you like it.

27 Jan 2008 Scheffe held

i dont like it. more confusing than helping.
why sample time 1?

Updates
28 Jan 2008

update the model to work with MIMO systems plus an MIMO example.

01 Dec 2010

Bug remove so that it can correctly work with non-zero D matrix.

19 Feb 2011

update descriptions

22 Feb 2011

update simulink model

Contact us