Implementing Kalman Filter using symbolic MATLAB

2 Ansichten (letzte 30 Tage)
Vishakha Ramani
Vishakha Ramani am 28 Mär. 2018
Kommentiert: Walter Roberson am 28 Mär. 2018
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.

Antworten (1)

Walter Roberson
Walter Roberson am 28 Mär. 2018
syms zinv
H_Z = G/(1-(f*(zinv)))
Y_Z = subs(poly2sym(Y_N,zinv), zinv, 1/z)
  2 Kommentare
Vishakha Ramani
Vishakha Ramani am 28 Mär. 2018
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 am 28 Mär. 2018
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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by