Lab Module 1 DSP
Lab Module 1 DSP
LAB ASSIGNMENT 1:
Generation of Sequences
The purpose of this section is to familiarize students with the basic commands in
SCILAB/MATLAB for signal generation and for plotting the generated signal.
Two basic discrete-time sequences are the unit sample sequence and the unit step
sequence represented by the following equations
1, for n = 0,
Unit sample sequence [n] =
0, for n 0.
1, for n 0,
Unit Step sequence u[n] =
0, for n 0.
A unit sample sequence u{n] of length N can be generated using the SCILAB/MATLAB
command u = [1 zeros(1, N - 1)];
A unit sample sequence ud [n] of length N and delayed by M samples, where M < N,
can be generated using the SCILAB/ MATLAB command
ud = [zeros(1, M) 1 zeros(1, N - M - 1)];
Likewise, a unit step sequence s [n] of length N can be generated using the SCILAB/
MATLAB command
s = [ones(1,N)];
A delayed unit step sequence can be generated in a manner similar to that used in the
generation of a delayed unit sample sequence.
2
EKT430 DIGITAL SIGNAL PROCESSING
Program P1_1 can be used to generate and plot a unit sample sequence.
Report
Q1.1 Run Program P1_i to generate the unit sample sequence u [n] and display it.
Q1.2 What are the purposes of the commands clf, axis, title, xlabel, and ylabel?
Q1.3 Modify Program P1_i to generate a delayed unit sample sequence ud[n] with a
delay of 11 samples. Run the modified program and display the sequence generated.
Q1.4 Modify Program P1_ito generate a unit step sequence s [n]. Run the modified
program and display the sequence generated.
Q1.5 Modify Program P1_ito generate a delayed unit step sequence ad tn] with an
advance of 7 samples. Run the modified program and display the sequence generated.
Another very useful class of discrete-time signals is the real sinusoidal sequence
represented by the following equation
3
EKT430 DIGITAL SIGNAL PROCESSING
Report:
Q1.1 Run Program P1_2 to generate the sinusoidal sequence and display it.
Q1.2 What is the frequency of this sequence and how can it be changed? Which
parameter controls the phase of this sequence? Which parameter controls the
amplitude of this sequence? What is the period of this sequence?
Q1.3 What is the length of this sequence and how can it be changed?
Q1.5 What are the purposes of the axis and grid commands?
Q1.7 Modify the above program to generate a sinusoidal sequence of length 50,
frequency 0 .08, amplitude 2. 5, and phase shift 90 degrees and display it. What is the
period of this sequence?
4
EKT430 DIGITAL SIGNAL PROCESSING
Q1.8 Replace the stem command in Program P1_2 with the plot command and run the
program again. What is the difference between the new plot and the one generated in
Question Q1.1?
Q1.9 Replace the stem command in Program P1_2 with the stairs command and run
the program again. What is the difference between the new plot and those generated in
Questions Q1.1 and Q1.8?
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);
Report
The purpose of digital signal processing is to generate a signal with more desirable
properties from one or more given discrete-time signals. The processing algorithm
consists of performing a combination of basic operations such as addition, scalar
multiplication, time-reversal, delaying, and product operation (Ref class notes).
Considered here are three very simple examples to illustrate the application of such
operations.
5
EKT430 DIGITAL SIGNAL PROCESSING
A common example of a digital signal processing application is the removal of the noise
component from a signal corrupted by additive noise. Let s [n] be the signal corrupted
by a random noise d[n] resulting in the noisy signal x[n] = s[n] + d[n]. The objective is
to operate on x[n] to generate a signal y[n] which is a reasonable approximation to
s[n]. To this end, a simple approach is to generate an output sample by averaging a
number of input samples around the sample at instant n. For example, a three-point
moving average algorithm is given by
1
y[n] = ( x[n 1] + x[n] + x[n + 1])
3
6
EKT430 DIGITAL SIGNAL PROCESSING
Report:
Q1.2 What is the form of the uncorrupted signal s [n]? What is the form of the additive
noise d[n]?
Q1.3 Can you use the statement x = s + d to generate the noise-corrupted signal? If not,
why not?
Q1.4 What are the relations between the signals xl, x2, and x3, and the signal x?
More complex signals can be generated by performing the basic operations on simple
signals. For example, an amplitude modulated signal can be generated by modulating a
high-frequency sinusoidal signal xH[n] = cos(Hn) with a low-frequency modulating
signal xL[n] = cos(Ln). The resulting signal y[n] is of the form
where m, called the modulation index, is a number chosen to ensure that (1 + m xL[n])
is positive for all n.
7
EKT430 DIGITAL SIGNAL PROCESSING
Report:
Q1.1 Run Program P1_4 and generate the amplitude modulated signal y [n] for various
values of the frequencies of the carrier signal xH [n] and the modulating signal xL [n],
and various values of the modulation index im.
Report:
Q1.1 Run Program P1 _5 and generate the swept-frequency sinusoidal sequence x [n].
Q1.2 What are the minimum and maximum frequencies of this signal?
Q1.3 How can you modify the above program to generate a swept sinusoidal signal with