Labex 1
Labex 1
Section:
Laboratory Exercise 1
DISCRETE-TIME SIGNALS: TIME-DOMAIN REPRESENTATION
Answers:
Q1.1 The unit sample sequence u[n] generated by running Program P1_1 is shown below:
1
Unit Sample Sequence
0.8
Amplitude
0.6
0.4
0.2
0
-10 -5 0 5 10 15 20
Time index n
Q1.2
The purpose of clf command is - Deletes all objects from the current figure
The purpose of axis command is - Sets manual scaling of axes on plots
The purpose of title command is - Write specified text on the top of the current plot
The purpose of xlabel command is - Write specified text below the x-axis of the current 2-D plot
The purpose of ylabel command is - Write specified text on the left side of the y-axis of the current 2-D
plot
Q1.3 The modified Program P1_1 to generate a delayed unit sample sequence ud[n] with a delay of 11
samples is given below along with the sequence generated by running this program .
% Program P1_1, Q1.3
% Generation of a Unit Sample Sequence
clf;
% Generate a vector from -10 to 20
n = -10:20;
% Generate a delayed unit sample sequence
u = [zeros(1,21) 1 zeros(1,9)];
% Plot a delayed unit sample sequence
stem(n,u);
xlabel('Time index n');ylabel('Amplitude');
title('A Delayed Unit Sample Sequence');
axis([-10 20 0 1.2]);
2
A Delayed Unit Sample Sequence
0.8
Amplitude
0.6
0.4
0.2
0
-10 -5 0 5 10 15 20
Time index n
Q1.4 The modified Program P1_1 to generate a unit step sequence s[n] is given below along with the
sequence generated by running this program .
% Program P1_1, Q1.4
% Generation of a Unit Step Sequence
clf;
% Generate a vector from -10 to 20
n = -10:20;
% Generate a unit step sequence
u = [zeros(1,10) ones(1,21)];
% Plot a unit step sequence
stem(n,u);
xlabel('Time index n');ylabel('Amplitude');
title('A Unit Step Sequence');
axis([-10 20 0 1.2]);
3
A Unit Step Sequence
0.8
Amplitude
0.6
0.4
0.2
0
-10 -5 0 5 10 15 20
Time index n
Q1.5 The modified Program P1_1 to generate a unit step sequence sd[n] with an advance of 7 samples is
given below along with the sequence generated by running this program .
% Program P1_1, Q1.5
% Generation of a Unit Step Sequence with an advance of 7 samples
clf;
% Generate a vector from -10 to 20
n = -10:20;
% Generate a unit step sequence with an advance of 7 samples
u = [zeros(1,3) ones(1,28)];
% Plot a unit step sequence with an advance of 7 samples
stem(n,u);
xlabel('Time index n');ylabel('Amplitude');
title('A Unit Step Sequence with an advance of 7 samples');
axis([-10 20 0 1.2]);
4
A Unit Step Sequence with an advance of 7 samples
0.8
Amplitude
0.6
0.4
0.2
0
-10 -5 0 5 10 15 20
Time index n
Proj ect
% Program P1_3
% Generation of a real exponential sequence
clf;
n = 0:35; a = 1.2; K = 0.2;
x = K*a.^+n;
stem(n,x);
xlabel('Time index n');ylabel('Amplitude');
5
Answers:
Q1.6 The complex-valued exponential sequence generated by running Program P1_2 is shown below :
Real part
2
Amplitude
-2
0 5 10 15 20 25 30 35 40
Time index n
Imaginary part
2
Amplitude
-2
0 5 10 15 20 25 30 35 40
Time index n
Q1.7 The parameter controlling the rate of growth or decay of this sequence is -n
Q1.9 The purpose of the operator real is - Determines the real part of a complex number or matrix
The purpose of the operator imag is - Determines the imaginary part of a complex number or matrix
Q1.10 The purpose of the command subplot is - Breaks figure window into multiple rectangular panes
for the display of multiple plots
Q1.11 The real-valued exponential sequence generated by running Program P1_3 is shown below :
6
120
100
80
Amplitude
60
40
20
0
0 5 10 15 20 25 30 35
Time index n
Q1.12 The parameter controlling the rate of growth or decay of this sequence is -n
Q1.13 The difference between the arithmetic operators ^ and .^ is – when using “^”, the program has
Q1.14 The sequence generated by running Program P1_3 with the parameter a changed to 0.9 and the
parameter K changed to 20 is shown below :
7
20
18
16
14
12
Amplitude
10
0
0 5 10 15 20 25 30 35
Time index n
Q1.16 The energies of the real-valued exponential sequences x[n]generated in Q1.11 and Q1.14 and
computed using the command sum are – E = sum(x.^2);
8
axis([0 40 -2 2]);
grid; title('Sinusoidal Sequence');
xlabel('Time index n');
ylabel('Amplitude');
axis;
Answers:
Q1.17 The sinusoidal sequence generated by running Program P1_4 is displayed below .
Sinusoidal Sequence
2
1.5
0.5
Amplitude
-0.5
-1
-1.5
-2
0 5 10 15 20 25 30 35 40
Time index n
A sequence with new frequency f = 0.2 can be generated by the following command line : f = 0.2;
9
It is controlled by the following MATLAB command line : n = 0:40;
A sequence with new length 42 can be generated by the following command line : n = 0:41;
Q1.21 The purpose of axis command is - Sets manual scaling of axes on plots
The purpose of grid command is - Adds or deletes grid lines to or from the current plot
Q1.22 The modified Program P1_4 to generate a sinusoidal sequence of frequency 0.9 is given below along
with the sequence generated by running it .
% Program P1_4, Q1.22
% Generation of a sinusoidal sequence
n = 0:40;
f = 0.9;
phase = 0;
A = 1.5;
arg = 2*pi*f*n - phase;
x = A*cos(arg);
clf; % Clear old graph
stem(n,x); % Plot the generated sequence
axis([0 40 -2 2]);
grid; title('Sinusoidal Sequence');
xlabel('Time index n');
ylabel('Amplitude');
axis;
10
Sinusoidal Sequence
2
1.5
0.5
Amplitude
-0.5
-1
-1.5
-2
0 5 10 15 20 25 30 35 40
Time index n
A comparison of this new sequence with the one generated in Question Q1.17 shows - similar
A sinusoidal sequence of frequency 1.1 generated by modifying Program P1_4 is shown below.
11
Sinusoidal Sequence
2
1.5
0.5
Amplitude
-0.5
-1
-1.5
-2
0 5 10 15 20 25 30 35 40
Time index n
A comparison of this new sequence with the one generated in Question Q1.17 shows - similar
Q1.23 The sinusoidal sequence of length 50, frequency 0.08, amplitude 2.5, and phase shift of 90 degrees
generated by modifying Program P1_4 is displayed below .
12
Sinusoidal Sequence
2
1.5
0.5
Amplitude
-0.5
-1
-1.5
-2
0 5 10 15 20 25 30 35 40
Time index n
Q1.24 By replacing the stem command in Program P1_4 with the plot command, the plot obtained is as
shown below:
13
Sinusoidal Sequence
3
1
Amplitude
-1
-2
-3
0 5 10 15 20 25 30 35 40
Time index n
– when using
The difference between the new plot and the one generated in Question Q1.17 is
“plot”, the result is continuous signal, when using “stem”, the result is discreted signal
Q1.25 By replacing the stem command in Program P1_4 with the stairs command the plot obtained is as
shown below:
14
Sinusoidal Sequence
3
1
Amplitude
-1
-2
-3
0 5 10 15 20 25 30 35 40
Time index n
– when
The difference between the new plot and those generated in Questions Q1.17 and Q1.24 is
using “plot”, the result is continuous signal, when using “stairs”, the result is stairstep
signal
Answers:
Q1.26 The MATLAB program to generate and display a random signal of length 100 with elements uniformly
distributed in the interval [–2, 2] is given below along with the plot of the random sequence generated
by running the program :
n=0:99;
x= randn(1,100);
clf;
plot(n,x);
axis ([ 0 100 -2 2 ]);
grid; title ('random amp sequence');
xlabel ('time');
ylabel ('amplitude');
15
random amp sequence
2
1.5
0.5
amplitude
-0.5
-1
-1.5
-2
0 10 20 30 40 50 60 70 80 90 100
time
Q1.27 The MATLAB program to generate and display a Gaussian random signal of length 75 with elements
normally distributed with zero mean and a variance of 3 is given below along with the plot of the
random sequence generated by running the program :
< Insert program code here. Copy from m-file(s) and paste. >
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
Q1.28 The MATLAB program to generate and display five sample sequences of a random sinusoidal signal of
length 31
where the amplitude A and the phase are statistically independent random variables with uniform
probability distribution in the range 0 A 4 for the amplitude and in the range 0
for the phase is given below. Also shown are five sample sequences generated by running this program
five different times .
< Insert program code here. Copy from m-file(s) and paste. >
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
16
A copy of Program P1_5 is given below.
< Insert program code here. Copy from m-file(s) and paste. >
Answers:
Q1.29 The signals generated by running Program P1_5 are displayed below :
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
Q1.31 The statement x = s + d CAN / CANNOT be used to generate the noise corrupted signal because -
Q1.32 The relations between the signals x1, x2, and x3, and the signal x are -
< Insert program code here. Copy from m-file(s) and paste. >
Answers:
Q1.34 The amplitude modulated signals y[n] generated by running Program P1_6 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 m are shown below:
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
< Insert program code here. Copy from m-file(s) and paste. >
Answers:
Q1.36 The swept-frequency sinusoidal sequence x[n] generated by running Program P1_7 is displayed
below.
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
17
Q1.38 The Program 1_7 modified to generate a swept sinusoidal signal with a minimum frequency of 0.1 and
a maximum frequency of 0.3 is given below :
< Insert program code here. Copy from m-file(s) and paste. >
Q1.39 The information displayed in the command window as a result of the who command is -
Q1.40 The information displayed in the command window as a result of the whos command is -
Answer:
Q1.41 MATLAB programs to generate the square-wave and the sawtooth wave sequences of the type shown
in Figures 1.1 and 1.2 are given below along with the sequences generated by running these programs :
< Insert program codes here. Copy from m-file(s) and paste. >
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
Date: Signature:
18