# Minimum signal length for notch filter?

I'm back again with another probably very basic question, but I searched a lot about the minimum length of signal for a filter to work, and mine seems to satisfy this (from filtfilt requirement in MATLAB), but still the filter doesn't seem to work. Please help.

Context : Dealing with an encoder signal for angular velocity measurements. The measurement is noisy due to 2 reasons : Eccentricity error of encoder (has a period equal to one revolution), and other errors (position error, state width error etc, which I assume as random). I have tried to remove the influence of random errors by averaging "n" samples, to get a new signal which seems to have worked in cancelling the high frequency noise (after lowpass filtering). However, the eccentricity error still remains.

What I did : I am trying to remove the influence of eccentricity error with a notch filter. I have calculated the mean rotational speed, and used the "irrnotch" function in MATLAB to generate a notch filter.

Problem : Even after applying the notch filter (using filtfilt), that frequency doesn't seem to be attenuated. I only have one rotation worth of data (signal length corresponds to one rotation), and I am trying to cancel out the fundamental frequency (with the period equal to one rotation). How can I proceed with this ? Is the notch filter not working because I have only one rotation worth of data?

I have put some figures below:

The input to the filter is yellow, which is the average angular speed signal. Output from the filter is purple. FVtool from MATLAB. sampling freq for the yellow signal is close to 3.5 Hz (after averaging). cutoff frequency that I need removed is 0.177 Hz. So I input 0.1 as the normalised frequency. I understand in this particular case, there is not much variation in the input signal except the effect of the eccentricity error, and I should probably take the mean and call it a day, but I want to know what I can do if there were higher variations super imposed on the base signal. How should I filter the base signal out ? Should I highpass, and add the mean back? or any other way..

• Are you sure the frequency you need removed is at 0.177Hz?
– Jdip
Mar 3 at 21:01
• I double checked now. The theory is that the eccentricity occurs at the angular frequency of rotation. But I understand that angular frequency won't exactly be constant over time. Since eccentricity effects occur over one full rotation of the encoder, I am using the average angular frequency over the whole rotation as the notch frequency. Average angular frequency is the mean of the yellow curve (10.6334 rpm) so notch freq is (10.6334/60 = 0.17722 Hz) Mar 3 at 21:11
• Your notch filter is fixed. If the frequency deviates even a little from the notch center, it's not going to be attenuated as much.
– Jdip
Mar 3 at 21:21
• But I am using the calculated value as input to design the notch filter in Matlab. I mentioned 0.177 Hz to not type out the full number. Like in the iirnotch function I input the normalised freq as (mean of yellow signal/60)/(fsamp/2). Mar 3 at 21:45
• I get that part, but as you mentioned, the frequency of interest isn’t constant in time. Your filter notches at one fixed frequency, so if the signal has a component that deviates from that frequency, it will sometimes be notched, sometimes not.
– Jdip
Mar 3 at 22:38

Let's call the frequency of interest $$f_0$$. You mention $$f_0$$ isn't constant in time, so it deviates by a certain amount. Let's call that amount $$f_1$$, so that the actual frequency of interest $$f_n \in \left[f_0-f_1, f_0+f_1\right]$$
• An adaptive notch filter that can track $$f_n$$
• A wider notch filter, i.e a band-stop filter with cut-offs based on how much $$f_0$$ deviates (i.e. based on $$f_1$$).
However, if the only component you care about below $$f_n$$ is DC, then go ahead and use a high-pass filter with cut-off $$, and add DC back after filtering.