EE3660 Homework #2 Solved

35.00 $

Category:

Description

5/5 - (4 votes)

  1. Let 𝑥[𝑛] = ℎ[𝑛] = (0.9)𝑛𝑢[𝑛] and 𝑦[𝑛] = 𝑥[𝑛] ∗ ℎ[𝑛]
    • Determine 𝑦[𝑛] analytically and plot the first 99 non-zero samples using the stem
    • Take first 50 samples of 𝑥[𝑛] and ℎ[𝑛]. Compute and plot 𝑦[𝑛] using the conv
    • Using the filter function, determine and plot the first 99 samples of 𝑦[𝑛].
    • Which of the outputs in (b) and (c) come close to that in (a)? Explain.

 

  1. The sum 𝐴𝑥 ≜ ∑𝑛 𝑥[𝑛] can be thought of as a measure of the “area” under a sequence x[n].
    • Starting with the convolution sum (2.36), show that 𝐴𝑦 = 𝐴𝑥𝐴 (derive in the live script).
    • Given the sequences x=sin(2*pi*0.01*(0:100)) + 0.05*randn(1,101); h=ones(1,5);

compute y[n] = h[n] ∗ x[n], check whether 𝐴𝑦 = 𝐴𝑥𝐴, and use the subplot function plot x[n] and y[n] on the same graph.

  • Normalize h[n] so that 𝐴= 1 and repeat part (b).
  • If 𝐴= 1, then 𝐴𝑦 = 𝐴𝑥. Use this result to explain the difference between the plots obtained in parts (b) and (c).

 

  1.  The response of a LTI system to the input 𝑥[𝑛] = 𝑢[𝑛] is 𝑦.
    • Find the impulse response ℎ[𝑛] of the system, and check the results using the function filter.
    • Plot the pole-zero pattern using the function zplane(b, a).
    • Compute and plot the impulse response using the functions filter and stem. Compare with the plot obtained using the function impz.
    • Use the function residuez and the z-transform pairs in Table 3.1 to find an analytical expression for the impulse response h[n].

 

  1. Find the impulse response of the system (3.97) for the case of real and equal poles and use the result to determine how the location of the poles affects (a) the stability of the system, and (b) the shape of the impulse response. (Hint: Use MATLAB to replicate Figure 3.10 for a double pole, find C and discuss stability of the three cases |𝑎1| < 𝐶, |𝑎1| = 𝐶, |𝑎1| > 𝐶)

 

  1. ( Consider the following LCCDE:

𝑦[𝑛] = 2𝑐𝑜𝑠(𝜔0)𝑦[𝑛 − 1] − 𝑦[𝑛 − 2],

with no input but with initial conditions 𝑦[−1] = 0 and 𝑦[−2] = −𝐴𝑠𝑖𝑛(𝜔0).

  • Show that the solution of the above LCCDE is given by the sequence

𝑦[𝑛] = 𝐴 ⋅ 𝑠𝑖𝑛[(𝑛 + 1)𝜔0] ⋅ 𝑢[𝑛].

This system is known as a digital oscillator (derive in the live script).

  • For 𝐴 = 2 and 𝜔0 = 0.1𝜋, verify the operation of the above digital oscillator using the filtic and the filter (Hint: Check one-sided z-transform in supplement)

 

  1.  In this problem we illustrate the numerical evaluation of DTFS using MATLAB.
    • Write a function c=dtfs0(x) which computes the DTFS coefficients (4.67) of a periodic signal and verify the result with dtfs
    • Write a function x=idtfs0(c) which computes the inverse DTFS (4.63) and verify the result with idtfs
  2.  Determine and plot the magnitude and phase spectra of the following periodic sequences:

(b) x2[n] = {1, 1, 0, 1, 1, 1, 0, 1}, (one period)

(one period)

  1.  Consider a noncausal finite length sequence x[n] = δ[n + 1] + δ[n] + δ[n − 1], we can compute the DTFT in MATLAB using following scripts:

x=[1 1 1]; % n=-1,0,1 om=linspace(-pi, pi, 60); X1=dtft12(x, -1, om); X2=freqz(x, 1, om);

  • Use subplot to plot the magnitude |X1|, |X2| and phase ∠X1, ∠X2 in one graph respectively.
  • Is the magnitude |X1| = |X2| ? Is the phase ∠X1 = ∠X2 ? If not, Explain.
  1.  In this problem use the image file “DSP.png” which has 100×300 pixels (unsigned 8 bits per pixel). You can use the following MATLAB script to load, show and store the image files:

img = imread(‘DSP.png’); imshow(img); imwrite(img, ‘DSP0.png’);

(a) Consider the 5×5 impulse response h[m, n] given as follow:

𝑚, 𝑛 ≤ 2

,

  • , 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒

filter the “DSP.png” using (2.78) and display the resulting image, comment on the result. (Hint:

You can directly use conv2 function, and make sure the data format is double before filtering). (b) Repeat part (a) and try two different kernels ℎ1[𝑚, 𝑛] and ℎ2[𝑚, 𝑛]: (known as Sobel filter)

  • 0 −1       1          2          1

1[𝑚, 𝑛] = [2    0       −2],    ℎ2[𝑚, 𝑛] = [ 0          0       0 ],

1    0    −1                                −1    −2    −1

what is the difference between the two results? (Hint: You should do abs and uint8 before imshow) (c) Repeat (b) by using filter2 function, what is the difference between the two functions? (Hint: Check the pixel values before abs)

 

  1. (12%) This problem uses the sound file “handel.wav” available in MATLAB. This sound is sampled at Fs = 8192 samples per second using 8-bits per sample. You can use the following MATLAB script to load, play and store the audio files:

[y,Fs] = audioread(‘handel.wav’); playerObj = audioplayer(y, Fs); play(playerObj); audiowrite(‘handel0.wav’, y, Fs);

  • Select every other sample in audio signal y which reduces the sampling rate by a factor of two. Now listen to the new sound array using the sound function at half the sampling rate. (Hint: You can use the logical array to index array elements)
  • Select every fourth sample in audio signal y which reduces the sampling rate by a factor of four. Listen to the resulting sound array using the sound function at quarter the sampling rate.
  • From the results of (a) and (b), what do you discover?

II Reference

  1. Formula 2.36
  2. Formula 3.97
  3. Figure 3.10
  4. Table 3.1
  5. Formula 4.67
  6. Formula 4.63
  7. Formula 2.78

 

III Supplement

Ÿ One-Sided Z Transform (It is not included in this course, but important in realistic discrete system) In some practical case (only have one-sided sequence x[n] and initial condition), our solutions require the one-sided or unilateral z-transform, defined by the formula:

 

The one-sided z-transform has the following characteristics:

  1. It does not contain information about the signal 𝑥[𝑛] for negative values of time (i.e., for n<0)
  2. It is unique only for causal signals, because only these signals are zero for n<0.
  3. The one-sided z-transform 𝑋+(𝑧) of 𝑥[𝑛] is identical to the two-sided z-transform X(𝑧) of the signal 𝑥[𝑛]𝑢[𝑛].
  4. ROC of 𝑋+(𝑧) is always the exterior of the circle, so it is not necessary to refer to their ROC.

(More details in the textbook, chapter 3.8)

 

One-Sided Z-Transform of Two-Order LCCDE

We can define two-order linear constant-coefficient difference equation (LCCDE) as follows:

𝑦[𝑛] = 𝑏0𝑥[𝑛] + 𝑏1𝑥[𝑛 − 1] + 𝑏2𝑥[𝑛 − 2] − 𝑎1𝑦[𝑛 − 1] − 𝑎2𝑦[𝑛 − 2],

Apply one-sided z-transform, we have

𝑌+(𝑧) = 𝑏0+𝑏1𝑧11++𝑎𝑏2𝑧𝑧22 𝑋+(𝑧) + (𝑏2𝑥[−1]−𝑎2𝑦[−1])𝑧−1+1+(𝑏𝑎1𝑥𝑧[11+]+𝑎𝑏2𝑧𝑥[2−2]−𝑎1𝑦[−1]−𝑎2𝑦[−2])

1+𝑎 𝑧

,

1                  2                                                                                                                    1                  2

(You can directly use this equation to derive problem 5(a))

 

MATLAB Usage (Reference)

b = [𝑏0 𝑏1 𝑏2]; a = [1 𝑎1 𝑎2]; yic = [y[-1] y[-2]]; xic = [x[-1] x[-2]];

zic = filtic(b, a, yic, xic); y = filter(b, a, x, zic);

(You can reference the scripts to verify the operation in problem 5(b)) (More details in the textbook, page 120)

 

  • HW2-ltvshz.zip