Suppose a system follows this equation: $$ x(t)=A \cos(\omega t + \phi)+\eta$$
where: $\omega = 2\pi f $ and $\eta$ is a random error
using Extended Kalman Filter, how does estimated value $\hat{x}$ be?
Signal Processing Stack Exchange is a question and answer site for practitioners of the art and science of signal, image and video processing. It only takes a minute to sign up.
Sign up to join this communityI'm copying my answer to Estimate and Track the Amplitude, Frequency and Phase of a Sine Signal Using a Kalman Filter which solves a more general problem with example code:
We can build a non linear dynamic model in order to estimate the parameters of a sine signal.
Let's model the signal as $ a \sin \left( \phi \right) $ where $ \phi $ is the instantaneous phase. So the model could be also written as $ a \sin \left( \omega t + \psi \right) $.
Then the model can be:
$$ {a}_{k} \sin \left( {\omega}_{k} {t}_{k} + \psi \right) = {a}_{k} \sin \left( {\phi}_{k} \right) $$
With some math and pre processing of Kalman Filter you may derive the model with the matrices:
$$ \boldsymbol{x}_{k} = \begin{bmatrix} {a}_{k} \\ {\omega}_{k} \\ {\phi}_{k} \end{bmatrix}, F = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & \Delta t & 1 \end{bmatrix}, Q = \begin{bmatrix} \Delta t {\sigma}_{a}^{2} & 0 & 0 \\ 0 & \Delta t {\sigma}_{\omega}^{2} & \frac{ {\Delta t}^{2} {\sigma}_{\omega}^{2}}{2} \\ 0 & \frac{ {\Delta t}^{2} {\sigma}_{\omega}^{2}}{2} & \frac{ {\Delta t}^{3} {\sigma}_{\omega}^{2}}{3} \end{bmatrix} $$
Where $ {\sigma}_{a}^{2} $ is the process variance of the amplitude and $ {\sigma}_{\omega}^{2} $ is the variance of the process noise of instant angular frequency.
The measurement model is a bit more tricky. The measurement model is:
$$ {z}_{k} = h \left( \boldsymbol{x}_{k} \right) = {a}_{k} \sin \left( {\phi}_{k} \right) $$
Hence the Jacobian is given by $ \frac{\partial h \left( \boldsymbol{x}_{k} \right )}{\partial \boldsymbol{x}_{k}} = \left[ \sin \left( {\phi}_{k} \right), 0, {a}_{k} \cos \left( {\phi}_{k} \right) \right] $.
Wrapping all this into a Kalman Model will yield:
You may see that the model can effectively track changes in the parameters.
There are other alternatives to this dynamic model but I think this is a simple and effective one.
You may also use the Unscented Kalman Filter. I implemented it at Extended Kalman Filter (EKF) for Non Linear (Coordinate Conversion - Polar to Cartesian) Measurements and Linear Predictions.
The code is available at my StackExchange Signal Processing Q76443 GitHub Repository (Look at the SignalProcessing\Q76443
folder).
dT
is the rate new measurement is measured. Of course it has to be at least by Nyquist. You may use dT = 1
and then everything is in normalized frequency.
$\endgroup$
dT
must be the sampling rate in practice and not the Nyquist rate.
$\endgroup$
This isn't quite what you're asking, because it neglects the amplitude, $A$, but it's a relatively straightforward example of application of an extended Kalman filter to the frequency tracking problem. See section 1.2 of this PDF, that I wrote some time ago.
I'd also recommend starting with B. D. O. Anderson and J. B. Moore, Optimal Filtering, Prentice-Hall, Inc., Engle- wood Cliffs, New Jersey 07632, 1979.