Starting from:

$25

EE3660-Homework 6 Solved

 Program Assignment  
1.     Consider again the inverse DFT given in (8.2).  

X π‘˜π‘›,   𝑛 = 0,1, … , 𝑁 − 1     (8.2)

𝑁

(a)   Replace k by ⟨−π‘˜⟩𝑁 in (8.2) and show that the resulting summation is a DFT expression, that is, IDFT{𝑋[π‘˜]} = 𝑁 1 DFT{𝑋[⟨−π‘˜⟩𝑁]}.

(b)   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.     In this problem we will investigate differences in the speeds of DFT and FFT algorithms when stored twiddle factors are used.

 

(a)   Write a function W = dft_matrix(N) that computes the DFT matrix WN given in (8.8).

(b)   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)   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.     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)   Express sm[k] in terms of sm-1[k] for m = 1, 2, 3.

(b)   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)   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.     Using the flow graph of Figure 8.13 and following the approach used in developing the fftditr2 function.

(a)   Develop a radix-2 DIF-FFT function X = fftdifr2(x) for power-of-2 length N.

(b)   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.     The filterfirdf implements the FIR direct form structure.     

(a)   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)   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.     Consider the IIR normal direct form II structure given in Figure 9.6 and implemented by (9.18) and (9.20).  

 

(a)   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:

                                                                                          1 𝑛𝑒[𝑛], π‘Ž = [1            −] , 𝑏 = 1

x[𝑛] = ( )

4

Compare your results to verify that your filterdf2 function is correctly implemented.

7.     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)  Cascade form with second-order sections in normal direct form I,

(b)  Cascade form with second-order sections in transposed direct form I,

(c)  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.     The frequency-sampling form is developed using (9.50) which uses complex arithmetic.

 

(a)   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)   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                 1             −1.99 + 1.99𝑧−1                    1.964 − 1.964𝑧−1                    −0.96 + 0.96𝑧−1

       π»(𝑧) =   33 [1 − 𝑧−1 + 1 − 1.964𝑧−1 + 𝑧−2 + 1 − 1.857𝑧−1 + 𝑧−2 + 1 − 1.683𝑧−1 + 𝑧−2]              (9.54) 

More products