MATLAB CODE OF FIR Filter Designing LPF HPF BPF BSF
-
Upload
stepping-for-deveploment -
Category
Engineering
-
view
279 -
download
11
Transcript of MATLAB CODE OF FIR Filter Designing LPF HPF BPF BSF
ECE324: DIGITAL SIGNAL PROCESSING LABORATORY
Practical No.: 6
Roll No.:B-54 Registration No.: 11205816 Name: Shyamveer Singh
Aim: Design a FIR filter1. Low pass filter
Mathematical Expressions Required:
Wc = 2π(fc / fs)Hd(w) =
Inputs :
wc=pi/2m=7
Program Code:
function[]=lpfshyam(wc,N)
i=(N-1)/2;
wn=wc/pi;
syms w
for n=-i:i
y(n+i+1)=(int(exp(w*n*j),-wc,wc))*1/(2*pi);
end
y=sym2poly(y)
for n=0:N-1
w(n+1)=0.54-0.46*cos(2*pi*n/(N-1));
h(n+1)=y(n+1).*w(n+1);
end
h=sym2poly(h)
fir1(N-1,wn)
end
Aim: Design a FIR filter1. Low pass filter
Output:>> lpfshyam((pi/2),7)
y =
-0.1061 0 0.3183 0.5000 0.3183 0 -0.1061
h =
-0.0085 0 0.2451 0.5000 0.2451 0 -0.0085
ans =
-0.0087 0.0000 0.2518 0.5138 0.2518 0.0000 -0.0087
Analysis/ Learning outcomes
This experiment give me a better understanding of low pass filter andhelps me to understand its working graphically.
Aim: Design a FIR filter2. High pass filter
Mathematical Expressions Required:
Wc = 2π(fc / fs)Hd(w) =
Inputs:
Wc=pi/2m=7
Program Codes:
function[]=hpfshyam(wc,N)
i=(N-1)/2;
wn=wc/pi;
syms w
for n=-i:i
y(n+i+1)=(1/2*pi)*(int(exp(j*w*n),-pi,-wc)+int(exp(j*w*n),wc,pi));
end
y=sym2poly(y)
for n=0:N-1
w(n+1)=0.54-0.46*cos(2*pi*n/(N-1));
h(n+1)=y(n+1).*w(n+1);
end
h=sym2poly(h)
fir1(N-1,wn)
end
Output:>> hpfshyam((pi/2),7)
y =
1.0472 0 -3.1416 4.9348 -3.1416 0 1.0472
h =
0.0838 0 -2.4190 4.9348 -2.4190 0 0.0838
ans =
-0.0087 0.0000 0.2518 0.5138 0.2518 0.0000 -0.0087
Aim: Design a FIR filter3. Band pass filter
Mathematical Expressions Required:
Wc = 2π(fc / fs)Hd(w) =
Inputs:
Wc1=pi/4 ,wc2=pi/6m=7
Program Codes:
function[]=bpfshyam(wc1,wc2,N)
i=(N-1)/2;
wn1=wc1/pi;
wn2=wc2/pi;
syms w
for n=-i:i
y(n+i+1)=(1/2*pi)*(int(exp(j*w*n),-wc2,-wc1)+int(exp(j*w*n),wc1,wc2));
end
y=sym2poly(y)
for n=0:N-1
w(n+1)=0.54-0.46*cos(2*pi*n/(N-1));
h(n+1)=y(n+1).*w(n+1);
end
h=sym2poly(h)
fir1(N-1,wn1)
end
Analysis/ Learning outcomes
This experiment give me a better understanding of High pass filter andhelps me to understand its working graphically
Outputs/ Graphs/ Plots:>> bpfshyam((pi/4),(pi/6),7)
y =
0.3067 -0.2104 -0.6506 -0.8225 -0.6506 -0.2104 0.3067
h =
0.0245 -0.0652 -0.5010 -0.8225 -0.5010 -0.0652 0.0245
Aim: Design a FIR filter4. Band stop filter
Mathematical Expressions Required:
Wc = 2π(fc / fs)Hd(w) =
Inputs:
Wc1=pi/4 , wc2=pi/6m=7
Analysis/ Learning outcomes
This experiment give me a better understanding of band pass filter andhelps me to understand its working graphically
Program Codes:
function[]=bsfshyam(wc1,wc2,N)
i=(N-1)/2;
wn1=wc1/pi;
wn2=wc2/pi;
syms w
for n=-i:i
y(n+i+1)=(1/2*pi)*(int(exp(j*w*n),-pi,-wc2)+int(exp(j*w*n),-wc1,wc1)+int(exp(j*w*n),wc2,pi));
end
y=sym2poly(y)
for n=0:N-1
w(n+1)=0.54-0.46*cos(2*pi*n/(N-1));
h(n+1)=y(n+1).*w(n+1);
end
h=sym2poly(h)
fir1(N-1,wn1)
end
Outputs/ Graphs/ Plots:
>> bsfshyam(pi/4,pi/6,7)
y =
-0.3067 0.2104 0.6506 10.6921 0.6506 0.2104 -0.3067
h =
-0.0245 0.0652 0.5010 10.6921 0.5010 0.0652 -0.0245
Analysis/ Learning outcomes
This experiment give me a better understanding of band stop filter andhelps me to understand its working graphically