Denoising a curve using Kalman filter technique

3 views (last 30 days)
Josh
Josh on 6 Jul 2022
Edited: Josh on 6 Jul 2022
I have tried to use the concept of Kalman filter for smoothing the curves. However, this code does not seem to denoise the
curve as good as the other techniques such as 'moving average' as we zoom into the denoised curve. Also the second original data point is estimated poorly in the Kalman smoothing. Please help.
clear;clc;close all
load('data001.mat')
x = data001(:,1);
y = data001(:,2);
yy = smoothdata(y,'movmean',0.5);
yy1 = Ksmooth(y');
plot(x,y,'ko',x,yy,'r--',x,yy1,'g--')
function [Data]= Ksmooth(s)
est=s(1);
Eest=1*10^(-5);
Emea=10^(-8);
q=0.05;
for i=1:1:length(s)
mea=s(1,i);
oest=est;
Kf= Eest/(Eest+Emea);
est=est + Kf*(mea-est);
Eest=(1-Kf)*(Eest) + abs(oest-est)*q;
Data(i,:)=est;
end
end

Answers (0)

Community Treasure Hunt

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

Start Hunting!