Professional Documents
Culture Documents
10.10.2020
Software used:
MATLAB
Code:
1.Design a digital Butterworth IIR filter using bilinear transformation to meet the following specification:
Pass band attenuation: 2dB ; Stop band attenuation:35dB ; Sampling rate: 2kHz
(ii)Find the spectrum of input and output signals if the input signal is
disp(order);
disp(num);
1.0e+13 *
1
0 0 0 0 1.1354
disp(denom);
1.0e+13 *
figure(1)
w1=w/(2*pi); %Normalising to frequency scale
plot(w1,20*log10(abs(h)));
title('Analog HPF Filter response');
xlabel('Frequencies(Hz)');
ylabel('H[w] in db');
2
x = cos(2*pi*f1*t/fs)+2*cos(2*pi*f2*t/fs) + 2*sin(2*pi*f3*t/fs); %Input signal
ip_dft=fft(x,N);
y=filter(num_d,denom_d,x);
op_dft=fft(y,N);
figure(3)
%subplot(211)
stem(abs(ip_dft)); %Plotting input spectrum
ylim([0 max(abs(ip_dft))+1]);
xlabel('K');
ylabel('Amplitude');
title('InputSpectrum');
3
figure(4)
%subplot(212)
stem(abs(op_dft)); %Plotting input spectrum
ylim([0 max(abs(ip_dft))+1]);
xlabel('K');
ylabel('Amplitude');
title('OututSpectrum');
4
2.Design a digital Chebyshev IIR filter using bilinear transformation to meet the following specification:
Pass band attenuation: 2dB ; Stop band attenuation:35dB ; Sampling rate: 2kHz
(ii)Find the spectrum of input and output signals if the input signal is
5
disp(order);
disp(num);
1 0 0 0
disp(denom);
1.0e+11 *
figure(1)
w1=w/(2*pi); %Normalising to frequency scale
plot(w1,20*log10(abs(h)));
title('Analog HPF Filter response');
xlabel('Frequencies(Hz)');
ylabel('H[w] in db');
6
[num_d,denom_d]=bilinear(num,denom,fs); %Analog to digital
figure(2)
freqz(num_d,denom_d);
title('Digital HPF Filter response');
figure(3)
%subplot(211)
stem(abs(ip_dft)); %Plotting input spectrum
ylim([0 max(abs(ip_dft))+1]);
xlabel('K');
ylabel('Amplitude');
title('InputSpectrum');
7
figure(4)
%subplot(212)
stem(abs(op_dft)); %Plotting output spectrum
ylim([0 max(abs(ip_dft))+1]);
xlabel('K');
ylabel('Amplitude');
title('OututSpectrum');
8
3.Design a digital Butterworth IIR to meet the following specifications:
Pass band attenuation: 2dB ; Stop band attenuation:35dB ;Sampling rate: 2kHz
(ii)Find the spectrum of input and output signals if the input signal is
9
disp(order);
disp(num);
disp(denom);
figure(1)
freqz(num,denom);
title('Digital LPF Filter response');
10
figure(2)
%subplot(211)
stem(abs(ip_dft)); %Plotting input spectrum
ylim([0 max(abs(ip_dft))+1]);
xlabel('K');
ylabel('Amplitude');
title('InputSpectrum');
figure(3)
%subplot(212)
stem(abs(op_dft)); %Plotting output spectrum
ylim([0 max(abs(ip_dft))+1]);
xlabel('K');
ylabel('Amplitude');
title('OututSpectrum');
11
4.Design a digital Chebyshev IIR to meet the following specifications:
Pass band attenuation: 2dB ; Stop band attenuation:35dB ; Sampling rate: 2kHz
(ii)Find the spectrum of input and output signals if the input signal is
12
disp(order);
disp(num);
disp(denom);
figure(1)
freqz(num,denom);
title('Digital HPF Filter response');
13
figure(2)
%subplot(211)
stem(abs(ip_dft)); %Plotting input spectrum
ylim([0 max(abs(ip_dft))+1]);
xlabel('K');
ylabel('Amplitude');
title('InputSpectrum');
figure(3)
%subplot(212)
stem(abs(op_dft)); %Plotting output spectrum
ylim([0 max(abs(ip_dft))+1]);
xlabel('K');
ylabel('Amplitude');
title('OututSpectrum');
14
5.(i)Design an Analog BandPass IIR filter to meet the following specifications:
Pass band attenuation: 3dB ; Stop band attenuation:20dB ; Find the monotonic frequency response of the
system.
disp(order);
15
The coefficients of numerator polynomial are:
disp(num);
1.0e+15 *
0 0 0 2.2684 0 0 0
disp(denom);
1.0e+22 *
w=0:500000;
[h,W]=freqs(num,denom,w); %Finding the transfer function
%w1=w/(2*pi); %Normalising to frequency scale
figure(1)
plot(w,20*log10(h));
xlim([min(w)-100000 inf]);
title('Analog BPF Filter response');
xlabel('w(rad/sec)');
ylabel('H[w] in db');
16
5.(ii)Design a Digital BandPass IIR filter using impulse invariance method to meet the following specifications:
Pass band attenuation: 3dB ; Stop band attenuation:20dB ; Sampling rate: 100kHz ;Find the monotonic
frequency response of the system.
fs=100000;
wp=[2*pi*50,2*pi*20000];
ws=[2*pi*20,2*pi*45000];
[order,cut_freq]=buttord(wp,ws,3,20,'s'); %Finding order and cutoff frequency
[num,denom]=butter(order,cut_freq,'bandpass','s'); %Finding transfer function coefficients
disp('The order of the filter is');
disp(order);
disp(num);
1.0e+15 *
0 0 0 2.2684 0 0 0
disp(denom);
1.0e+22 *
figure(1)
[num_d,denom_d]=impinvar(num,denom,fs);
freqz(num_d,denom_d);
title('Digital BPF after Impulse invariance');
17
6.(i)Design an Analog Bandstop IIR filter to meet the following specifications:
Pass band attenuation: 3dB ; Stop band attenuation:18dB ;Find the monotonic frequency response of the
system.
disp(order);
18
The coefficients of numerator polynomial are:
disp(num);
1.0e+11 *
disp(denom);
1.0e+11 *
figure(1)
w=0:2500;
[h,W]=freqs(num,denom,w); %Finding the transfer function
plot(w,20*log10(abs(h)));
title('Analog BSF Filter response');
xlabel('w(rad/sec)');
ylabel('H[w] in db');
6.(ii)Design a Digital Bandstop IIR filter using bilinear transformation to meet the following specifications:
19
Pass band upper cut-off frequency: 225 Hz = 1413.72 rad/sec
Pass band attenuation: 3dB ; Stop band attenuation:18dB ;Sampling rate: 500Hz
fs=500;
wp=[2*pi*25,2*pi*225];
ws=[2*pi*100,2*pi*150];
[order,cut_freq]=buttord(wp,ws,3,20,'s'); %Finding order and cutoff frequency
[num,denom]=butter(order,cut_freq,'stop','s'); %Finding transfer function coefficients
disp('The order of the filter is');
disp(order);
disp(num);
1.0e+11 *
disp(denom);
1.0e+11 *
figure(1)
[num_d,denom_d]=bilinear(num,denom,fs);
freqz(num_d,denom_d);
title('Digital BSF after BLT');
20
21