Upload
jagda
View
1
Download
0
Embed Size (px)
DESCRIPTION
Lab Experiment FIR Filter
Citation preview
Ideal Low Pass FIR Filter
Consider the following continuous signal. Design a lowpass digital filter to filter out the
sinusoidal term.
x (t )=2+cos (10 t )
The maximum frequency is 10/ (2*3.14) = 1.59 Hz. Sampling frequency should be at least 10 *1.59 = 15.9 Hz. So the sampling time is .063 Seconds. Let us take Ts=0.1 Seconds.
An analogue low pass filter having cut off frequency 5 rad/s will suppress the cos(10t) term. So the digital cut off frequency to be designed is θC= 5(0.1) = .5
N=11; %filter orderm=(N-1)/2;thetac=.5;n=0:N-1;h=sin(thetac*(n-m+eps))./(pi*(n-m+eps));%eps is used to avoid dividing by zeroh1=h.*(ones(1,N));%we window the filter coefficientsh2=h.*(hanning(N))';n=0:100;Ts=.1;xn1=2;%This signal should pass through the filterxn2=cos(10*n*Ts);%This signal should not passxn=xn1+xn2;t=0:.1:10;xt=cos(10*t)+2;y1=filter(h1,1,xn);y2=filter(h2,1, xn);subplot(3,1,1); plot(t,xt);title('cos(10*t)+2 before filtering');[H1 f1]=freqz(h1,1,100); subplot(3,1,2);plot(f1/pi,abs(H1));hold on;[H2 f2]=freqz(h2,1,100);plot(f2/pi,abs(H2),'*');legend('Rectangular','Hanning',0);ylabel('Filter: Order 11');
subplot(3,1,3); plot(n*Ts,y1);title('The signal after cos(10*t) term is removed: Filter order is 11');xlabel('Time(sec)'); hold on; plot(n*Ts, y2, '*');legend('Rectangular','Hanning',0);
Exercise
Consider the analogue signal
x(t) = sin (t) + sin (10t)
We are interested in suppressing the sin(t) term. Design a digital highpass filter to accomplish
that.