Upload
mohamed-hussien-hamed
View
27
Download
3
Embed Size (px)
Citation preview
Giacinto Gelli DSP Course – 1 / 5
Digital Signal Processing a.y. 2007-2008
Matlab Laboratory # 1Discrete-time signals and systems
Giacinto Gelli
Discrete-time signals
Giacinto Gelli DSP Course – 2 / 5
• Discrete-time signal x[n] ⇒ represented by a pair of Matlab vectors n (time)and x (amplitude)
• Example: n = [-3,-2,-1,0,1,2,3]; x = [2,1,-1,0,1,4,3];
• Graphical representation: command stem(n,x) (not plot! check thedifference!)
• Exercises:
(a) Generate/plot x[n] = RN [n] (rectangular window in 0 ≤ n ≤ N − 1).
(b) Generate/plot x[n] = u[n].
(c) Generate/plot x[n] = δ[n].
(d) Generate/plot x[n] = A(α)nu[n] (the 6 cases on a single figure usingsubplot.
(e) Generate/plot x[n] = A cos(ω0n + φ) (check frequency/timeperiodicity).
Signal operations
Giacinto Gelli DSP Course – 3 / 5
• Operations on two or more signals require that the signal be defined on thesame time interval.
• Time-shifting and reflection operates only on the vector n.
• Exercises:
(a) Given the signal x[n], write a Matlab function [y,n] =
time shift(x,n,n0) for evaluating y[n − n0] for arbitrary values ofn0 ∈ Z. Test it with the signal x[n] = (0.9)nu[n] for −5 ≤ n ≤ 20 andn0 = ±10, plot the results and comment.
(b) Given the signal x[n], write a Matlab function [y,n] =
time reverse(x,n) for evaluating y[n] = x[−n] (use the commandfliplr or flipud). Test it with the signal x[n] = R3[n], plot theresults and commment.
Discrete-time systems and convolution (1/2)
Giacinto Gelli DSP Course – 4 / 5
• Convolution y[n] = x[n] ∗ h[n] is performed using the command y =
conv(x,h).
• Limitations:
(a) x[n] and h[n] must be finite-length sequences or must be truncated ⇒
can be used only for FIR filters (for the general case use the commandfilter instead).
(b) The command conv does not allow one to specify the time-interval.
Discrete-time systems and convolution (2/2)
Giacinto Gelli DSP Course – 5 / 5
• Exercises:
(a) Write a Matlab script for evaluating the convolution betweenh[n] = RN (n) and x[n] = anu[n] for N = 4 and a = 0.8 (a criticalpoint is truncation of the infinite-length x[n], try to find an appropriatecriterion). Plot the results and comment.
(b) The command �conv can alos be used for poynomial multiplication. Use itto perform multiplication between the two polynomialsP1(z
−1) = 1 − 1
2z−1 and P2(z
−1) = 1 + 3
4z−1. Check with the
analytical solution.