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