Implementing Kalman Filter using symbolic MATLAB

조회 수: 7 (최근 30일)
Vishakha Ramani
Vishakha Ramani 2018년 3월 28일
댓글: Walter Roberson 2018년 3월 28일
Hello all
I have been trying to implement the Kalman filter to predict the values of input x(n) given the observations y(n). According to the text book, the optimal filter weights are given as:
H(z) = G/(1-f*(z^-1))
I have calculated the values of G and f. I also have the vector of observations Y_N.
The difference equation thus comes out to be : x(n) = f*x(n-1) + G*y(n)
I want to plot the estimates x(n) now using SYMBOLIC MATLAB.
Following is my code:
syms z H_Z;
H_Z = G/(1-(f*(z^-1)))
syms Y_Z X_Z n
Y_Z = poly2sym(Y_N,z^-1) %(I am also stuck at this part- how do you calculate the z-transform of a vector. MATLAB refuses to take z^-1 as the symbolic variable)
X_Z = H_Z*Y_Z
x_n = sym2poly(X_Z) %(getting an error here: not a polynomial)
Would anybody please guide me with this problem. If my logic is correct, then any help with syntax would be appreciated.

답변 (1개)

Walter Roberson
Walter Roberson 2018년 3월 28일
syms zinv
H_Z = G/(1-(f*(zinv)))
Y_Z = subs(poly2sym(Y_N,zinv), zinv, 1/z)
  댓글 수: 2
Vishakha Ramani
Vishakha Ramani 2018년 3월 28일
Thank you for your prompt reply. The solution worked. However, I am still getting an error in last line where I need the vector of estimates x_n.
I used:
X_Z = H_Z*Y_Z;
x_n = sym2poly(X_Z) %it says Not a polynomial.
Walter Roberson
Walter Roberson 2018년 3월 28일
even if you
X_Z = subs(H_Z, zinv, 1/z)*Y_Z
then what you get out is not a polynomial and cannot be converted to one. H_Z divides by an expression involving the variable, leading to an expression that cannot be rationalized to be a polynomial. The best you could hope for is a ratio of polynomials. Unfortunately, MATLAB does not make it easy to find out what the ratio consists of.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by