0% found this document useful (0 votes)
149 views14 pages

(EE3101) Laboratory 2 Report

This document is an engineering student's laboratory report on digital signal processing. It includes 6 questions analyzing properties of analog and digital filters. Question 1 examines the poles of an analog filter and determines it is stable. Question 2 plots the magnitude response of the analog filter. Question 3 compares digital filters designed using different sampling periods. Question 4-5 compare filters designed using impulse invariance and bilinear transformation methods. Question 6 designs Butterworth filters and Question 7 compares matched-Z and frequency transformation methods. Graphs and equations in the report provide details on the filters and comparisons.

Uploaded by

94747
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
149 views14 pages

(EE3101) Laboratory 2 Report

This document is an engineering student's laboratory report on digital signal processing. It includes 6 questions analyzing properties of analog and digital filters. Question 1 examines the poles of an analog filter and determines it is stable. Question 2 plots the magnitude response of the analog filter. Question 3 compares digital filters designed using different sampling periods. Question 4-5 compare filters designed using impulse invariance and bilinear transformation methods. Question 6 designs Butterworth filters and Question 7 compares matched-Z and frequency transformation methods. Graphs and equations in the report provide details on the filters and comparisons.

Uploaded by

94747
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

EE3101 Digital Signal Processing Laboratory Report Ang Zhi Ping U066463H

EE3101 Laboratory 2: IIR Digital Filter Design Name: Matric No.: Date: Q1.
H a (s) = 1 1 + 2.6130 s + 3.4140 s 2 + 2.6130 s 3 + s 4

Ang Zhi Ping U066463H 12th November 2008

The commands executed are:


>> analog_pole = roots([1 2.6130 3.4140 2.6130 1]) analog_pole = -0.3826 -0.3826 -0.9239 -0.9239 + + 0.9239i 0.9239i 0.3827i 0.3827i

Since the real part of all poles of Ha(s) is negative (-0.3826 and -0.9239), all poles of the filter lies in the open left half plane. This implies that the analog filter is stable. Q2. The commands executed are:
>> [H,w] = freqs([1],[1 2.6130 3.4140 2.6130 1]); >> plot(w,20*log10(abs(H)),'k'),title('Magnitude Response of H_a(s)'),xlabel('Frequency (rad s^-^1)'),ylabel('Magnitude (dB)'),xlim([0 10]),ylim([-80 10]),grid on,hold; >> plot([0:10],-3*ones(length([0:10])),'--k'); >> plot([1 1],[-80,10],'--k');

Refer to Graph A. The filter is a low pass filter with 3 dB cutoff frequency at 1 rad/s. It has unity DC gain. Q3. The script below is executed for different values of T (0.05, 0.25, 0.45):
% % % EE2001 Laboratory 2 Question 3 Ang Zhi Ping U066463H % Sampling period % Substitution factor % Substitution of a linear factor is computed as

T = 0.05; a = [1/T -1/T];

EE3101 Digital Signal Processing Laboratory Report Ang Zhi Ping U066463H % repeated convolutions b0 = [1]; % 1 b1 = conv(b0,a); % s b2 = conv(b1,a); % s^2 b3 = conv(b2,a); % s^3 b4 = conv(b3,a); % s^4 b0(length(b4)) = 0; % Pad coefficients to fit the longest vector b4 b1(length(b4)) = 0; b2(length(b4)) = 0; b3(length(b4)) = 0; B = [1]; A = 1*b0 + 2.6130*b1 + 3.4140*b2 + 2.6130*b3 + 1*b4; [H,w] = freqz(B,A,8192); plot(w,20*log10(abs(H))),title('Frequency Response for IIR Filter Using Derivative Approximation Method for T=0.05'),xlim([0 pi]),xlabel('Frequency (rad/sample)'),ylabel('Magnitude (dB)'),grid on;

Refer to Graph B. Q4. The script which is executed is:


% % % EE3101 Laboratory 2 Question 4 Ang Zhi Ping U066463H

