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

$35.00

Category: You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (8 votes)

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)