You are on page 1of 5

MATLAB 1

Lab 4: Z-transfer Functions, Difference Equations, and Filter Implementation

Part A: FIR Filters

1. An FIR system is given below:


Numerator coefficients: 𝑏𝑏 = [0.2 0.3 0.2]
a. [5] Determine its transfer function 𝐻𝐻(𝑧𝑧) =
b. [5] Determine its difference equation 𝑦𝑦(𝑛𝑛) =
c. [5] Given sampled values: sample=[1:1:10], write a MATLAB program to perform the digital
filtering.
d. [5] Using the standard MATLAB routine “filter()”, verify ‘c’.

2. Two FIR system coefficients are given below, respectively,

FIR system 1:
bLP =[
-0.0012 -0.0025 -0.0045 -0.0068 -0.0073 -0.0030 0.0089 …
0.0297 0.0583 0.0907 0.1208 0.1422 0.1500 0.1422 …
0.1208 0.0907 0.0583 0.0297 0.0089 -0.0030 -0.0073 …
-0.0068 -0.0045 -0.0025 -0.0012]

FIR system 2:
bBP =[
0.0004 -0.0017 -0.0064 -0.0076 0.0073 0.0363 0.0458 …
0.0000 -0.0802 -0.1134 -0.0419 0.0860 0.1500 0.0860 …
-0.0419 -0.1134 -0.0802 0.0000 0.0458 0.0363 0.0073 …
-0.0076 -0.0064 -0.0017 0.0004]

a. Determine the transfer function using z-transform for the first FIR system.
b. Determine the difference equation for the first FIR system.
Plot the frequency responses using the MATLAB function freqz() for the z-transfer functions.
Label and print your graph.
c. Perform the same operations as (b) for the second FIR system.
MATLAB 2

d. Generate the sum of sinusoids for duration of 1 second:


x(t ) = 5cos(2π (500)t ) + 5cos(2π (1200)t + 0.25π ) + 5cos(2π (1800)t + 0.5π ) with fs=8 kHz.

e. Write MATLAB programs using the MATLAB function filter() according to the two given FIR
systems.
① Perform digital filtering using each of the developed programs, plot the input signal spectrum
and the output signal spectrum using the frequency resolution of 1 Hz, respectively. Print and
label the spectrum.
a) What frequency components/component (frequency locations of the spectral peak(s)) are/is
shown in the output signal spectrum?
② Listen to and compare the input signal and output signal from each filter, respectively.
③ Discuss the obtained results.

f. Use speech data (we.dat) with a sampling of 8000 Hz,


① Perform digital filtering using each of the developed filter programs, and calculate and plot the
input signal spectrum and the output spectrum with a frequency resolution of 4 Hz, respectively.
Print and label each spectrum.
② Listen to and compare the input signal and output signal from each filter, respectively.
③ Discuss the obtained results.
MATLAB 3

Part B: IIR Filters

1. An IIR system is given below


Numerator coefficients: b=[0.5 0.5]
Denominator coefficients: a=[1 –0.25];
a. [5] Determine its transfer function H(z)=
b. [5] Determine its difference equation y(n)=
c. [10] Given sampled values: sample=[1:1:10], write a MATLAB program to perform the digital
filtering. Using the standard MATLAB routine “filter()”, very the result of (b).

2. Two IIR filter coefficients are given below, respectively,


IIR system 1:
Numerator coefficients: bBP = [0.0201 0.0000 -0.0402 0.0000 0.0201]
Denominator coefficients: aBP = [1.0000 -2.1192 2.6952 -1.6924 0.6414]

IIR system 2:
Numerator coefficients: bHP =[ 0.0938 -0.3753 0.5630 -0.3753 0.0938 ]
Denominator coefficients: aHP =[ 1.0000 0.0784 0.8267 0.2597 0.1960 ]

a. [5] Determine the transfer function using z-transform for the IIR system 1 and 2.
b. [10] Determine the difference equation for the IIR system 1 and 2.
Plot the frequency responses using the MATLAB function freqz() for each of z-transfer function.
c. Generate the sum of sinusoids for the duration of 1 second:
x(t ) = 5cos(2π (500)t ) + 5cos(2π (1200)t + 0.25π ) + 5cos(2π (1800)t + 0.5π ) using fs = 8 kHz.

d. Write MATLAB programs using the MATLAB function filter() according to two IIR systems.
① Perform digital filtering using each of the developed programs, and plot the input signal
spectrum and the output signal spectrum using the frequency resolution of 1 Hz, respectively.
Print and label spectrum.
② Listen to and compare the input signal and output signal from each filter, respectively.
③ Discuss the obtained results.
④ What frequency components/component (frequency locations of the spectral peak(s)) are/is
shown in the output spectrum?

e. Use speech data ‘we.dat’ with a sampling rate of 8000 Hz.


MATLAB 4

① Perform digital filtering using each of the developed programs, and calculate and plot the input
signal spectrum and the output spectrum with a frequency resolution of 4 Hz, respectively. Print
and label the spectrum.
② Listen to and compare the input signal and output signal from each filter, respectively. Discuss
the obtained results.
MATLAB 5

Part C: Spectral Estimation Using Window Functions


Consider three sinusoids with the following amplitudes and phases:
𝑥𝑥1 (𝑡𝑡) = 5 cos(1000𝜋𝜋𝜋𝜋) ; 𝑥𝑥2 (𝑡𝑡) = 5 cos(2400𝜋𝜋𝜋𝜋 + 0.25𝜋𝜋) ; 𝑥𝑥3 (𝑡𝑡) = 5 cos(3600𝜋𝜋𝜋𝜋 + 0.5𝜋𝜋).
1. Generate the sum of the sinusoids for 240 samples using a sampling rate of 8,000 Hz. Write a
MATLAB program to compute and plot the amplitude spectrum of the signal 𝑥𝑥(𝑛𝑛) with the FFT
using each of the following window functions:
a. Rectangular window;
b. Triangular window;
c. Hamming window.
2. Examine the effect of spectral leakage for each window use in 1.

You might also like