I have a dataset of accelerometric data that is affected by electical spikes.
I\'m looking for a good method to filter out or reduce these spikes as need to calcula
For others that may need this here's what I ended up using. Here's the data file data file link
Thanks goes to @thewaywewalk
Matlab filter electical spikes in accelerometric data
clear all, clc,clf,tic
aa=csvread(strcat('/tmp/example_data_with_peak.txt'),5,0); %will skip the first 5 rows that are text and zeros
figure(1);
plot(aa)
Af=aa;
% Thresholds
Tl = -mean(abs(aa))*10
To =mean(abs(aa))*10
% initialisation
[peaks_r,peaks_c] = find( Af < Tl | Af > To);
peaks = find( Af < Tl | Af > To);
counter = 0;
while ~isempty(peaks)
peaks = find( Af < Tl | Af > To);
try
Af(peaks) = ( Af(peaks-1) + Af(peaks+1) ) / 2;
catch
if peaks(1) == 1
Af(1) = 0;
else
Af(end) = 0;
end
end
counter=counter+1;
end
counter
figure(2);
plot(Af)
Here are the images of before and after.
