Search code examples
matlabkalman-filter

Electronics - Matlab - I would like to us a Kalman Filter in a GPS doppler speed signal


I would like to use the Kalman Filter in the GPS Doppler speed. Even if I read some tutorials in the web, I have no idea how to do it.

Is there a matlab script that can do it only by given in input the GPS speed. Maybe I have to precise the sample frequency also ?


Solution

  • Here is the minimal matlab code with vision.KalmanFilter class. assuming your measurements are column vectors of matrix data [latitude, latitude_speed, longitude, longitude_speed]'. constant velocity model is assumed here. You should define ProcessNise, MeasurementNoise and the initialization yourself.

    data = randn(4,100); % load your data here
    
    delta = 1; % sampling frequency
    % state model asuming constant velocity
    stateModel = [1 delta 0 0    ; 
                  0 1     0 0    ;
                  0 0     1 delta;
                  0 0     0 1    ];
    % measurements are simply the state
    measurementModel = eye(4);
    
    kalman = vision.KalmanFilter(stateModel, ...
                                 measurementModel, ...
                                 'ProcessNoise',1, ...
                                 'MeasurementNoise',1);
    
    %initialize
    kalman.State = [0; 0; 0; 0];
    kalman.StateCovariance = eye(4);
    
    T = size(data,2); % length of measurements
    filtered = [];
    for t=1:T
        measurement = data(:,t);
        kalman.predict(); % prediction
        kalman.correct(measurement);
        filtered = [filtered, kalman.State];
    end