image thumbnail

Recursive Filter design

by

 

Single Pole Recursive filter is designed to filter a signal of 1hz containing a 10Hz harmonics

Recursive_Filter_design.m
close all
clear all

% ----------Code for generating a 1Hz sine signal with 10Hz harmonic signal---------------%

t=0:0.01:10;
w=2*pi*1;
y=0

y=sin(2*pi*1*t)+0.4*sin(2*pi*t*10);

subplot(2,1,1)
plot(t,y)
grid
title('Sine wave 1Hz with 10hz harmonics samples at fs=100Hz')

%-----------Code to Plot the Frequency spectrum of the signal---------%
N=1024;
X=fft(y,N);
X=fftshift(abs(X));
f=[-N/2:1:N/2-1]/N;
subplot(2,1,2)
f=f*100
plot(f,X)
grid
title('Frequency spectrum of the signal')

%------------Find the filter coeffecients using the formulat
%x=exp(-2*pi*fc/fs and plot the response

fc=2;
fs=100;
x=exp(-2*pi*(fc/fs));
%%%%%%%%% the filter Co-efficients are given below
a=[1-x]
b=[1 -x]

lpf=filt(a,b)
figure
freqz(a,b)
title('Recursive filter with cut-off=2Hz')

figure
%------------Filter the input Y with the recursive filter---------%

y1=filter(a,b,y);
subplot(2,1,1)
plot(y1)
title('The filtered signal')
grid
N = 1024;
X = abs(fft(y1,N));
X = fftshift(X);
F = [-N/2:N/2-1]/N;
subplot(2,1,2)

plot(F*100,X)
title('The FFT of the filtered signal')
grid











Contact us