0% found this document useful (0 votes)
34 views16 pages

Laboratory Exercise 1: Discrete-Time Signals: Time-Domain Representation

This document contains a laboratory exercise on discrete-time signals and their time-domain representation. It includes questions about generating and modifying unit sample, unit step, exponential, and sinusoidal sequences using MATLAB code. The questions test understanding of generating sequences, controlling sequence parameters like rate of growth/decay and amplitude, and computing sequence energies. Sample sequences generated by running the provided MATLAB programs are displayed.

Uploaded by

Vrunda Shah
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
Download as doc, pdf, or txt
0% found this document useful (0 votes)
34 views16 pages

Laboratory Exercise 1: Discrete-Time Signals: Time-Domain Representation

This document contains a laboratory exercise on discrete-time signals and their time-domain representation. It includes questions about generating and modifying unit sample, unit step, exponential, and sinusoidal sequences using MATLAB code. The questions test understanding of generating sequences, controlling sequence parameters like rate of growth/decay and amplitude, and computing sequence energies. Sample sequences generated by running the provided MATLAB programs are displayed.

Uploaded by

Vrunda Shah
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1/ 16

Vrunda shah (IE)

Laboratory Exercise 1
DISCRETE-TIME SIGNALS: TIME-DOMAIN REPRESENTATION

1.1 GENERATION OF SEQUENCES

Project 1.1 Unit sample and unit step sequences


Answers:
% Program P1_1
% Generation of a Unit Sample Sequence
clf;% Generate a vector from -10 to 20
n = -10:20;
% Generate the unit sample sequence
u = [zeros(1,10) 1 zeros(1,20)];
% Plot the unit sample sequence
stem(n,u);

Q1.1 The unit sample sequence u[n] generated by running Program P1_1 is shown below:

0.9

0.8

0.7

0.6

0.5

0.4

0.3

0.2

0.1

0
-10 -5 0 5 10 15 20

Q1.2 The purpose of clf command is – to clear current figure

The purpose of axis command is –it control axis appearance and scaling

The purpose of title command is –it adds text at the top of the current axis.

The purpose of xlabel command is –it adds text beside the X-axis on the current axis. The

purpose of ylabel command is – it adds text beside the Y-axis on the current axis.

1
Vrunda shah (IE)

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 .
Answers:
% Program P1_1
% Generation of a Unit Sample Sequence
clf;% Generate a vector from -10 to 20
n = -10:20;
% Generate the unit sample sequence
u = [zeros(1,10) 1 zeros(1,20)];
% Plot the unit sample sequence
stem(n+11,u);

0.9

0.8

0.7

0.6

0.5

0.4

0.3

0.2

0.1

0
0 5 10 15 20 25 30 35

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 .
Answers:
% Program P1_1
% Generation of a Unit Sample Sequence
clf;% Generate a vector from -10 to 20
n = -10:20;
% Generate the unit sample sequence
u = [zeros(1,10) 1 ones(1,20)];
% Plot the unit sample sequence
stem(n,u);

2
Vrunda shah (IE)

0.9

0.8

0.7

0.6

0.5

0.4

0.3

0.2

0.1

0
-10 -5 0 5 10 15 20

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 .
Answers:
% Program P1_1
% Generation of a Unit Sample Sequence
clf;% Generate a vector from -10 to 20
n = -10:20;
% Generate the unit sample sequence
u = [zeros(1,10) 1 ones(1,20)];
% Plot the unit sample sequence
stem(n-7,u);

0.9

0.8

0.7

0.6

0.5

0.4

0.3

0.2

0.1

0
-20 -15 -10 -5 0 5 10 15

3
Vrunda shah (IE)

Project 1.2 Exponential signals

Answers:
% Program P1_2
% Generation of a complex exponential sequence
clf;
c = -(1/12)+(pi/6)*i;
K = 2;
n = 0:40;
x = K*exp(c*n);
subplot(2,1,1);
stem(n,real(x));
xlabel('Time index n');ylabel('Amplitude');
title('Real part');
subplot(2,1,2);
stem(n,imag(x));
xlabel('Time index n');ylabel('Amplitude');
title('Imaginary part');

% 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');

Q1.6 The complex-valued exponential sequence generated by running Program P1_2 is shown below :

Real part
2

1
Amplitude

-1

-2
0 5 10 15 20 25 30 35 40
Time index n
Imaginary part
2
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 –c

4
Vrunda shah (IE)

The parameter controlling the amplitude of this sequence is -k

