# Extended Kalman Filter converges to wrong values (super simple model)

조회 수: 7(최근 30일)
Frank 2014년 12월 12일
댓글: Frank 2015년 1월 7일
I am trying to implement an Extended Kalman Filter for an hydraulic/electric circuit that has a resistance (R) and a Capacitor (C) both are connected in parallel. Pressure and flow (voltage and current) are measured. Aim is to estimate R and C. The estimation of the EKF for C is with in the expected range, but the R is always of by a constant factor.
the ODE is: dp/dt = -p/CR + q/C (p is pressure (or voltage), q is flow (or current))
in discrete time the pressure for the next time step is: p = p + T(q/C-p/CR)
I tried two implementations that differ in the state selection:
1. x = [p, 1/C, 1/(C*R)] <-- off by factor 2
2. x = [p, 1/C, 1/R] <-- off by factor 3
for both the input is q and the output is p.
I double checked the equations, and played with different implementations for some days now, but R is always off. and i dont understand why. So it would be great to get some advice because i am running out of ideas.
The jacobians are:
1. state: [1 - Tx3, T u, -T x1 0, 1, 0 0, 0, 1]
2. state [1 - T*x3*x2, T(u-x1x3), -T x1x2 0, 1, 0 0, 0, 1]
It is implemented in simulink and the model is attached if anybody wants to have a look. (packed as zip because slx is not supported)
Thanks!

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

### 채택된 답변

John Petersen 2015년 1월 2일
You have a constant dt used in the filter, but the simulation is variable step. This will cause problems with your predictor. Fix this and then see how it goes.
##### 댓글 수: 1표시 없음숨기기 없음
Frank 2015년 1월 7일
Thanks for your response, I finally found the issue(s).
One was in fact timing related. The sample time of the EKF has to be fixed and not inherited.
The second one was that for the prediction step i used the linearized matrix F to calculate the states. BUT, since known, you can (and have to) use the nonlinear function f.
now it woks nicely! :)

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

### 범주

Find more on Online Estimation in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!