%my finite imp resp filter
clear all; clc; close all;
[b,a] = fir1(50, 1/8,'low'); % creating your filter
%fir1(order usually 30-50, cuttoff_normalized_freq, 'type high, low, band')
%this is to view your filter
figure(1);
freqz(b,a);
N=500; %number of points to calculate
fe=5000;
n=0:1:N-1;
%your input signal
x=sin(2*pi*200*n/fe)+sin(2*pi*1400*n/fe);
%one passes, one doesn't;
%now filtering the signal y with this FIR
figure(2);
y=filter(b,1,x);
subplot(2,1,1);
plot(n,x);grid;legend('input signal'); xlabel('time'); ylabel('ampl');
subplot(2,1,2);
plot(n,y); grid; legend('output filtered signal'); xlabel('time'); ylabel('ampl');