close all, clear all, clc fs = 1000; fs2 = fs/2; fc = [150 250]; fn = fc/fs2; t = linspace(0, 0.05, 50); xn = sin(200*pi*t).^2; figure(1) subplot(2,1,1), stem(t, xn), grid N = 25; B = fir1(N, fn); [H, w] = freqz(B, 1); yn = filter(B, 1, xn); subplot(2,1,2), stem(t, yn), grid figure(2) plot(w/(2*pi)*fs, 20*log10(abs(H))), grid