Kalman Filtering for smoothing GPS speed data

조회 수: 33 (최근 30일)
N/A
N/A 2020년 6월 17일
댓글: Rahim Nami 2022년 10월 11일
Hello,
I have a Kalman Filter code like this and I get a really plain result. You can check it in the attachment 'deneme'. But I want to get a result like attachment file '32'. What should I do? Please help me I really need it. (dataa file is a part of my data, if you want to try something on it) :)
clear all
clc
P = 1;
R = 0.1;
XK1 =0;
hold on
data=xlsread('dataa');
Z=data(1:end,9);
uzunluk=length(Z);
XK_sakla=[1:uzunluk];
KG_sakla=[1:1:uzunluk];
a=0;
for y = [1:uzunluk]
a=a+1;
KG = P/(P+ R);
XK = XK1 + (KG*(Z(a)-XK1));
P = (1-KG)*P;
XK1 = XK;
XK_sakla(a) = XK;
KG_sakla(a) = KG;
end
scatter(1:uzunluk,Z,'x','black','Linewidth',1);
plot (1:uzunluk , XK_sakla,'blue','Linewidth',1 );
xlabel('Number of Observations');
ylabel('Value');
  댓글 수: 1
Rahim Nami
Rahim Nami 2022년 8월 19일
https://www.mathworks.com/matlabcentral/answers/1782290-design-filter-kalman-time-series-gps
Please help me

댓글을 달려면 로그인하십시오.

채택된 답변

Jim Riggs
Jim Riggs 2020년 6월 17일
The problem is with this line:
P = (1-KG)*P;
This causes the gain P to continuously decrease. After a while, the gain P is very small and the filter does not follow the data.
Try replacing this with the following using a constant gain;
...
KG = 1;
for y = [1:uzunluk]
a=a+1;
%KG = P/(P+ R); % comment out this line
XK = XK1 + (KG*(Z(a)-XK1));
%P = (1-KG)*P; % comment out this line
XK1 = XK;
XK_sakla(a) = XK;
KG_sakla(a) = KG;
end
...
Using a constant value of 1, the filter goes through each data point.
After this, try running with KG less than 1 to see the effect, (e.g.)
KG = 0.5;
See how that looks.
  댓글 수: 3
N/A
N/A 2020년 6월 18일
@jim riggs You are a real lifesaver thank you so much :)
Rahim Nami
Rahim Nami 2022년 10월 11일
Hello everyone Please explain the mathematical model of the code that is asked. you write Or This code is related to which mathematical model Thanks a lot

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by