DSP Lab ExptList 2020
DSP Lab ExptList 2020
1. Generate the following fundamental discrete time signals and display using various plot-
ting functions available in MATLAB.
i. Unit impulse
ii. Unit step
iii. Unit ramp
iv. Periodic sequences (Eg. x[n] = {· · · , 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, · · · })
v. Exponential signal, x[n] = a(α)n u[n], where
(a) a and α are real. Obtain the plots for various values of α (α >1, 0 <α <1, -1
<α <0, -1<α ).
(b) a is complex.
(c) α is complex. Take α = eβ and obtain the plots if β is purely imaginary (β = jω)
and complex (β = σ + jω).
vi. Plot the complex exponential signal x[n] = ejΩ0 n for a specific Ω0 . Check whether the
signal is periodic for all values of Ω0 . If not obtain the condition for periodicity and
demonstrate the same using appropriate plots. (use “subplot” and “hold” functions)
( )
4πn
vii. Given x1 [n] = cos , x2 [n] = 3 cos(1.3πn) − 4 sin(0.5πn + 0.5π), x3 [n] =
17
5 cos(1.5πn + 0.75π) + 4 cos(0.6πn) − sin(0.5πn). In each case, determine the period
of the sequence theoretically and verify the result using the MATLAB plots.
viii. Plot signal x[n] = {1, 1, 1, 0, 1, 2, 3, 4}. Plot x[−n] and x[−n + 2].
2. a) Sample the sinusoid xa = 3 sin(2πf t), where f = 2 KHz at two different sampling
frequencies, fs1 = 3 KHz and fs2 = 5 KHz and plot the sampled signals. Use func-
tions ‘stem’ and ‘subplot’. Plot the sampled signals over the original continuous-time
signal. (Use ‘hold’)
b) Express the above as a 3-bit digital signal. Sample at fs3 = 15 KHz. Plot the sampled
signal (use ‘stem’) over the original analog signal.
3. A random signal of length N with samples uniformly distributed in the interval (0, 1)
can be generated by using the MATLAB command x = rand(1, N ). Likewise, a random
signal x[n] of length N with samples normally distributed with zero mean and unity
variance can be generated by using the following MATLAB command x = randn(1, N );
a. Write a MATLAB program to generate and display a random signal of length 100
whose elements are uniformly distributed in the interval [−2, 2].
b. Write a MATLAB program to generate and display a Gaussian random signal of length
75 whose elements are normally distributed with zero mean and a variance of 3. (Check
to see that the realised variable has mean and variance as defined, using the built in
functions mean() and var() in MATLAB ).
4. Familiarize the MATLAB functions for reading and displaying speech, audio, and image
data (eg. imread(), imshow(), wavread(), sound() etc.). Generate a chessboard image
(as a matrix) and display it on the screen.
No.2: Convolution
1. Generate the signal x[n] = {1, 1, 1, 0, 1, 2, 3, 4}. Write a function to compute linear con-
volution with system impulse response h[n] = {1, 2, 1, −1} given by
∑
y[n] = h[k]x[n − k]
k
Verify your result with that obtained from in-built function in MATLAB. How would the
result change if we were to change the origin point of
(a) x[n]
(b) h[n]
2. Use the above program to find the step response of an LTI system given the impulse
response. (Take h[n] = {1, 2, 3, 4}). Also compute the response of the same system to a
rectangular pulse, exponential signal and a sinusoidal signal.
1. You are given a sinusoid x(t) = 3 sin(2πf t) where f is 2 KHz. Sample the given signal
with sampling frequency fs = 8 KHz and plot the subsequent output.
2. Generate x1 [n] = {1, 2, 3} and x2 [n] = {3, 2, 1}. Obtain their respective 5-point DFTs.
{ }
1 1 1 1
3. Compute the eight point DFT of a given sequence x[n] = , , , , 0, 0, 0, 0 using
2 2 2 2
radix-2 decimation in time and radix-2 decimation-infrequency algorithms. Compare the
speed of your algorithm with the built-in DFT function of MATLAB.
No.4: Over sampling, under sampling effects in time and frequency domain.
1. Generate a sinusoid of frequency 13 Hz. Since the frequency of the continuous time signal
1
is 13 Hz, the Nyquist rate is T = . Run the program for several values of T , below and
26
1 1 1 2 1 2 4
above the Nyquist rate such as , , , , , , ,
8 × 13 6 × 13 4 × 13 7 × 13 3 × 13 5 × 13 9 × 13
1 2 4 1
, , , , etc.. Which of the discrete time signals will give correct
2 × 13 3 × 13 5 × 13 13
reconstruction of the continuous time signal? Mathematically determine the angular fre-
quency in rad/sample and the fundamental period N of each of the discrete time signals
and verify from the plots.
1 −7
2. Generate two sinusoids with frequencies f0 = Hz and f1 = Hz. Sample both at
8 8
fs = 1 Hz.
(a) Generate stem plots for each, with a different color for each. Plot the original
continuous signals over the sampled one, again each color coded. What do you
observe?
(b) Determine the sampling rate at which you can avoid a problem here. Repeat the
procedure at this new sampling frequency. What do you observe?
(c) Devise a method to obtain the signal without changing the sampling rate?
Can you give a theoretical explanation for the particular frequencies that come up? Would
you be able to give a f2 for which this same sampling problem would occur at fs ?
3. Consider a continuous time periodic signal x(t) and sample it with sampling frequency fs .
Let the period of the resultant signal be N (x[n] = x[n+N ]). The spectrum of the discrete
signal would be periodic with period N . Focusing on a single period k = 0, · · · , N − 1,
corresponding to a frequency range 0 ≤ f ≤ fs , display the effects of under sampling,
sampling at Nyquist rate and oversampling by looking at the spectrum?
No.5: Z-Transform
1. a) Write a MATLAB program to compute and display the poles and zeros, to compute
and display the factored form and to generate the pole-zero plot of a z-transform that
is a ratio of two polynomials in z −1 . Using this program, analyze the z transform
2 + 5z −1 + 9z −2 + 5z −3 + 3z −4
H(z) =
5 + 45z −1 + 2z −2 + z −3 + z −4
b) From the pole-zero plot generated in part a), determine the possible ROCs. Can you
tell from the pole-zero plot whether or not the DTFT exists? Is the filter stable if it
is causal?
c) Using zp2tf (), determine the rational form of a z transform whose zeros are at z1 = 0.3,
z2 = 2.5, z3 = −0.2 + j0.4, and z4 = −0.2 − j0.4; the poles are at p1 = 0.5, p2 =
−0.75, p3 = 0.6 + j0.7, and p4 = 0.6 − j0.7; and the gain constant k is 3.9.
z −1
d) Using impz() determine the first 10 samples of the inverse z transform of
3 − 4z −1 + z −2
. Using residuez() obtain the partial fraction expansion of X(z). From the partial
fraction expansion, write down the closed form expression of the inverse z transform
(assuming causal). Evaluate the first 10 samples of the closed form expression for x[n]
using MATLAB and compare with the result obtained using impz().
e) Using residuez() convert back the partial fraction expression for X(z) in part d) to
the rational function form.
2. Obtain the pole-zero plot of the transfer function H(z) = 1 − 0.3z −1 − 0.2z −2 . Plot the
magnitude and phase spectrum of the same.
3. Show stable and unstable conditions for the linear time invariant system h[n] = an u(n).
Obtain pole-zero plot for both conditions. Vary location of the pole, one at ROC limit,
one outside and one inside and observe the system response over time. Discuss in detail
the pole-zero plots you obtained relating to stability.
4. Determine the zeros for the systems H1 (z) = 6+z −1 −z −2 and H2 (z) = 1−z −1 −6z −2 , and
indicate whether the system is minimum phase, maximum-phase or mixed-phase system.
Explain the results obtained in terms of the magnitude and phase responses.
No.6: FIR Filter design
π
1. Compute the pole-zero plot of an FIR filter that blocks the frequencies Ω0 = and
2
3π
Ω1 = .
4
2. Consider the FIR filter, given by y[n] = x[n] + x[n − 4]
π
3. Design an FIR filter that completely blocks the frequency Ω0 = and then compute its
( ) 4
π
output if the input is x[n] = sin n u(n) for n = 0, 1, 2, 3, 4. Does the filter fulfill your
4
expectations? Explain.
1. Design a Low pass filter with the following specifications: Compute the order of the fil-
ter based on the transition width. Choose the window based on the stop band attenuation.
Pass band edge frequency = 1000 Hz; Stop band edge frequency = 1500 Hz
Minimum stop band attenuation = 50 dB; Maximum pass band attenuation = 0.9 dB
Sampling Frequency = 8000 Hz
Pass band edge frequency = 1500 Hz; Stop band edge frequency = 1000 Hz
Minimum stop band attenuation = 50 dB; Maximum pass band attenuation = 0.9 dB
Sampling Frequency = 8000 Hz
4. Generate a composite signal by adding sinusoids of different frequencies (100 Hz, 200 Hz,
500 Hz, 2000 Hz, and 4000 Hz). Compute the output of the filters designed in Qns. 1 to
3 by giving the composite signal as input and verify the design.
5. Vary the window size and window type, how does the response vary? Filter two signals
at different frequencies, one in pass band and the other in the stop band. Do you get
results as expected?
No.8: IIR Filter design
Pass band edge frequency = 1000 Hz; Stop band edge frequency = 2000 Hz
Minimum stop band attenuation = 30 dB; Maximum pass band attenuation = 0.5 dB
Sampling Frequency = 8000 Hz
2. Design and implement a low pass Chebychev filter using IIT for the specifications given
in Qn.1. Compare the two designs.
3. Determine the transfer function and plot the gain response of an elliptic IIR low pass
filter with the following specifications:
Passband edge fp =800 Hz, Stopband edge fst = 1 KHz,
passband ripple of 0.5 dB, minimum stopband attenuation of 40 dB
sampling rate fs = 4 KHz.
4. Generate two different signals with different frequencies, one signal in passband and the
other signal in the stop band. Show the results for all the above filters.
No.9: Correlation
1. Write a program to perform correlation of two sequences. Create any two arbitrary se-
quences of short lengths and compute the result using your program. Use the inbuilt
function in MATLAB to verify your result.
2. Use your program to compute the auto correlation of a sequence. Compute the auto cor-
relation of a rectangular pulse and a periodic signal. Plot the auto correlation function
and comment on your results.