% The MATLAB function impinvar() is used which uses the impulse % invariance method to perform analog to digital filter conversion analog_b = [1]; analog_a = [1 2.6130 3.4140 2.6130 1]; % T=0.05 [bz1,az1] = impinvar(analog_b,analog_a,1/0.05); % T=0.25 [bz2,az2] = impinvar(analog_b,analog_a,1/0.25); % T=0.45 [bz3,az3] = impinvar(analog_b,analog_a,1/0.45); % Computing digital frequency response [h1,w1] = freqz(bz1,az1,8192); [h2,w2] = freqz(bz2,az2,8192); [h3,w3] = freqz(bz3,az3,8192); % Plotting all magnitude responses on the same graph subplot(3,1,1),plot(w1,20*log10(abs(h1))),title('Magnitude Response of H(z) Using Impulse Invariance Method (T=0.05)'),xlabel('Frequency (rad/sample)'),ylabel('Magnitude (dB)'),xlim([0 pi]),ylim([-140 10]),grid; subplot(3,1,2),plot(w2,20*log10(abs(h2))),title('Magnitude Response of H(z) Using Impulse Invariance Method (T=0.25)'),xlabel('Frequency (rad/sample)'),ylabel('Magnitude (dB)'),xlim([0 pi]),ylim([-100 10]),grid; subplot(3,1,3),plot(w3,20*log10(abs(h3))),title('Magnitude Response of H(z) Using Impulse Invariance Method (T=0.45)'),xlabel('Frequency

EE3101 Digital Signal Processing Laboratory Report Ang Zhi Ping U066463H (rad/sample)'),ylabel('Magnitude (dB)'),xlim([0 pi]),ylim([-80 10]),grid;

Refer to Graph C. Q5. The script which is executed is:


% % % EE3101 Laboratory 2 Question 5 Ang Zhi Ping U066463H

% The MATLAB function bilinear() is used which uses the bilinear % transformation to perform analog to digital filter conversion analog_b = [1]; analog_a = [1 2.6130 3.4140 2.6130 1]; % T=0.05 [bz1,az1] = bilinear(analog_b,analog_a,1/0.05); % T=0.25 [bz2,az2] = bilinear(analog_b,analog_a,1/0.25); % T=0.45 [bz3,az3] = bilinear(analog_b,analog_a,1/0.45); % Computing digital frequency response [h1,w1] = freqz(bz1,az1,8192); [h2,w2] = freqz(bz2,az2,8192); [h3,w3] = freqz(bz3,az3,8192); % Plotting all magnitude responses on the same graph subplot(3,1,1),plot(w1,20*log10(abs(h1))),title('Magnitude Response of H(z) Using Bilinear Transformation Method (T=0.05)'),xlabel('Frequency (rad/sample)'),ylabel('Magnitude (dB)'),xlim([0 pi]),ylim([-300 10]),grid; subplot(3,1,2),plot(w2,20*log10(abs(h2))),title('Magnitude Response of H(z) Using Bilinear Transformation Method (T=0.25)'),xlabel('Frequency (rad/sample)'),ylabel('Magnitude (dB)'),xlim([0 pi]),ylim([-300 10]),grid; subplot(3,1,3),plot(w3,20*log10(abs(h3))),title('Magnitude Response of H(z) Using Bilinear Transformation Method (T=0.45)'),xlabel('Frequency (rad/sample)'),ylabel('Magnitude (dB)'),xlim([0 pi]),ylim([-300 10]),grid;

Refer to Graph D. When T increases, the 3 dB cutoff digital frequency shifts to the right. The frequency correspondence between the analog and digital frequency is given by the relation =2 tan1 (T/2). Given that T is small, which can be assumed from the cases of T = 0.05, 0.25 and 0.45, approximates to T. Since is 1 rad/s at the cutoff frequency, the analog cutoff frequency of 1 rad/s will be mapped to 0.05 rad, 0.25 rad and 0.45 rad respectively for different T values, hence the shift in the 3 dB cutoff digital frequency.

EE3101 Digital Signal Processing Laboratory Report Ang Zhi Ping U066463H

Zooming in to see the 3 dB cutoff frequency, the T = 0.05 filter has a 3 dB cutoff at exactly 0.05 rad (given = 1 rad/s). For T = 0.25, the 3 dB cutoff has shifted leftwards to 0.248 rad instead of 0.25 rad, and for T = 0.45, the 3 dB cutoff has shifted further to 0.442 rad instead of 0.45 rad. This is a result of the non-linear mapping of the analog frequency axis to the digital frequency unit circle. As the mapping function from analog to digital frequency is given by the arctangent function, the mapping is approximately linear for small values of T but large analog frequencies will be mapped to smaller-than-expected values of digital frequencies if the linear property is used as an estimate. Refer to Graph E for the nonlinear frequency mapping observation. Q6. The standard form of third order Butterworth filters is:
H a ( s) = 1 (1 + s )(1 + s + s 2 )

Given 1,c = 0.1 rad/s and 2,c = 0.2 rad/s, the required transformed Butterworth filters are:

H 1,a ( s ) =

1 (1 + 10s)(1 + 10s + 100s 2 ) 1 H 2,a ( s ) = (1 + 5s )(1 + 5s + 25s 2 )

The following script is executed:


% % % EE3101 Laboratory 2 Question 6 Ang Zhi Ping U066463H

[h1,w1]=freqs([1],conv([100 10 1],[10 1])); [h2,w2]=freqs([1],conv([25 5 1],[5 1])); % Plotting magnitude response of Butterworth filter subplot(2,1,1),plot(w1,20*log10(abs(h1))),title('Magnitude Response of Butterworth Filter (N=3,\Omega_c=0.1 rad s^-^1)'),xlabel('Frequency (rad s^-^1)'),ylabel('Magnitude (dB)'),xlim([0 1]),ylim([-70 10]),grid on; subplot(2,1,2),plot(w2,20*log10(abs(h2))),title('Magnitude Response of Butterworth Filter (N=3,\Omega_c=0.2 rad s^-^1)'),xlabel('Frequency (rad s^-^1)'),ylabel('Magnitude (dB)'),xlim([0 1]),ylim([-70 10]),grid on;

Refer to Graph F.

EE3101 Digital Signal Processing Laboratory Report Ang Zhi Ping U066463H

Q7. For frequency transformation method, the transformation equation is:


k 1 2k 1 cos 2 Z + Z 2 = k +1 k +1 , = 2k 1 k 1 2 Z + Z 1 cos 2 k +1 k +1 + 1 2 , k = cot 2 1 tan 1 2 2 2

z 1

The following script is executed for both matched-Z and frequency transformation methods:
% % % EE3101 Laboratory 2 Question 7 Ang Zhi Ping U066463H

analog_b1 = [1]; analog_a1 = conv([100 10 1],[10 1]); analog_b2 = [1]; analog_a2 = conv([25 5 1],[5 1]); % The MATLAB function c2d() is used which converts an analog filter to % discrete filter using the 'matched' option which does the matched-Z % transformation sys1 = tf(analog_b1,analog_a1); sys2 = tf(analog_b2,analog_a2); % Perform matched-Z transformation using T=1 sysd1 = c2d(sys1,1,'matched'); sysd2 = c2d(sys2,1,'matched'); % Extracting digital coefficients num1 = get(sysd1,'num'); den1 = get(sysd1,'den'); num2 = get(sysd2,'num'); den2 = get(sysd2,'den'); b1 a1 b2 a2 = = = = num1{1}; den1{1}; num2{1}; den2{1};

% Calculating frequency response of matched-Z transformed filters [h1,w1] = freqz(b1,a1,8192); [h2,w2] = freqz(b2,a2,8192); % Plotting magnitude response of matched-Z transformed filters figure(1),subplot(2,1,1),plot(w1,20*log10(abs(h1))),title('Magnitude Response of Matched-Z Transformed Butterworth Filter (N=3,\Omega_c=0.1 rad s^-^1)'),xlabel('Frequency (rad/sample)'),ylabel('Magnitude (dB)'),xlim([0 pi]),ylim([-200 10]),grid; subplot(2,1,2),plot(w2,20*log10(abs(h2))),title('Magnitude Response of Matched-Z Transformed Butterworth Filter (N=3,\Omega_c=0.2 rad s^^1)'),xlabel('Frequency (rad/sample)'),ylabel('Magnitude (dB)'),xlim([0 pi]),ylim([-200 10]),grid;

EE3101 Digital Signal Processing Laboratory Report Ang Zhi Ping U066463H

% The MATLAB function iirlp2bp() is used to perform lowpass to bandpass % frequency transformation [b3,a3] = iirlp2bp(b1,a1,0.1/pi,[0.1 0.2]); [b4,a4] = iirlp2bp(b2,a2,0.2/pi,[0.1 0.2]); % Calculating frequency response of frequency transformed bandpass % filters [h3,w3] = freqz(b3,a3,8192); [h4,w4] = freqz(b4,a4,8192); % Plotting magnitude response of frequency transformed bandpass filters figure(2),subplot(2,1,1),plot(w3,20*log10(abs(h3))),title('Magnitude Response of Frequency Transformed Butterworth Filter (N=3,\Omega_c=0.1 rad s^-^1,\phi_1=0.1\pi rad,\phi_2=0.2\pi rad)'),xlabel('Frequency (rad/sample)'),ylabel('Magnitude (dB)'),xlim([0 pi]),ylim([-200 10]),grid; subplot(2,1,2),plot(w4,20*log10(abs(h4))),title('Magnitude Response of Frequency Transformed Butterworth Filter (N=3,\Omega_c=0.2 rad s^^1,\phi_1=0.1\pi rad,\phi_2=0.2\pi rad)'),xlabel('Frequency (rad/sample)'),ylabel('Magnitude (dB)'),xlim([0 pi]),ylim([-200 10]),grid;

Refer to Graph G (matched-Z transformation) and Graph H (frequency transformation).

Graph A
10

Magnitude Response of Ha(s)

-10

-20

Magnitude (dB)

-30

-40

-50

-60

-70

-80

4
7

5 Frequency (rad s )
-1

10

Graph B
0 Magnitude (dB)

Frequency Response for IIR Filter Using Derivative Approximation Method for T=0.05

-50

-100

-150

0.5

1.5 2 2.5 Frequency (rad/sample) Frequency Response for IIR Filter Using Derivative Approximation Method for T=0.25

0 Magnitude (dB) -20 -40 -60 -80

0.5

1.5 2 2.5 Frequency (rad/sample) Frequency Response for IIR Filter Using Derivative Approximation Method for T=0.45

0 Magnitude (dB)

-20

-40

-60

0.5

1.5 Frequency (rad/sample)


8

2.5

Graph C
0 Magnitude (dB)

Magnitude Response of H(z) Using Impulse Invariance Method (T=0.05)

-50

-100

0.5

1.5 2 Frequency (rad/sample) Magnitude Response of H(z) Using Impulse Invariance Method (T=0.25)

2.5

0 Magnitude (dB) -20 -40 -60 -80 -100 0 0.5 1.5 2 Frequency (rad/sample) Magnitude Response of H(z) Using Impulse Invariance Method (T=0.45) 1 2.5 3

0 Magnitude (dB) -20 -40 -60 -80 0 0.5 1 1.5 Frequency (rad/sample)
9

2.5

Graph D
0 Magnitude (dB)

Magnitude Response of H(z) Using Bilinear Transformation Method (T=0.05)

-100

-200

-300

0.5

1.5 2 2.5 Frequency (rad/sample) Magnitude Response of H(z) Using Bilinear Transformation Method (T=0.25)

0 Magnitude (dB)

-100

-200

-300

0.5

1.5 2 2.5 Frequency (rad/sample) Magnitude Response of H(z) Using Bilinear Transformation Method (T=0.45)

0 Magnitude (dB)

-100

-200

-300

0.5

1.5 Frequency (rad/sample)


10

2.5

Graph E
-2 Magnitude (dB) -2.5 -3 -3.5 -4 0.04

Magnitude Response of H(z) Using Bilinear Transformation Method (T=0.05)

0.05 0.055 Frequency (rad/sample) Magnitude Response of H(z) Using Bilinear Transformation Method (T=0.25)

0.045

0.06

-2 Magnitude (dB) -2.5 -3 -3.5 -4 0.24 0.25 0.255 Frequency (rad/sample) Magnitude Response of H(z) Using Bilinear Transformation Method (T=0.45) 0.245 0.26

-2.5 Magnitude (dB) -3 -3.5 -4 -4.5 0.44 0.445 0.45 Frequency (rad/sample)
11

0.455

0.46

Graph F
10 0 -10 Magnitude (dB) -20 -30 -40 -50 -60 -70 0 0.1 0.2

Magnitude Response of Butterworth Filter (N=3,c=0.1 rad s )

-1

0.3

0.4

0.5 Frequency (rad s )


-1

0.6

0.7

0.8

0.9

Magnitude Response of Butterworth Filter (N=3,c=0.2 rad s-1) 10 0 -10 Magnitude (dB) -20 -30 -40 -50 -60 -70 0 0.1 0.2 0.3 0.4
12

0.5 Frequency (rad s )


-1

0.6

0.7

0.8

0.9

Graph G
0

Magnitude Response of Matched-Z Transformed Butterworth Filter (N=3,c=0.1 rad s )

-1

-50 Magnitude (dB)

-100

-150

-200

0.5

1.5 Frequency (rad/sample)

2.5

Magnitude Response of Matched-Z Transformed Butterworth Filter (N=3,c=0.2 rad s-1) 0

-50 Magnitude (dB)

-100

-150

-200

0.5

1.5 Frequency (rad/sample)


13

2.5

Graph H
0

Magnitude Response of Frequency Transformed Butterworth Filter (N=3,c=0.1 rad s ,1=0.1 rad,2=0.2 rad)

-1

-50 Magnitude (dB)

-100

-150

-200

0.5

1.5 Frequency (rad/sample)

2.5

Magnitude Response of Frequency Transformed Butterworth Filter (N=3,c=0.2 rad s-1,1=0.1 rad,2=0.2 rad) 0

-50 Magnitude (dB)

-100

-150

-200

0.5

1.5 Frequency (rad/sample)


14

2.5

You might also like