You are on page 1of 3

Problem: A signal at a sampling frequency of 2.

048 KHz is to be decimated by a factor of


32. The antialiasing filter should satisfy the following specifications:
Pass band ripple: 0.00115
Stop band ripple: 0.0001
Pass band edge frequency: 30Hz
Stop band edge frequency: 32Hz

Design a suitable decimator.

clc; clear all; close all;


FT=input('enter the sampling frequency');
m=input('enter the decimation factor');
m1=input('enter the first decimation factor');
m2=input('enter the second decimation factor');
m3=input('enter the third decimation factor');
wp=input('enter the passband edge frequency');
ws=input('enter the stopband edge frequency');
mval=input('enter the magnitude values');
rp=input('enter the passband ripple');
rs=input('enter the stopband ripple');
fedge=[wp ws]; dev=[rp rs];
[N,fpts,mag,wt]=firpmord(fedge,mval,dev,FT);N
b=firpm(N,fpts,mag,wt);
[h,omega]=freqz(b,1,512);
subplot(2,2,1)
plot(omega/(2*pi),20*log10(abs(h)));grid; xlabel('Frequency');ylabel('Gain, dB')
st1=FT/m1; ss=FT/(2*m); fedge=[wp (st1-ss)]; dev=[rp/3 rs];
[N,fpts,mag,wt]=firpmord(fedge,mval,dev,FT);N
b=firpm(N,fpts,mag,wt);
[h,omega]=freqz(b,1,512);
subplot(2,2,2)
plot(omega/(2*pi),20*log10(abs(h)));grid; xlabel('Frequency');ylabel('Gain, dB')
st1=FT/(m1*m2); fedge=[wp (st1-ss)]; FT1=FT/m1;
[N,fpts,mag,wt]=firpmord(fedge,mval,dev,FT1);N
b=firpm(N,fpts,mag,wt);
[h,omega]=freqz(b,1,512);
subplot(2,2,3)
plot(omega/(2*pi),20*log10(abs(h)));grid; xlabel('Frequency');ylabel('Gain, dB')
st1=FT/m; fedge=[wp (st1-ss)]; FT2=FT/(m1*m2);
[N,fpts,mag,wt]=firpmord(fedge,mval,dev,FT2);N
b=firpm(N,fpts,mag,wt);

[h,omega]=freqz(b,1,512);
subplot(2,2,4)
plot(omega/(2*pi),20*log10(abs(h)));grid; xlabel('Frequency');ylabel('Gain, dB')
enter the sampling frequency2048
enter the decimation factor32
enter the first decimation factor4
enter the second decimation factor4
enter the third decimation factor2
enter the passband edge frequency30
enter the stopband edge frequency32
enter the magnitude values[1 0]
enter the passband ripple0.00115
enter the stopband ripple0.0001
N=3946;

N1=17;

N2=32;

N3=269;

50

20
0
-20
Gain, dB

Gain, dB

-50

-40
-60
-80

-100

-100
0

0.05

0.1

0.15

0.2

0.25 0.3
Frequency

0.35

0.4

0.45

-120

0.5

50

50

0
Gain, dB

Gain, dB

-150

-50

-100

-150

0.05

0.1

0.15

0.2

0.25 0.3
Frequency

0.35

0.4

0.45

0.5

0.05

0.1

0.15

0.2

0.25 0.3
Frequency

0.35

0.4

0.45

0.5

-50

-100

0.05

0.1

0.15

0.2

0.25 0.3
Frequency

0.35

0.4

0.45

0.5

-150

Uniform DFT filter banks


clc;clear all;close all;
len= input('Type in the filter length=');
L=input('Type in the value of L=');
l=input('enter the number of frequency sample points');
k=(len-1)/2; n=-k:k; b=sinc(n/L)/L; win=hamming(len); h0=b.*win';

j=sqrt(-1);
for i=1:len
h1(i)=j^(i)*h0(i);
h2(i)=(-1)^i*h0(i);
h3(i)=(-j)^(i)*h0(i);
end
[H0z,w]=freqz(h0,1,l,'whole');
H0=abs(H0z); M0=20*log10(H0);
[H1z,w]=freqz(h1, 1,l,'whole');
H1=abs(H1z); M1=20*log10(H1);
[H2z,w]=freqz(h2, 1, l,'whole');
H2=abs(H2z); M2=20*log10(H2);
[H3z, w]=freqz(h3, 1, l,'whole');
H3=abs(H3z); M3=20*log10(H3);
plot(w/pi, M0, '-k', w/pi, M1, '--k', w/pi, M2, '--k', w/pi, M3, '-k');grid
xlabel('\omega/\pi'); ylabel('Gain, dB')
Type in the filter length= 25
Type in the value of L =4
enter the number of frequency sample points 512

20

Gain, dB

-20

-40

-60

-80

-100

-120

0.2

0.4

0.6

0.8

1.2

1.4

1.6

1.8

You might also like