University of Oulu
University of Oulu
MATLAB exercise 2
GROUP MEMBERS :
A.L.A.V.Isuru 2655220
D.K.M.A.M.Padmal 2655246
SUPERVISOR :
Kien-Giang Nguyen
Here h[n] is a vector with number of elements ’p’ of channel state and u[n] ∼ N (0, Q)
1
Using Equation 3 and 5, above expression can be simplified as follows.
M[n|n − 1] = E[(Ah[n − 1] + u[n] − Aĥ[n − 1|n − 1])(Ah[n − 1] + u[n] − Aĥ[n − 1|n − 1])T ]
As the reasons of independence between u[n] and h[n] expected value of cross terms will be vanished
and expression will be expressed as below.
M[n|n − 1] = AE[((h[n − 1] − ĥ[n − 1|n − 1])(h[n − 1] − ĥ[n − 1|n − 1])T ]AT + E[u[n]uT [n]]
Then we can define the new estimation for the channel coefficient as follows
Equation 5 , 6, 8, 7 and 9 represent the recursive Kalman filter algorithm. Using initial state
ĥ[−1| − 1] = µh and M[−1| − 1] = C, We can find the each and every state of the variable of
interest with considerable accuracy for the given time.
2
Kalman Filter Equations
2 Implementation
Task 1
To perform the first task in the simulation, Equation 5 , 6, 8, 7 and 9 are implemented as recursive
algorithm in MATLAB with help of initial state. ĥ[−1| − 1] = µh = 0 and M[−1| − 1] = C = 100I
and the following parameters.
0.99 0 0.0001 0
p = 2 (size of the state vector) A = , λ1 = 0.99, λ2 = 0.999, Q =
0 0.999 0 0.0001
and σ 2 = 0.1, λ1 , λ2 are eigen values of matrix A.
Results are shown in Figures 1, 2 ,3 ,4 and 5
Task 2
Change the following parameter in MATLAB program used in Task 1.
0.9 0
A= λ = 0.9 λ2 = 0.99
0 0.99 1
Results are Shown in Figures 6, 7 ,8, 9 and 10
Task 3
Change the following parameter in MATLAB program used in Task 1.
0.99 0 0.01 0
A= , λ1 = 0.99, λ2 = 0.999 and Q =
0 0.999 0 0.01
Results are Shown in Figures 11, 12, 13, 14, 15
Task 4
Change the following parameter in MATLAB program used in Task 1.
0.99 0.01 0.001 0
A= , λ1 = 1.00547, λ2 = 0.983534 and Q =
0.01 0.999 0 0.001
Results are Shown in Figures 16, 17, 18 ,19 and 20
3
3 Simulation results and Discussion
Task 1
1.5
tap weight,hn[0]]
0.5
-0.5
0 10 20 30 40 50 60 70 80 90 100
Sample number, n
1.5
tap weight,hn[1]]
0.5
-0.5
0 10 20 30 40 50 60 70 80 90 100
Sample number, n
3 1.5
2
1 1
0
0.5
-1
0 10 20 30 40 50 60 70 80 90 100
Sample number, n 0
3
2 -0.5
0 10 20 30 40 50 60 70 80 90 100
1
True and estimated tap weight,hn[1]]
Sample number, n
0
-1 1.5
0 10 20 30 40 50 60 70 80 90 100
Sample number, n 1
channel output, x[n]
3
2 0.5
1
0 0
-1
0 10 20 30 40 50 60 70 80 90 100 -0.5
Sample number, n 0 10 20 30 40 50 60 70 80 90 100
Sample number, n
Figure 2: Input - output wave forms of channel Figure 3: Kalman filter estimations
4
1 0.2
0.15
0.5
0.1
0
0.05
0
-0.5
0 10 20 30 40 50 60 70 80 90 100 0 10 20 30 40 50 60 70 80 90 100
Sample number, n Sample number, n
1 0.2
0.15
0.5
0.1
0
0.05
0
-0.5
0 10 20 30 40 50 60 70 80 90 100 0 10 20 30 40 50 60 70 80 90 100
Sample number, n Sample number, n
Above Figures are quite similar to the figures given in Example 13.3 in Text Book[1]
Task 2
1.5
tap weight,hn[0]]
0.5
-0.5
0 10 20 30 40 50 60 70 80 90 100
Sample number, n
1.5
tap weight,hn[1]]
0.5
-0.5
0 10 20 30 40 50 60 70 80 90 100
Sample number, n
5
True and estimated tap weight,hn[0]]
noiseless channel output, y[n]channel input,v[n]
3 1.5
2
1 1
0
0.5
-1
0 10 20 30 40 50 60 70 80 90 100
Sample number, n 0
3
2 -0.5
0 10 20 30 40 50 60 70 80 90 100
1
3
2 0.5
1
0 0
-1
0 10 20 30 40 50 60 70 80 90 100 -0.5
Sample number, n 0 10 20 30 40 50 60 70 80 90 100
Sample number, n
Figure 7: Input - output wave forms of channel Figure 8: Kalman filter estimations
1 0.2
0.15
0.5
0.1
0
0.05
0
-0.5
0 10 20 30 40 50 60 70 80 90 100 0 10 20 30 40 50 60 70 80 90 100
Sample number, n Sample number, n
1 0.2
Minimum MSE, M22[n]
Kalman gain, K2[n]]
0.15
0.5 0.1
0.05
0
0
0 10 20 30 40 50 60 70 80 90 100 0 10 20 30 40 50 60 70 80 90 100
Sample number, n Sample number, n
Figure 9: Kalman filter gains Figure 10: Kalman filter minimum MSE
When changing parameters as given in the task 2 , Kalman gain is converge to the zero quickly
and form low amount of oscillations around zero (Figure 9) compared to the task 1(Figure 4).
Therefore MSE value is converged to the zero value with low amount of samples compared to the
task 1.This mean estimation will not depend on the new samples and it follows the true value
under low amount of the samples(Figure 8).
This is due to the channel tap coefficients are propagation onto zero limit with minimum number
of samples(Figure 6) along with changing of transition matrix(A). As well as matrix A has low
eigenvalues in this case compared to the task 1.
6
Task 3
1.5
tap weight,hn[0]]
0.5
-0.5
0 10 20 30 40 50 60 70 80 90 100
Sample number, n
1.5
tap weight,hn[1]]
0.5
-0.5
0 10 20 30 40 50 60 70 80 90 100
Sample number, n
3 1.5
2
1 1
0
0.5
-1
0 10 20 30 40 50 60 70 80 90 100
Sample number, n 0
3
2 -0.5
0 10 20 30 40 50 60 70 80 90 100
1
True and estimated tap weight,hn[1]]
Sample number, n
0
-1 1.5
0 10 20 30 40 50 60 70 80 90 100
Sample number, n 1
channel output, x[n]
3
2 0.5
1
0 0
-1
0 10 20 30 40 50 60 70 80 90 100 -0.5
Sample number, n 0 10 20 30 40 50 60 70 80 90 100
Sample number, n
Figure 12: Input - output wave forms of channel Figure 13: Kalman filter estimations
7
1 0.2
0.15
0.5
0.1
0
0.05
0
-0.5
0 10 20 30 40 50 60 70 80 90 100 0 10 20 30 40 50 60 70 80 90 100
Sample number, n Sample number, n
1 0.2
0.15
0.5
0.1
0
0.05
0
-0.5
0 10 20 30 40 50 60 70 80 90 100 0 10 20 30 40 50 60 70 80 90 100
Sample number, n Sample number, n
Figure 14: Kalman filter gains Figure 15: Kalman filter minimum MSE
According to the Figure 11, channel tap coefficient (specially h[0]) converge into the zero with rapid
fluctuations compared to the above tasks.this is because co variance matrix Q has higher value as
its elements under this task.
Also Kalman gain has rapid oscillations around the zero compared to the above tasks(Figure
14).Therefore our prediction estimation model gets more samples to follow the true state(Figure
13).Also MSE value is fluctuating highly instead of converging to the zero.
Task 4
1.5
tap weight,hn[0]]
0.5
-0.5
0 10 20 30 40 50 60 70 80 90 100
Sample number, n
1.5
tap weight,hn[1]]
0.5
-0.5
0 10 20 30 40 50 60 70 80 90 100
Sample number, n
8
True and estimated tap weight,hn[0]]
noiseless channel output, y[n]channel input,v[n]
3 1.5
2
1 1
0
0.5
-1
0 10 20 30 40 50 60 70 80 90 100
Sample number, n 0
3
2 -0.5
0 10 20 30 40 50 60 70 80 90 100
1
3
2 0.5
1
0 0
-1
0 10 20 30 40 50 60 70 80 90 100 -0.5
Sample number, n 0 10 20 30 40 50 60 70 80 90 100
Sample number, n
Figure 17: Input - output wave forms of channel Figure 18: Kalman filter estimations
1 0.2
0.15
0.5
0.1
0
0.05
0
-0.5
0 10 20 30 40 50 60 70 80 90 100 0 10 20 30 40 50 60 70 80 90 100
Sample number, n Sample number, n
1 0.2
Minimum MSE, M22[n]
Kalman gain, K2[n]]
0.15
0.5
0.1
0
0.05
0
-0.5
0 10 20 30 40 50 60 70 80 90 100 0 10 20 30 40 50 60 70 80 90 100
Sample number, n Sample number, n
Figure 19: Kalman filter gains Figure 20: Kalman filter minimum MSE
Channel coefficient are increasing compared to the other tasks(Figure 16).But still Kalman gain
converge to the zero with lower oscillations compared to the task 3(Figure 19). In addition MSE
is converged to the zero with reasonable number of samples(Figure 20).Also our prediction model
behave with the true value at considerable accuracy and low fluctuations(Figure 18).This is because
co variance matrix Q has lower values in its diagonal, and provide little fluctuation to our state
model given in Equation 3.
References
[1] Steven M. Kay. Fundamentals of Statistical Signal Processing: Estimation . PRENTICE HALL
SIGNAL PROCESSING SERIES, volume 1.
[2] MATLAB help, https://se.mathworks.com/help/matlab/
4 Matlab Codes
MATLAB program purpose
Lab2 KalmanFilter Implement the Kalman filter to filter out the desired state from the
noisy observation using recursive algorithm