0% found this document useful (0 votes)
78 views23 pages

FinalExam For Zhank

This document contains solutions to 9 problems related to digital signal processing (DSP). Problem 1 involves computing the discrete Fourier transform (DFT) of a 4-point sequence and determining properties like frequency resolution. Problem 2 analyzes a DSP system transfer function, determining stability and filter type. Problem 3 designs a 5-tap bandpass FIR filter. Problem 4 analyzes parameters of an FIR filter designed in MATLAB. Problems 5-7 involve designing IIR and adaptive filters. Problem 8 computes Wiener filter coefficients to minimize a cost function. Problem 9 outlines specifications for sampling rate conversion.

Uploaded by

chamber games
Copyright
© © All Rights Reserved
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)
78 views23 pages

FinalExam For Zhank

This document contains solutions to 9 problems related to digital signal processing (DSP). Problem 1 involves computing the discrete Fourier transform (DFT) of a 4-point sequence and determining properties like frequency resolution. Problem 2 analyzes a DSP system transfer function, determining stability and filter type. Problem 3 designs a 5-tap bandpass FIR filter. Problem 4 analyzes parameters of an FIR filter designed in MATLAB. Problems 5-7 involve designing IIR and adaptive filters. Problem 8 computes Wiener filter coefficients to minimize a cost function. Problem 9 outlines specifications for sampling rate conversion.

Uploaded by

chamber games
Copyright
© © All Rights Reserved
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/ 23

Final Exam

Name: Zhankun Luo

Problem 1
Given the sequence having 4 data points as , and
the sampling period of seconds, no window function is used.

a. Sketch the 4-points fast Fourier transform algorithm (Decimation in frequency FFT) to compute
the DFT coefficients: X(0), X(1), X(2), X(3)

b. Compute the amplitude spectrum

c. Determine the corresponding frequency for the amplitude spectrum .

d. Determine the frequency resolution.

e. Use the DFT formula to determine

(10 points)

solution

Thus

a. Sketch the 4-points fast Fourier transform algorithm (Decimation in frequency FFT) to compute
the DFT coefficients: X(0), X(1), X(2), X(3)

We compute X(k)
b. Compute the amplitude spectrum

The amplitude spectrum to a two-sided amplitude spectrum is

We compute

c. Determine the corresponding frequency for the amplitude spectrum .

For k, the corresponding frequency is

When k = 1, for the amplitude spectrum .

d. Determine the frequency resolution.

The frequency resolution is

e. Use the DFT formula to determine

When k=1
Problem 2
Given the following DSP system with a sampling rate of 8000 Hz

a. Obtain transfer function

b. Make a pole-zero plot and determine the stability.

c. Obtain the frequency response and then the magnitude response

d. Compute the filter gain at the frequency of 0 Hz, 1000 Hz, 2000 Hz, 3000Hz, 4000 Hz,
respectively. Make a plot of the magnitude frequency response.

e. Determine the filter type, that is, the lowpass filter, or high-pass filter, or bandpass filter, or
band-stop filter. (10 points)

solution
a. Obtain transfer function

Do transform to the DSP equation

b. Make a pole-zero plot and determine the stability.

zeros:

poles:

Because all poles:

The DSP system is stable.


c. Obtain the frequency response and then the magnitude response

Then the magnitude response

d. Compute the filter gain at the frequency of 0 Hz, 1000 Hz, 2000 Hz, 3000Hz, 4000 Hz,
respectively. Make a plot of the magnitude frequency response.

So, the filter gain at 0 Hz, 1000 Hz, 2000 Hz, 3000Hz, 4000 Hz are

e. Determine the filter type, that is, the lowpass filter, or high-pass filter, or bandpass filter, or
band-stop filter.

filter type: band-pass


Problem 3
Design a 5-tap bandpass FIR filter whose lower and upper cutoff frequencies are 800 Hz, and
1000, respectively using the Hamming window method.

Assume the sampling frequency is 4000 Hz.

a. List the FIR filter coefficients

b. Determine the transfer function

c. Determine the DSP equation

d. Set up MATLAB routine "freqz()" to obtain the frequency response plot.

(10 points)

solution
a. List the FIR filter coefficients

Here , then

So, we compute

Using the Hamming window method.

Then,

b. Determine the transfer function

c. Determine the DSP equation

d. Set up MATLAB routine "freqz()" to obtain the frequency response plot.

freqz([-0.007484, 0.008413, 0.1, 0.008413, -0.007484], [1], 4096, fs)


