I am analyzing accelerometer recordings that are contaminated by 'spikes' caused by issues in the digital circuitry. The spikes are problematic, because I wish to determine the peak-amplitude from these signals using an automated procedure from a large number (hundreds, perhaps thousands) of these recordings. Hence, manually determining the amplitudes is possible, but not preferred.

The acceleration recordings are oscillatory in nature and reach frequencies of ~200 Hz. I am planning on using a low-pass filter in Matlab to remove the contaminating spikes in the signal. Sample rate is around 730 Hz. An FFT-based filter may be complicated by the fact that the signal gradually increases and decreases in frequency over time.

Here is a picture of an example recording including the pesky spikes (the noise) in the first 100 ms:


I am using Matlab for signal processing and I am looking for advice on which digital filter for use as a high-pass filter? For example, Butterworth and Chebyshev filters are quite commonly applied if I am not mistaken, but why? Will wavelets do me any good?

  • 1
    $\begingroup$ Fast changing time-domain signals (like spikes) have lots of high frequency components. So a high pass filter probably won't help much. What are you trying to do with the signal? What impact does leaving the spikes in have on what you are trying to do? $\endgroup$
    – Peter K.
    Commented Mar 4, 2015 at 23:56
  • 1
    $\begingroup$ @PeterK. Good point... The thing is I wish to automatically determine peak-amplitudes, which makes these spikes a nuisance. Removal, or at least substantial reduction, by filtering the data would make my life a lot easier. I have also added this info in the question, but have answered your comment also in this comment to make your life easier :). $\endgroup$
    – AliceD
    Commented Mar 5, 2015 at 0:06
  • 1
    $\begingroup$ I think LP filter may be the best choice for this case. Maybe you should consider using a better AD, instead of trying to remove the spikes after recording. $\endgroup$
    – Kattern
    Commented Mar 5, 2015 at 1:47
  • 1
    $\begingroup$ This it.mathworks.com/help/signal/ug/… will help you in choosing the filter. Have a look towards the end of that page: there is a plot which compares different types of filters of the same order $\endgroup$
    – Rhei
    Commented Mar 5, 2015 at 15:31
  • 1
    $\begingroup$ The peaks you want to identify can also have noise spikes. So you basically want to smoothen the signal? $\endgroup$
    – fibonatic
    Commented Mar 6, 2015 at 5:33

2 Answers 2


If you want to detect the peak value of the time-domain signal, it is important not to change phase of each frequency signals. Otherwise, the peak value will be affected by it and will slightly change.

I think you already have recorded signal and you can process it after the recording. If so, it is better to use zero-phased filters, like this function in matlab.


In this case, the needed function is to reduce the spike, which contains so much frequencies. In the help page I have shown before, there is an example of filtering this kind of spikes from the relatively low-frequency signal. I think it's what you need.


I recommend Butterworth low pass filter for its flat gain characteristics. The gain ripple of the Chebtshev would affect badly. The phase change will be corrected by using the filter backward, which the filtfit does. As you imagine, the effect of the phase change would be very little in this case, but it cannot be guaranteed. Just for your information, Bessel would be a candidate when you do the filtering online.

If you still doubt about the effect of the phase shift (not the time-shift) by the filter, you can imagine the time-streched pulse and impulse signal in the image and code below. These signals are almost the same but only the phase are different. Besides the amount of the effect, the phase shift does affect to the amplitude of the signal.

I recomend you to use zero-phase filter if you want to measure the actual amplitude precisely.

the effect of phase. of source it's a kind of special case...

clear all;
close all;

% generate signal with the same phase
N = 2^15; % number of samples for this signal
for k = 1:N/2;
    S(k+1) = exp(0);
S(N/2+2: N) = conj(S(N/2: -1 :2));

signal1 = real(ifft(S));

% generate signal with different phase from above
% this signal is called time-streched pulse.
N = 2^15;
for k = 1:N/2;
    S(k+1) = exp(-1j*2*pi*N/2*(k/N)^2);
S(N/2+2: N) = conj(S(N/2: -1 :2));

signal2 = real(ifft(S));

% and let's see them.
xlim([-1e4, length(signal1)])
ylabel('all the same phase')
xlim([-1e4, length(signal1)])
ylabel('only the phases are different form above')

As I said in the comment, a high pass filter is not what you want.

Below is some scilab code that generates the plot. The plot shows four signals:

  • The original signal.
  • The signal high-pass filtered.
  • The signal median filter.
  • The signal low-pass filtered.

The median filter is a non-linear filter sometimes used in image processing to remove spikes. However, because it is non-linear it may have undesirable effects on your signal.

The low-pass filter still gets impacted by the spike a bit, but it may be preferable to the median filter.

enter image description here


    x = rand(1,1000,"norm");
    omega = 2*%pi*0.0789234;
    y = filter(1,[1 -2*cos(omega) 1],x);

    mx = max(y);

    z = y;
    z(100) = 3*mx;
    title("ORIGINAL SIGNAL")

    hp=eqfir(33,[0 .2;.25 .35;.4 .5],[0 1 1],[1 1 1]);

    zhp = filter(hp,1,z);

    M = 3;
    for k=1:1000,
        lw = max(1,k-M);
        hgh = min(1000,k+M);
        zmdn(k) = median(z(lw:hgh))
    title("MEDIAN FILTERED")

    zlp = filter(0.01,[1 -0.99],z);
    title("LOW PASS FILTERED")
  • $\begingroup$ Thanks, very helpful +1. Probably the LP filter is best, as nonlinear filtering is indeed a bit tricky. But then my question still stands I guess - which type of filter? $\endgroup$
    – AliceD
    Commented Mar 5, 2015 at 1:35
  • 1
    $\begingroup$ Start simple: the simple first order LPF I used is usually where I start. You may need to tweak the coefficients, but it generally does a good first pass at cleaning up the measurements. $\endgroup$
    – Peter K.
    Commented Mar 5, 2015 at 2:01
  • 1
    $\begingroup$ I generally think wavelets are a solution looking for a problem. They have their place, but not for simple (ish) data processing like this. $\endgroup$
    – Peter K.
    Commented Mar 5, 2015 at 2:02
  • $\begingroup$ My question may have been unclear - sorry for that. My sub-question was also on which filter to use for LP filtering - e.g., Butterworth, Chebyshev etc.? Any ideas? $\endgroup$
    – AliceD
    Commented Mar 5, 2015 at 12:19
  • 1
    $\begingroup$ I'd use the simple first order filter to start with. Perhaps combined with a first order DC blocking filter. Then see what your other post-processing does. That may mean you need to design a bandpass filter that keeps your frequencies of interest, but blocks high-and-low frequencies. Can you post a plot of the spectrum of your vibrations? That may give a clue. $\endgroup$
    – Peter K.
    Commented Mar 5, 2015 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.