How to remove Spikes from a signal

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 !!
Unbenannt.PNG

11 Comments

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:
Mani Teja
Mani Teja on 27 Sep 2019
Edited: Mani Teja on 27 Sep 2019
Hello Ankit,
Thanks for your reply. I would like to mention that I am aware of the reasons due to which the plot has spikes. My only aim is to get rid of the spikes in the simplest way possible and make it look like the 'Target Curve'.
hi Mani
great can you please attached your complete plot instead of part of it?
thanks
ankit
Hello Ankit,
the attached image is the complete plot. Please scroll towards right to see the complete plot.
Thanks
Ankit
Ankit
Ankit on 27 Sep 2019
Edited: Ankit on 27 Sep 2019
I forgot to ask you which MATLAB version you are using?
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.
Hello Ankit,
thanks for the links and the function. I shall try using them. I am using Matlab 2017b currently.
Hi Adam,
Please scroll towards right to see the complete plot.
Thanks
Mani
Hi Mani,
I was just going through some options in MATLAB, go to know about the below options
I found one such example using filloutliers (see below link)
Regards
Ankit
Hello ankit,
The 'filloutliers' function helped precisely.
thanks :D

Sign in to comment.

Answers (0)

Categories

Asked:

on 27 Sep 2019

Commented:

on 27 Sep 2019

Community Treasure Hunt

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

Start Hunting!