Exercise#03 1
Exercise#03 1
Date:
Section:
Exercises #03
Generation of Sequence
Introduction:
The purpose of this exercise is to familiarize you with the basic commands in MATLAB for signal
generation and for plotting the generated signal. MATLAB has been designed to operate on data stored
as vectors or matrices. For our purposes, sequences will be stored as vectors.
with the arrow indicates the sample at time index n = 0 which will serve as our reference. However in
MATLAB, we cannot have information about the sample position directly from this row vector. Therefore,
to completely define discrete-time signals in MATLAB, we need to define two row vectors, one for x(n)
and another one for n. For example, to define the sequence
1
How should the following signals be defined? Plot them on the spaces provided below
a. b.
c. d.
2
Part 2 – Elementary discrete time signals
The unit sample sequence is defined as
3
Q2.1 Show how these plots are generated.
Tip: A shortcut to define a matrix whose elements are zeroes or ones only, you can use the command
zeros(m,n) and ones(m,n) where m-by-n is the size of the matrix containing zeros or ones as
elements, respectively. For example to define a row vector of zeroes, use
>> zeros(1,10)
and it will generate a row vector of ten zeros. The command
>> ones(1,12)
will generate a row vector of twelve ones. Try issuing the command
>> [zeros(1,3) 1 zeros(1,3)]
and observe the results.
4
Q2.2 Define the following unit sample sequences and plot the results in MATLAB
5
c. The same unit sample sequence in (a) delayed by three samples
n=[0:9]; x = [zeros(1,3) 1 zeros(1,6)];
stem(n,x); grid on; title('c')
6
e. The same unit sample sequence in (a) advanced by three samples.
n=[-3:9]; x=[1 zeros(1,12)];
stem(n,x); grid on; title('e')
Q2.3 Generate a length-7 unit step sequence and its delayed version of two samples. Plot the
sequence on the spaces provided below
7
=[-3:3]; x=[zeros(1,3) ones(1,4)];
stem(n,x); grid on; title('Unit Step Sequence')
Observation:
8
Conclusion:
In this laboratory experiment, I have been familiarized with the different basic commands in MATLAB that
are used for the generation of signal and plotting of a signal. In this activity, discrete-time signals are
being plotted. Discrete-time signal is a form of a continuous-time signal wherein it is function of an
independent variable that is an integer. Elementary discrete time signals are also plotted such as the unit
sample sequence, unit step sequence, real-valued exponential sequence, complex-valued exponential
sequence, sinusoidal sequence, and random sequence.