Q1.8 The result of changing the parameter c to (1/12)+(pi/6)*i is –

Real part
50
Amplitude

-50
0 5 10 15 20 25 30 35 40
Time index n
Imaginary part
100
Amplitude

50

-50
0 5 10 15 20 25 30 35 40
Time index n

If we change value of c,the signal will become growth signal

Q1.9 The purpose of the operator real is – it is used to represent real value

The purpose of the operator imag is - it is used to represent imaginary value

Q1.10 The purpose of the command subplot is –

subplot Create axes in tiled positions. H = subplot(m,n,p), or subplot(mnp), breaks the


Figure window into an m-by-n matrix of small axes, selects the p-th axes for the current
plot, and returns the axes handle.

Q1.11 The real-valued exponential sequence generated by running Program P1_3 is shown below :

5
Vrunda shah (IE)

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 –a

The parameter controlling the amplitude of this sequence is - k

Q1.13 ^ and .^ is –
The difference between the arithmetic operators “^”
raises a square matrix to a power using matrix multiplication.
“.^” raises the elements of a matrix or vector to a power; this is a “pointwise” operation.

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 :


20

18

16

14

12
Amplitude

10

0
0 5 10 15 20 25 30 35
Time index n

6
Vrunda shah (IE)

Q1.15 The length of this sequence is =36


It is controlled by the following MATLAB command line : 0:35

It can be changed to generate sequences with different lengths as follows (give an example command line and
the corresponding length) :

For n= 0:19;

20

18

16

14

12
Amplitude

10

0
0 2 4 6 8 10 12 14 16 18 20
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 –
clf;
n=0:35; a=1.2; k=0.2;
x=k*a.^n;
b=0.9; c=20;
y=c*b.^n;
energy=sum(x.^2+y.^2)

energy =4.7777e+04

Project 1.3 Sinusoidal sequences

A copy of Program P1_4 is given below.


Answers:

7
Vrunda shah (IE)

% Program P1_4
% Generation of a sinusoidal sequence
n = 0:40; f = 0.1;
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;

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

Q1.18 The frequency of this sequence is – 0.1 cycles/samples


It is controlled by the following MATLAB command line : f=0.1;

A sequence with new frequency can be generated by the following command line :
f=0.5;
The parameter controlling the phase of this sequence is -phase

The parameter controlling the amplitude of this sequence is - A = 1.5;

The period of this sequence is – T= 10

Q1.19 The length of this sequence is - 41

8
Vrunda shah (IE)

It is controlled by the following MATLAB command line : n = 0:40;

A sequence with new length __21___ can be generated by the following command line :0:20;

Q1.20 The average power of the generated sinusoidal sequence is –

sum(x(1:10).*x(1:10))/10 = 1.1250

Q1.21 The purpose of axis command is – to set the range of x axis

The purpose of grid command is - to turn on the drawing of grid lines on the graph.
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 Q1_22A
% 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;
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 –

9
Vrunda shah (IE)

in Q1.17 that f = 0.1 Hz/sample. For the modified program in Q1.22, we have f = 0.9
Hz/sample, which generates the 0.1. Again because cosine is even, this makes a graph
thatsame graph as f = 0.9 – 1 = is identical to the one we got in Q1.17 with f = +0.1
Hz/sample.
A sinusoidal sequence of frequency 1.1 generated by modifying Program P1_4 is 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

A comparison of this new sequence with the one generated in Question Q1.17 shows -

A comparison of this new sequence with the one generated in Question Q1.17 shows - the
graph here is again identical to the one in Q1.17. This is because a cosine of frequency f =
1.1 Hz/sample is identical to one with frequency f = 1.1 – 1 = 0.1 Hz/sample, which was
the frequency used in Q1.17.
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 .

10
Vrunda shah (IE)

Sinusoidal Sequence
3

Amplitude
0

-1

-2

-3
0 5 10 15 20 25 30 35 40
Time index n

The period of this sequence is - = 1/f = 1/0.08 = 1/(8/100) = 100/8 = 25/2./ The period of this
sequence is - 2

Q1.24 By replacing the stem command in Program P1_4 with the plot 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

- instead of drawing stems


The difference between the new plot and the one generated in Question Q1.17 is
from the x-axis to the points on the curve, the “plot” command connects the points with
straight line segments, which approximates the graph of a continuous-time cosine signal.

Q1.25 By replacing the stem command in Program P1_4 with the stairs command the plot obtained is as shown
below:

11
Vrunda shah (IE)

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 those generated in Questions Q1.17 and Q1.24 is –

