I say "true" instead of true because sometimes we can't know what the truth is, so we have to guess it. Generally, the better the values the Kalman filter use match the "true" values, the better the Kalman filter estimates the state. I've generated my acceleration as a vector that is T long with a variance of 1 you seem to have generated just one value for it with a variance of 100. I've zoomed in on the bottom plot to see the true and estimated values because the noise is so large. The bottom plot is the true (red), noisy (black), and estimated (blue) velocity. The top plot is the true (red), noisy (black), and estimated (blue) position. The implementation gives the following estimates of the position and velocity, and seems to work even with the large velocity noise. I think I've managed to implement your system, but in R rather than matlab (sorry, I have no access to matlab and scilab stopped working for me on OSX). My question is: how can I find Q and R? Does it depend of what I want to do? Here is my Matlab code: (I don't want to use the Matlab Kalman function ) ) %% Kalman Filter Design dt = 0.01 %% Define coefficient matrices % x = % True State equation % x = F * x(t-1) + B * u + w F = B = % Measurement of the true state equation % z = H * x(t) + v H = %% Define noise %Process noise(white noise) % w = Gw * a a = Gw = %Process noise covariance matrix Q = Gw * Gw' * cov(a) %Measurement noise (white noise) v = %Measurement noise covariance matrix R = cov(v)* %% Kalman Filter x_estimate = P = Q position_estimate = velocity_estimate = acc_estimate = P_mag_estimate = predic_state = predic_var = z = for t = 1:length (z) %Predicted state estimate x_estimate = F * x_estimate predic_state = %Predicted estimate covariance P = F * P * F' + Q predic_var = %Innovation covariance S = H * P * H' + R %Kalman Gain Predict measurement covariance K = P * H' * inv(S) % Updated state estimate x_estimate = x_estimate + K * (z(t) - H * x_estimate) %Update covariance estimation P = (eye(size(P,2)) - K * H) * P %Store for plotting position_estimate = velocity_estimate = P_mag_estimate = end I want to estimate a new position (which will be I guess not very different from my measurements) and my velocity as well (which will be more different) I have a quite good measurement signal of my position (let's say a very small white noise) and a pretty noisy measurement signal of my velocity (big white noise). I really read a lot of articles about the design of this filter but the performances of my filter are still quite bad.
![does matlab 2018b have stft function does matlab 2018b have stft function](https://www.mdpi.com/sensors/sensors-18-03103/article_deploy/html/images/sensors-18-03103-g001.png)
I have a quite typical Kalman filter to design.