Description
I Program Assignment (100%)
1. (10%)Consider again the inverse DFT given in (8.2).
X[𝑛] =
1
𝑁
∑ 𝑋[𝑘]𝑊𝑁
−𝑘𝑛
, 𝑛 = 0,1, …
𝑁−1
𝑘=0
, 𝑁 − 1 (8.2)
(a) (5%)Replace k by 〈−𝑘〉𝑁 in (8.2) and show that the resulting summation is a DFT
expression, that is, IDFT{𝑋[𝑘]} =
1
𝑁
DFT{𝑋[〈−𝑘〉𝑁]}.
(b) (5%)Develop a MATLAB function x = IDFT(X,N) using the fft function that uses the
above approach. Verify your function on signal x[n] = {1, 2, 3, 4, 5, 6, 7, 8}.
2. (15%)In this problem we will investigate differences in the speeds of DFT and FFT
algorithms when stored twiddle factors are used.
(a) (5%)Write a function W = dft_matrix(N) that computes the DFT matrix WN given in
(8.8).
(b) (5%)Write a function X = dftdirect_m(x,W) that modifies the dftdirect function using the
matrix W from (a). Using the tic and toc functions compare computation times for the
dftdirect and dftdirect_m function for N = 128, 256, 512, and 1024. For this purpose
generate an N-point complex-valued signal as x = randn(1,N) + 1j*randn(1,N).
(verify your code with fft first)
(c) (5%)Write a function X = fftrecur_m(x,W) that modifies the fftrecur function given on
page 439 using the matrix W from (a). Using the tic and toc functions compare
computation times for the fftrecur and fftrecur_m function for N = 128, 256, 512, and
1024. For this purpose generate an N-point complex valued signal as x = randn(1,N) +
1j*randn(1,N).
(verify your code with fft first)
3. (15%)Consider the flow graph in Figure 8.10 which implements a DIT-FFT algorithm with
both input and output in natural order. Let the nodes at each stage be labeled as sm[k],0 ≤ m
≤ 3 with s0[k] = x[k] and s3[k] = X[k], 0 ≤ k ≤ 7.
(a) (5%)Express sm[k] in terms of sm-1[k] for m = 1, 2, 3.
(b) (5%)Write a MATLAB function X = fftalt8(x) that computes an 8-point DFT using the
equations in part (a). Verify with sequence x[n] = {0,1,2,2,3,3,3,4}.
(c) (5%)Compare the coding complexity of the above function with that of MATLAB
function fftditr2 shown in Figure 8.6, and comment on its usefulness.
4. (10%)Using the flow graph of Figure 8.13 and following the approach used in developing
the fftditr2 function.
(a) (5%)Develop a radix-2 DIF-FFT function X = fftdifr2(x) for power-of-2 length N.
(b) (5%)Verify your function for N = 2v
, where 2 ≤ ν ≤ 10. For this purpose generate an Npoint complex-valued signal as x = randn(1,N) + 1j*randn(1,N).
5. (10%)The filterfirdf implements the FIR direct form structure.
(a) (5%)Develop a new MATLAB function y=filterfirlp(h,x) that implements the FIR
linear-phase form given its impulse response in h. This function should first check if h is
one of type-I through type-IV and then simulate the corresponding equations. If h does
not correspond to one of the four types then the function should display an appropriate
error message.
(b) (5%)Verify your function on each of the following FIR systems:
h1[n] = {1,2,3,2,1},
↑
h2[n] = {1,-2,3,3,-2,1},
↑
h3[n] = {1,-5,0,5,-1},
↑
h4[n] = {1,-3,-4,4,3,-1},
↑
h5[n] = {1,2,3,-2,-1},
↑
For verification determine the first ten samples of the step responses using your function
and compare them with those from the filter function.
6. (10%)Consider the IIR normal direct form II structure given in Figure 9.6 and implemented
by (9.18) and (9.20).
(a) (5%)Using the MATLAB function filterdf1 as a guide, develop a MATLAB function
y=filterdf2(b,a,x) that implements the normal direct form II structure. Assume zero
initial conditions.
(b) (5%)Determine y[n], 0 ≤ n ≤ 500 using your function and filterdf1 function with
following inputs:
x[𝑛] = (
1
4
)
𝑛𝑢[𝑛], 𝑎 = [1 −
3
2
1
2
], 𝑏 = 1
Compare your results to verify that your filterdf2 function is correctly implemented.
7. (20%)The following numerator and denominator arrays in MATLAB represent the system
function of a discrete-time system in direct form:
b = [1,-2.61,2.75,-1.36,0.27], a = [1,-1.05,0.91,-0.8,0.38].
Determine and draw each of the following structures:
(a) (5%)Cascade form with second-order sections in normal direct form I,
(b) (5%)Cascade form with second-order sections in transposed direct form I,
(c) (5%)Cascade form with second-order sections in normal direct form II,
(d) (5%)Cascade form with second-order sections in transposed direct form II.
8. (10%)The frequency-sampling form is developed using (9.50) which uses complex
arithmetic.
(a) (5%)Develop a MATLAB function [G,sos]=firdf2fs(h) that determines frequency
sampling form parameters given in (9.51) and (9.52) given the impulse response in h.
The matrix sos should contain second-order section coefficients in the form similar to
the tf2sos function while G array should contain the respective gains of second-order
sections. Incorporate the coefficients for the H[0] and H[N/2] terms in sos and G arrays.
(b) (5%)Verify your function by input h with sampled frequency response (9.53) and
compare with the system function (9.54) (see example 9.6 in the textbook)
𝐻(𝑧) =
1 − 𝑧
−33
33 [
1
1 − 𝑧
−1 +
−1.99 + 1.99𝑧
−1
1 − 1.964𝑧
−1 + 𝑧
−2 +
1.964 − 1.964𝑧
−1
1 − 1.857𝑧
−1 + 𝑧
−2 +
−0.96 + 0.96𝑧
−1
1 − 1.683𝑧
−1 + 𝑧
−2
] (9.54)