% B(z) = [-0.007484, 0.008413, 0.1, 0.008413, -0.007484]
% A(z) = [1]
% 4096 points for plot
% fs: 4000 Hz sampling rate
 
Problem 4
A DSP design engineer used the following MATLAB code to design FIR filter.

fs=8000;
f=[ 0 0.15 0.25  0.4  0.5 1]; % edge frequencies
m=[ 1  1   0    0    1 1]; % ideal magnitudes
w=[  10 15 10 ]; % error weight factors
format long
b=remez(24,f,m,w) % Parks-McClellen algorithm and Remez exchange

(1) Determine the edge frequencies in Hz for passband and stopband

(2) Determine the filter type and number of taps.

(3) Weights for optimization, that Wp and Ws

(5 points)

solution
(1) Determine the edge frequencies in Hz for passband and stopband

passband: 0 - 600Hz and 2000 - 4000 Hz

stopband: 1000 - 1600 Hz

(2) Determine the filter type and number of taps.

filter type: band-stop

number of taps: 24+1=25

(3) Weights for optimization, that Wp and Ws


Problem 5
Design a second-order bandpass IIR digital Butterworth filter with the lower cut-off frequency of
100 Hz and upper cut-off frequency of 120 Hz at a sampling frequency of 1000 Hz using the
bilinear transformation method.

a. Determine the transfer function

b. Make a pole zero plot and determine the stability

c. Set up MATLAB routine "freqz()" to obtain the frequency response plot.

d. Determine difference equation in the direct-form I

e. Draw the realization block diagram using the direct-form II.

(10 points)

solution
a. Determine the transfer function

rad/s, Hz

order of Butterworth: 2 / 2 = 1

The 1st-order Butterworth filter

Then substitute , band-pass filter

Then with BLT, transfer function

b. Make a pole zero plot and determine the stability

poles: 0.7263 -j 0.5950, 0.7263 +j 0.5950

zeros: -1, +1

Because all poles,

The DSP system is stable


c. Set up MATLAB routine "freqz()" to obtain the frequency response plot.

freqz([0.0592, 0, -0.0592], [1, -1.4527, 0.8816], 4096, fs)


% B(z) = [0.0592, 0, -0.0592]
% A(z) = [1, -1.4527, 0.8816]
% 4096 points for plot
% fs: 1000 Hz sampling rate
d. Determine difference equation in the direct-form I

e. Draw the realization block diagram using the direct-form II.

the realization block diagram


Problem 6
For the following adaptive filter used for noise cancellation application,

and an adaptive filter with two taps:

with initial values , and

(a) determine the LMS algorithm equations

(b) perform adaptive filtering for each

(10 points)

solution
(a) Determine the DSP equations using the LMS algorithm

for k= 0, 1; that is, write the equations for all adaptive coefficients:

(b) perform adaptive filtering for each

Python script is below:

from rls.lms import Lms


from rls.rls import Rls
list_x = [-0.5, 1.2, 0.5]
list_d = [-1, 2, 1]
#####################
# LMS adaptive filter
#####################
N, mu, w_0 = 2, 0.1, [0.5, -0.5]
lms = Lms(mu, N, w_0)
list_y, list_e, list_w = [], [], [w_0]
for x, d in list(zip(list_x, list_d)):
   lms.train(x, d)
   list_y.append(lms.y)
   list_e.append(lms.e)
   list_w.append(lms.w)
print(list_y)
print(list_e)
print(list_w)
print('\n')

Then

 
Problem 7
Given a DSP system with a sampling rate set up to be 8,000 samples per second, implement
adaptive filter with 5 taps for system modeling.

Assume that the system as the following input and output:

tow taps:

a. Determine the DSP equations using the RLS algorithm with and .

b. Perform adaptive filtering for n=0, 1, 2.

(10 points)

solution
a. Determine equations using the RLS algorithm. [initialization for ]
b. Repeat (b) using the RLS algorithm with δ=1 and λ=0.96.

Python script is below:

from rls.lms import Lms


from rls.rls import Rls
def convert(L, n):
   if isinstance(L, (float, int)):
       return round(L, n)
   list_new = []
   for elem in L:
       list_new.append(convert(elem, n))
   return list_new

def print_approx(L, n=6):


   L_new = convert(L, n)
   print(L_new)

list_x = [2, -4, 4, -2]


