I need to implement an extended Kalman filter in a MATLAB for loop and decided to use the extendedKalmanFilter object. This was not too difficult and I have it working on a non-linear system with 2 outputs. However, each output is sampled at a different rate, y(1) every minute and y(2) every ten minutes: So my measurement data looks like this:
Here is the code I tried, naively, and the error that is raised:
EKF = extendedKalmanFilter(@arom3_StateFcnRodin, @arom3_MeasurementFcnRodin2, InitialState);
EKF.ProcessNoise = diag(sigma_w);
EKF.MeasurementNoise = diag(R);
EKF.StateCovariance = diag(P0);
EKF.MeasurementFcn = @arom3_MeasurementFcnRodin1;
EKF.MeasurementNoise = diag(R(1));
EKF.MeasurementFcn = @arom3_MeasurementFcnRodin2;
EKF.MeasurementNoise = diag(R);
[CorrectedState, CorrectedStateCovariance] = correct(EKF, yk_m);
[PredictedState, PredictedStateCovariance] = predict(EKF, dt, params);
Where arom3_MeasurementFcnRodin1 and arom3_MeasurementFcnRodin2 are different measurement functions reflecting the 1 and 2 output system respectively:
function y = arom3_MeasurementFcnRodin1(xa)
and
function y = arom3_MeasurementFcnRodin2(xa)
Error raised:
Error using ExtendedKalmanFilter
Expected z to be an array with number of elements equal to 1.
Error in matlabshared.tracking.internal.validateInputSizeAndType (line 14)
validateattributes(value, ...
Error in matlabshared.tracking.internal.ExtendedKalmanFilter/correct (line 629)
matlabshared.tracking.internal.validateInputSizeAndType...
Error in arom3_sim_EKF3 (line 193)
[CorrectedState, CorrectedStateCovariance] = correct(EKF, yk_m);
Note: the code works when the sample rates are both 1.
Is this even possible with extendedKalmanFilter? Are there any other options, or will I have to implement the EKF by hand?