'How do I filter a certain frequency using MATLAB?

I have done a fourier transform of some experimental data to calculate the dominant frequency of the vibration in a flow, but I get a spike at 1000, which is from interferences. How do I ignore or filter this frequency to get the right frequency distribution?



Solution 1:[1]

The easiest approach is probably to use the Matlab function iirnotch.

x = ; % Populate this with your input signal

fsHz = ; % Populate this with your sample rate
notchFreqHz = 1000; % The frequency you with to notch
notchWidthHz = 50; % Notch width (-3 dB bandwidth)

w0 = notchFreqHz / fsHz; % Normalized notch frequency
bw = notchWidthHz / fsHz; % Normalized bandwidth

[num,den] = iirnotch(w0, bw);

y = filter(num, den, x); % Apply the filter, y is the output signal

See Second-order IIR notch filter - MATLAB iirnotch for more details.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 GrapefruitIsAwesome