@ Matthew (Jun 28)
I had the same problem (with P growing exponentially). Like you said: this has to do with the Alpha parameter. It has to do with how the Unscented Transform calculates its transformed mean. In certain cases (I think when measurement covariance is very low, and process covariance is a few orders of magnitude greater), there can be some rounding errors in Matlab, which causing the transformed mean to come up short.
To fix this, I changed the UT function to be like this:
function [y,Y,P,Y1] = ut(f,X,Wm,Wc,n,R)
% y=zeros(n,1); % LINE COMMENTED OUT HERE
% y=y+Wm(k)*Y(:,k); % LINE COMMENTED OUT HERE
y = mean([Y(:,1)'; mean(Y(:,2:end)')]); % LINE ADDED HERE
I found that for my system, the covariance matrix was growing like crazy (P_k~10^8*P_k-1) and was getting complex.
Try adjusting the alpha parameter. 10e-3 was way too small for my system, and 0.1 was the bare minimum that I could avoid the covariance issues. 0.15 seemed to work best.
in general, alpha is recommended to be between 10e-3 and 1.
I really have not understood this code yet. In my case, I also study on EKF for GPS data that I want to apply EKF to due with noise and missing data in GPS data. I have one GPS data columm with more than 2000 of length. Who could show me how to do it?
Thank you so much for your kinds