the “stairs” command produces a stairstep plot as opposed to the stem graph that was generated
in Q1.17 and the straight-line interpolation plot that was generated in Q1.24.

1.2 SIMPLE OPERATIONS ON SEQUENCES

Project 1.5 Signal Smoothing

Answers:

A copy of Program P1_5 is given below.


% Program P1_5
% Signal Smoothing by Averaging
clf; R = 51;
d = 0.8*(rand(R,1) - 0.5); % Generate random noise
m= 0:R-1;
s = 2*m.*(0.9.^m); % Generate uncorrupted signal
x = s + d'; % Generate noise corrupted signal
subplot(2,1,1);
plot(m,d','r-',m,s,'g--',m,x,'b-.');
xlabel('Time index n');ylabel('Amplitude');
legend('d[n] ','s[n] ','x[n] ');
x1 = [0 0 x];
x2 = [0 x 0];
x3 = [x 0 0];
y = (x1 + x2 + x3)/3;
subplot(2,1,2);
plot(m,y(2:R+1),'r-',m,s,'g--'); legend( 'y[n] ','s[n] ');
xlabel('Time index n');
ylabel('Amplitude');

12
Vrunda shah (IE)

Q1.29 The signals generated by running Program P1_5 are displayed below :

10
d[n]
Amplitude

5 s[n]
x[n]

-5
0 5 10 15 20 25 30 35 40 45 50
Time index n
8
y[n]
6
Amplitude

s[n]

0
0 5 10 15 20 25 30 35 40 45 50
Time index n

Q1.30 The uncorrupted signal s[n]is - a linear growth with a slowly decaying real exponential.

The additive noise d[n]is– a random sequence uniformly distributed between -0.4 and +0.4.

Q1.31 x = s + d CAN / CANNOT be used to generate the noise corrupted signal because - d is a
The statement
column vector, whereas s is a row vector; it is necessary to transpose one of these vectors
before adding them.

Q1.32 x1, x2, and x3, and the signal x are - all three signals x1, x2, and
The relations between the signals
x3 are extended versions of x, with one additional sample appended at the left and one
additional sample appended to the right. The signal x1 is a delayed version of x, shifted
one sample to the right with zero padding on the left. The signal x2 is equal to x, with
equal zero padding on both the left and right to account for the extended length. Finally,
x3 is a time advanced version of x, shifted one sample to the left with zero padding on the
right.

Q1.33 The purpose of the legend command is - to create a legend for the graphs.

1.3 GENERATION OF COMPLEX SEQUENCES

Project 1.6 Generation of Complex Signals

A copy of Program P1_6 is given below.


% Program P1_6
% Generation of amplitude modulated sequence
n = 0:300;
m = 1;
fH =0.1;
fL =0.005;

13
Vrunda shah (IE)

xH = sin(2*pi*fH*n);
xL = sin(2*pi*fL*n);
y = (1+m*xL).*xH;
figure;
stem(n,y);
grid;
xlabel('Time index n');
ylabel('Amplitude');

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

-2
0 50 100 150 200 250 300
Time index n

Q1.35 * and .* is - “*” multiplies two conformable matrices


The difference between the arithmetic operators
or vectors using matrix multiplication. “.*” takes the pointwise products of the elements
of two matrices or vectors that have the same dimensions.

Answers:

A copy of Program P1_7 is given below.


% Program P1_7
% Generation of a swept frequency sinusoidal sequence
n = 0:300;
a = pi/2/100;
b = 0;
arg = a*n.*n + b*n
x = cos(arg);
clf;
stem(n, x);
axis([0,300,-1.5,1.5]);
title('Swept-Frequency Sinusoidal Signal');
xlabel('Time index n');

14
Vrunda shah (IE)

ylabel('Amplitude');
grid;
axis;

Q1.36 The swept-frequency sinusoidal sequence x[n] generated by running Program P1_7 is displayed below .

Swept-Frequency Sinusoidal Signal


1.5

0.5
Amplitude

-0.5

-1

-1.5
0 50 100 150 200 250 300
Time index n

Q1.37 The minimum and maximum frequencies of this signal are - 0, 0.5 hz/samples

Q1.38 The Program P1_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 :

15
Vrunda shah (IE)

Swept-Frequency Sinusoidal Signal


0.3

0.28

0.26

0.24

0.22
Amplitude

0.2

0.18

0.16

0.14

0.12

0.1
0 50 100 150 200 250 300
Time index n

Date: Signature:

16

You might also like