list_d = [1, -1, 0, 1]
#####################
# RLS adaptive filter
#####################
delta, lambda_, N = 1, 0.96, 2
rls = Rls(delta, lambda_, N) # initial w = [0, ..., 0]
list_y, list_e, list_alpha, list_w, = [], [], [], [[0] * N]
for x, d in list(zip(list_x, list_d)):
   rls.train(x, d)
   list_y.append(rls.y)
   list_e.append(rls.e)
   list_alpha.append(rls.alpha)
   list_w.append(rls.w)
   print_approx(rls.Q)
   print_approx(rls.k)
print('\n')
print_approx(list_y)
print_approx(list_e)
print_approx(list_alpha)
print_approx(list_w)
print('\n')

Then

 
Problem 8
The following Wiener filter is used to predict the sinusoid

Assume that where the Wiener filter predictor with


delays of , and is given as

Find the Wiener filter coefficients: , and , and the minimized the cost function of

(15 points)

solution

Here we define

Moreover, for , we conclude that ( are not equal each other)

Because we know that (for )


Thus for , we conclude

Find the Wiener filter coefficients , here if is invertible

Here we have

Finally, we compute with python Sympy library, is

Here is the python script to compute

import sympy as sym


from sympy import cos, sin
n1, n2, n3, omega1, omega2 = sym.symbols('n_1, n_2, n_3, Omega_1, Omega_2')
R = sym.Matrix([[1, 0.5*cos((n1-n2)*omega1) + 0.5*cos((n1-n2)*omega2)],
              [0.5*cos((n1-n2)*omega1) + 0.5*cos((n1-n2)*omega2), 1]])
P = sym.Matrix([[0.5*cos(n1*omega1) + 0.5*cos(n1*omega2)],
              [0.5*cos(n2*omega1) + 0.5*cos(n2*omega2)]])
det = R.det()
sym.trigsimp(sym.cancel(det)) # simplity det(R)
eigen = R.eigenvals()
sym.trigsimp(sym.cancel(eigen)) # find eigen value of R
w = R.inv()* P   # find Wiener filter w_*
w = sym.trigsimp(sym.cancel(w)) # simplifty w_*
sym.cancel(w)
J_min = -P.transpose() * w + sig_sq # find J_min
J_min_simplify = sym.cancel(sym.trigsimp(J_min))
print(sym.latex(J_min_simplify))

As we can see, the minimized the cost function of is a very complex and
long expression

Actually, we need 4th-order difference equation to describe the ,

2nd-order is not enough


Problem 9
For the sampling conversion from 7 kHz to 3 kHz with the following specifications:

Passband frequency range = 0 – 500 Hz


Passband ripple = 0.02 dB
Stopband attenuation = 46 dB,

a. draw the block diagram for the interpolator;

b. determine the window type, filter length, and cutoff frequency if the window method is used
for the combined FIR filter H(z).

(10 points)

solution
a. draw the block diagram for the interpolator;

b. determine the window type, filter length, and cutoff frequency if the window method is used
for the combined FIR filter H(z).

For interpolation filter:

For Anti-aliasing filter:

Because 3 kHz < 4 kHz, we choose kHz

From table, Passband ripple<0.02 dB Stopband attenuation>46 dB,

window type: Hamming

select the closest odd number

cutoff frequency
 
Problem 10
For the design of a two-stage decimator (M1xM2=5x3) with the following specifications:

Original sampling rate = 15 kHz


Frequency of interest = 0 - 250 Hz
Passband ripple = 0.05 (absolute)
Stopband attenuation = 0.005 (absolute)
Final sampling rate = 1,000 Hz,

a. Draw the decimation block diagram;

b. Specify the sampling rate for each stage;

c. determine the window type, filter length, and cutoff frequency for each stage if the window
method is used for anti-aliasing FIR filter design

(10 points)

solution
a. Draw the decimation block diagram;

b. Specify the sampling rate for each stage;

Here we select the sampling rate for stage 1

the sampling rate for stage 2.

c.

A. determine the window type, filter length, and cutoff frequency for the first stage H1(z);

From table, Passband ripple<0.05 dB Stopband attenuation>46.02 dB,

window type: Hamming

filter length,

select the closest odd number


cutoff frequency

B. determine the window type, filter length, and cutoff frequency for the second stage H2(z)

From table, Passband ripple<0.05 dB Stopband attenuation>46.02 dB,

window type: Hamming

filter length,

select the closest odd number

cutoff frequency
 

You might also like