You are on page 1of 4

DSP Project 4

1. Design an IIR digital filter in Matlab with the parameters specified in the table below using the indirect
design method shown in the table.

a) Determine (if applicable) the order and cut-off frequency of the analog filter.

b) Determine the transfer functions of the analog filter ) H (sa) and digital filter H(z) .
Fs=16000;
N=6;
n=N/2;
Rs=40;
Fc=[3200 6400];
wt=2*pi*Fc/Fs;
Wt=wt*Fs;

[bs,as] = cheby2(n,Rs,Wt,'s')
[bd, ad] = impinvar(bs,as,Fs)

bd = 0.0377 0.0383 0.0494 0.0335 0.0488 -0.0090 0


ad = 1.0000 1.0516 2.5391 1.6097 1.9286 0.6025 0.4284

bs = 1.0e+20 * 0 0.0000 0.0000 0.0000 0.0000 3.9432 0

as = 1.0e+26 * 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 5.2853

c) Graphically plot the frequency response and zeros and poles diagram for the analog filter.
figure(1), freqs(bs,as)
figure(2), zplane(bs,as)
d) Graphically plot the frequency response and zeros and poles diagram for the designed digital filter.
figure(3), freqz(bd,ad)
figure(4), zplane(bd,ad)

e) Graphically plot the amplitude [dB] - frequency [Hz] characteristics of the designed digital filter,
determine the gain of the filter at the cutting frequencies in the table (zoom in and measure using
cursors) and verify the required design conditions.

[h]=impz(bd,ad,512,Fs);
H=fft(h,512);
f = -Fs/2: Fs/512 :Fs/2-Fs/512;
figure(5)
plot(f,20*log10(fftshift(abs(H))))
title( 'Aplitude Frequency characteristic')
xlabel('Frequency[Hz]')
ylabel('Amplitude[dB]');
2. Design the digital filter at point 1 using the direct design method of IIR filters in Matlab. Repeat the
requirements of paragraphs d) and e) for the filter designed by the direct method.

Wt = [3200*2/Fs 6400*2/Fs];
[bd2,ad2] = cheby2(n,Rs,Wt);

figure(6), freqz(bd2,ad2)
figure(7), zplane(bd2,ad2)

[h]=impz(bd2,ad2,512,Fs);
H=fft(h,512);
f = -Fs/2: Fs/512 :Fs/2-Fs/512;
figure(8)
plot(f,20*log10(fftshift(abs(H))))
title( 'Aplitude Frequency characteristic')
xlabel('Frequency[Hz]')
ylabel('Amplitude[dB]')
3. Apply at the input of the designed filter at point 2 (direct design method) a sinusoidal signal of
variable frequency between 0 Hz and FS/2 generated by the Matlab function chirp. The length of the
generated signal is 1 second. Represent the signals from the input and output of the filter. Represent the
spectrogram of signals from the input and output of the filter.

t= 0:1/Fs:1;
x = chirp(t,0,1,Fs/2);
y = filter(bd2,ad2,x);
figure(9)
subplot(2,1,1), stem(t,x), grid, title('x[t]')
subplot(2,1,2), stem(t,y), grid, title('y[t]')

figure(10), spectrogram(x, 512,256,512,Fs,'yaxis'), colormap(jet), title('Spectrogram of the input signal')


figure(11), spectrogram(y, 512,256,512,Fs,'yaxis'), colormap(jet), title('Spectrogram of the output signal')

You might also like