LABEX1
LABEX1
Section:
Laboratory Exercise 1
DISCRETE-TIME SIGNALS: TIME-DOMAIN REPRESENTATION
clf;
n = -10:20;
stem(n,u);
axis([-10 20 0 1.2]);
Answers:
Q1.1 The unit sample sequence u[n] generated by running Program P1_1 is shown
below:
1
Unit Sample Sequence
1.2
0.8
Amplitude
0.6
0.4
0.2
0
-10 -5 0 5 10 15 20
Time index n
The purpose of axis command is – đặt lại các giá trị trên trục tọa độ
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.
2
Unit Sample Sequence
1.2
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 .
3
>
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 ad-
vance of 7 samples is given below along with the sequence generated by running
this program.
4
Unit Sample Sequence
1.2
0.8
Amplitude
0.6
0.4
0.2
0
-10 -5 0 5 10 15 20
Time index n
5
Answers:
6
Real part
2
Amplitude
0
-1
-2
0 5 10 15 20 25 30 35 40
Time index n
Imaginary part
2
1
Amplitude
-1
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 -
7
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 -
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:
8
20
18
16
14
12
Amplitude
10
0
0 5 10 15 20 25 30 35
Time index n
9
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
10
Q1.18 The frequency of this sequence is -f=0.1 hz
A sequence with new length __77___ can be generated by the following command
line:
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 .
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
12
A comparison of this new sequence with the one generated in Question Q1.17
shows -
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 -
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 .
13
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:
14
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
The difference between the new plot and the one generated in Question Q1.17 is -
15
Q1.25 By replacing the stem command in Program P1_4 with the stairs command the
plot obtained is as shown 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
16
The difference between the new plot and those generated in Questions Q1.17 and
Q1.24 is -
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 :
clf;
n=0:99;
x=4*(rand(1,100)-0.5); % 4*[0,1]-0.5=[2,2]
stem(n,x);
ylabel(' amplitude');
axis([ 0 99 -3 3]);
grid;
17
uniform random sequence
2.5
1.5
0.5
amplitude
-0.5
-1
-1.5
-2
10 20 30 40 50 60 70 80
Time index
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:
clf;
n = 0:74;
mean = 0;
variance = sqrt(3);
x=variance*randn(1,75) + mean;
stem(n,x);
ylabel(' amphitude');
axis ([ 0 75 -7 7]);
18
grid;
trung binh
10
2
amplitude
-2
-4
-6
-8
-10
0 10 20 30 40 50 60 70
n
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 .
clf;
n = 0:30;
f = 0.1;
Amax = 4;
phimax = 2*pi;
A= Amax*rand;
19
phi = phimax*rand;
x = A*cos(arg);
stem (n,x);
axis ([ 0 31 -5 5 ]);
grid;
axis ;
20
sinusoidal Sequence with random amplitude and phase
5
1
Amplitude
-1
-2
-3
-4
-5
0 5 10 15 20 25 30
time index n
1
Amplitude
-1
-2
-3
-4
-5
0 5 10 15 20 25 30
time index n 1.
21
2
% Program P1_5
clf;
R = 51;
m = 0:R-1;
subplot(2,1,1);
plot(m,d','r-',m,s,'g--',m,x,'b-.');
y = (x1 + x2 + x3)/3;
subplot(2,1,2);
plot(m,y(2:R+1),'r-',m,s,'g--');
Answers:
Q1.29 The signals generated by running Program P1_5 are displayed below :
22
d[n]
6
s[n]
Amplitude x[n]
4
0
0 5 10 15 20 25 30 35 40 45 50
Time index n
8
y[n]
6 s[n]
Amplitude
0
0 5 10 15 20 25 30 35 40 45 50
Time index n
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. >
23
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:
1.5
0.5
Amplitude
-0.5
-1
-1.5
0 10 20 30 40 50 60 70 80 90 100
Time index n Q1.35
24
A copy of Program P1_7 is given below.
% Program P1_7
n = 0:100;
a = pi/2/100;
b = 0;
x = cos(arg);
clf;
stem(n, x);
axis([0,100,-1.5,1.5]);
ylabel('Amplitude');
grid; axis;
Answers:
25
Swept-Frequency Sinusoidal Signal
1.5
0.5
Amplitude
-0.5
-1
-1.5
0 10 20 30 40 50 60 70 80 90 100
Time index n
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 :
clf;
n=0:100;
a=2*pi*10^(-3);
b=0.2*pi;
arg = a*n.*n+b*n;
x = cos(arg);
stem(n,x);
axis([0,100,-1.5,1.5]);
xlabel(' time');
26
ylabel(' amplitude');
grid;
0.5
amplitude
-0.5
-1
-1.5
0 10 20 30 40 50 60 70 80 90 100
time
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 -
27
1.4 OTHER TYPES OF SIGNALS (Optional)
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 :
clf;
n=0:50;
f=0.05;
phase = -pi/2;
duty = 50;
a =3;
x=a*square(arg,duty);
subplot(211);
stem(n,x);
axis ([ 0 50 -4 4]);
grid;
xlabel(' Time');
ylabel(' amplitude');
m = 0:50;
tanso = 0.03;
phasew = pi/6;
peak =1;
A1 =2.0;
arg2=2*pi*f*n + phasew;
x1=A1*sawtooth(arg2,peak);
28
subplot(212);
stem (m,x1);
axis([0 60 -2 2]);
grid;
ylabel('amplitude');
29
square wave sequence
4
amplitude 2
-2
-4
0 5 10 15 20 25 30 35 40 45 50
Time
sawtooth wave sequence
2
1
amplitude
-1
-2
0 10 20 30 40 50 60
time
Date: Signature:
30