You are on page 1of 4

Experiment 6

Low Pass and High Pass Filter


Program 1: Design of a low pass filter using MATLAB clc; clear all; close all; Fs=input('Enter sampling frequency: '); Fl=input('Enter the value of low frequency: '); Fh=input('Enter the value of high frequency: '); Fc=input('Enter the cut off frequency: '); t=0:(1/(Fh*100)):2/Fl; A=1+((2*Fs)/Fc); B=1-((2*Fs)/Fc); for n=2:1:((2*Fh*100)/Fl)+1 X1= 10*sin(2*pi*Fl*t); X2= 10*sin(2*pi*Fh*t); X=X1+X2; Vin=X; Vin(1)=1; Vout(1)=1; Vout(n)=(1/A)*[Vin(n)+Vin(n-1)-(Vout(n-1)*B)]; end subplot(2,2,1) plot(t,X1);title(['Low Frequency Signal of ', num2str(Fl) , ' Hz']); subplot(2,2,2) plot(t,X2);title(['High Frequency Signal of ', num2str(Fh) , ' Hz']); subplot(2,2,3) plot(t,X);title(['Input to Filter']); subplot(2,2,4) plot(t,Vout);title(['Output of filter']);

ATMIYA

DIGITAL SIGNAL PROCESSING M.E. (E.C.), 1ST SEMESTER INSTITUTE OF TECHNOLOGY & SCIENCE, RAJKOT.

Experiment 6

Low Pass and High Pass Filter


Output: Enter sampling frequency: 5000 Enter the value of low frequency: 50 Enter the value of high frequency: 500 Enter the cut off frequency: 100

ATMIYA

DIGITAL SIGNAL PROCESSING M.E. (E.C.), 1ST SEMESTER INSTITUTE OF TECHNOLOGY & SCIENCE, RAJKOT.

Experiment 6

Low Pass and High Pass Filter


Program 2: Design of a high pass filter using MATLAB clc; clear all; close all; Fs=input('Enter sampling frequency: '); Fl=input('Enter the value of low frequency: '); Fh=input('Enter the value of high frequency: '); Fc=input('Enter the cut off frequency: '); t=0:(1/(Fh*100)):2/Fl; X1= 10*sin(2*pi*Fl*t); X2= 10*sin(2*pi*Fh*t); X=X1+X2; Vin=X; Vin(1)=1; Vout(1)=1; A=2+(Fc/Fs); B=2-(Fc/Fs); for n=2:1:(2*Fh*100)/Fl+1 Vout(n)=(1/A)*[(2*Vin(n))-(2*Vin(n-1))+(Vout(n-1)*B)]; end subplot(2,2,1) plot(t,X1);title(['Low Frequency Signal of ', num2str(Fl) , ' Hz']); subplot(2,2,2) plot(t,X2);title(['High Frequency Signal of ', num2str(Fh) , ' Hz']); subplot(2,2,3) plot(t,X);title(['Input to Filter']); subplot(2,2,4) plot(t,Vout);title(['Output of filter']);

ATMIYA

DIGITAL SIGNAL PROCESSING M.E. (E.C.), 1ST SEMESTER INSTITUTE OF TECHNOLOGY & SCIENCE, RAJKOT.

Experiment 6

Low Pass and High Pass Filter


Output: Enter sampling frequency: 1000 Enter the value of low frequency: 50 Enter the value of high frequency: 500 Enter the cut off frequency: 100

ATMIYA

DIGITAL SIGNAL PROCESSING M.E. (E.C.), 1ST SEMESTER INSTITUTE OF TECHNOLOGY & SCIENCE, RAJKOT.

You might also like