Starting from:

$30

Digital Signal Processing Homework Assignment #2


EE3660 Intro. to Digital Signal Processing
Homework Assignment #2: Chap. 2-4

I Program Assignment (100%)
1. (8%) Let π‘₯[𝑛] = β„Ž[𝑛] = (0.9)
𝑛𝑒[𝑛] and 𝑦[𝑛] = π‘₯[𝑛] ∗ β„Ž[𝑛]
(a) Determine 𝑦[𝑛] analytically and plot the first 99 non-zero samples using the stem function.
(b) Take first 50 samples of π‘₯[𝑛] and β„Ž[𝑛]. Compute and plot 𝑦[𝑛] using the conv function.
(c) Using the filter function, determine and plot the first 99 samples of 𝑦[𝑛].
(d) Which of the outputs in (b) and (c) come close to that in (a)? Explain.
2. (8%) The sum 𝐴π‘₯ β‰œ ∑𝑛 π‘₯[𝑛] can be thought of as a measure of the “area” under a sequence x[n].
(a) Starting with the convolution sum (2.36), show that 𝐴𝑦 = 𝐴π‘₯π΄β„Ž (derive in the live script).
(b) 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.
(c) Normalize h[n] so that π΄β„Ž = 1 and repeat part (b).
(d) If π΄β„Ž = 1, then 𝐴𝑦 = 𝐴π‘₯ . Use this result to explain the difference between the plots
obtained in parts (b) and (c).
3. (8%) The response of a LTI system to the input π‘₯[𝑛] = 𝑒[𝑛] is 𝑦[𝑛] = 2 ⋅ (
1
3
)
𝑛𝑒[𝑛].
(a) Find the impulse response β„Ž[𝑛] of the system, and check the results using the function filter.
(b) Plot the pole-zero pattern using the function zplane(b, a).
(c) Compute and plot the impulse response using the functions filter and stem. Compare with
the plot obtained using the function impz.
(d) Use the function residuez and the z-transform pairs in Table 3.1 to find an analytical
expression for the impulse response h[n].
4. (12%) 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| > 𝐢)
5. (10%) Consider the following LCCDE:
𝑦[𝑛] = 2π‘π‘œπ‘ (πœ”0)𝑦[𝑛 − 1] − 𝑦[𝑛 − 2],
with no input but with initial conditions 𝑦[−1] = 0 and 𝑦[−2] = −𝐴𝑠𝑖𝑛(πœ”0).
(a) 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).
(b) For 𝐴 = 2 and πœ”0 = 0.1πœ‹, verify the operation of the above digital oscillator using the
filtic and the filter function. (Hint: Check one-sided z-transform in supplement)
6. (10%) In this problem we illustrate the numerical evaluation of DTFS using MATLAB.
(a) Write a function c=dtfs0(x) which computes the DTFS coefficients (4.67) of a periodic
signal and verify the result with dtfs function.
(b) Write a function x=idtfs0(c) which computes the inverse DTFS (4.63) and verify the result
with idtfs function.
7. (12%) Determine and plot the magnitude and phase spectra of the following periodic sequences:
(a) x1[n] = 4 ⋅ cos(1.2πn +
π
3
) + 6 ⋅ sin(0.4πn −
π
6
)
(b) x2[n] = {1, 1, 0, 1, 1, 1, 0, 1}, (one period)

(c) x3[n] = 1 − sin(
π
4
n), 0 ≤ n ≤ 11 (one period)
8. (8%) 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);
(a) Use subplot to plot the magnitude |X1|, |X2| and phase ∠X1, ∠X2 in one graph respectively.
(b) Is the magnitude |X1| = |X2| ? Is the phase ∠X1 = ∠X2 ? If not, Explain.
9. (12%) 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:
β„Ž[π‘š, 𝑛] = {
1
25
, − 2 ≤ π‘š, 𝑛 ≤ 2
0 , π‘œπ‘‘β„Žπ‘’π‘Ÿπ‘€π‘–π‘ π‘’
,
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)
β„Ž1
[π‘š, 𝑛] = [
1 0 −1
2 0 −2
1 0 −1
], β„Ž2
[π‘š, 𝑛] = [
1 2 1
0 0 0
−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)
10. (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);
(a) 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)
(b) 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.
(c) 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𝑧
−1+𝑏2𝑧
−2
1+π‘Ž1𝑧−1+π‘Ž2𝑧−2 𝑋
+(𝑧) +
(𝑏2π‘₯[−1]−π‘Ž2𝑦[−1])𝑧
−1+(𝑏1π‘₯[−1]+𝑏2π‘₯[−2]−π‘Ž1𝑦[−1]−π‘Ž2𝑦[−2])
1+π‘Ž1𝑧−1+π‘Ž2𝑧−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)

More products