Description
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)