How to remove Spikes from a signal
Show older comments
Hello everyone,
I have a plot below which consists of two curves:
1. Red Curve - Original
2. Green Dotted Curve - Target
I want to filter out the spikes from the 'Original Curve' and replace it with suitable values such that the 'Original Curve' appears like the 'Target Curve'. In the plot below, I have achieved it using Interpolation. I want to find an easier way to do it. I even tried using 'medfilt1' function but I am not able to get rid of all the spikes. Any help would be highly appreciated.
Thanks !!

11 Comments
Ankit
on 27 Sep 2019
I will first find out the reasons why I am getting these spikes and answers to following question
is this behavior expected or not?
Whether it is because of Solver settings? Is my time time step is too large?
If you real want to avoid this behavior have a look on below links:
Ankit
on 27 Sep 2019
hi Mani
great can you please attached your complete plot instead of part of it?
thanks
ankit
Mani Teja
on 27 Sep 2019
sorry my bad!
have you tried sgolayfilt() also?
here you can find more examples for filtering out signals
Ankit
on 27 Sep 2019
I forgot to ask you which MATLAB version you are using?
Adam
on 27 Sep 2019
I'd be surprised if a smoothing filter could help you convert that to your target. Spikes generally considered as being anomalous to the main trend, but in your case it's the majority of your data, at least from -100 to -60 that is 'spikes' and almost none of the data in that range is down at your target line and none of it below the target.
Mani Teja
on 27 Sep 2019
Mani Teja
on 27 Sep 2019
Ankit
on 27 Sep 2019
Hi Mani,
I was just going through some options in MATLAB, go to know about the below options
Clean Outlier Data: https://de.mathworks.com/help/matlab/ref/cleanoutlierdata.html
I found one such example using filloutliers (see below link)
Regards
Ankit
Mani Teja
on 27 Sep 2019
Answers (0)
Categories
Find more on Electrophysiology in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!