To design a FIR notch filter using a Hamming window in MATLAB, you can start by defining the desired notch frequency and the sampling rate. Use the fir1 function to create the filter coefficients with the specified notch frequency, applying the Hamming window to shape the filter. Finally, use the filter function to apply the notch filter to your signal. Here's a simple example code snippet:
<code class="language-matlab">fs = 1000; % Sampling frequencyf_notch = 50; % Notch frequency bw = 5; % Bandwidth of the notch n = 100; % Filter order
% Calculate normalized frequency Wn = [f_notch-bw/2, f_notch+bw/2] / (fs/2); b = fir1(n, Wn, 'stop', hamming(n+1)); % FIR notch filter design
% Apply the filter to your signal filtered_signal = filter(b, 1, signal);
</code>
Copyright © 2026 eLLeNow.com All Rights Reserved.