0% found this document useful (0 votes)
48 views15 pages

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

1) The document discusses generating and representing discrete-time signals in the time domain. It includes programs to generate unit sample sequences, unit step sequences, exponential sequences, and sinusoidal sequences. 2) The programs generate these basic discrete-time sequences by creating arrays with the appropriate values at each time index and plotting the results. Key parameters like amplitude, growth/decay rates, phase, and frequency can be adjusted. 3) MATLAB commands like stem, subplot, axis, title, xlabel, and ylabel are used to plot the sequences and label the graphs. Operations like real, imag, and sum are used to extract specific components of the signals and calculate their energies.

Uploaded by

Naveen Chandra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views15 pages

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

1) The document discusses generating and representing discrete-time signals in the time domain. It includes programs to generate unit sample sequences, unit step sequences, exponential sequences, and sinusoidal sequences. 2) The programs generate these basic discrete-time sequences by creating arrays with the appropriate values at each time index and plotting the results. Key parameters like amplitude, growth/decay rates, phase, and frequency can be adjusted. 3) MATLAB commands like stem, subplot, axis, title, xlabel, and ylabel are used to plot the sequences and label the graphs. Operations like real, imag, and sum are used to extract specific components of the signals and calculate their energies.

Uploaded by

Naveen Chandra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Laboratory Exercise 1

DISCRETE-TIME SIGNALS: TIME-DOMAIN REPRESENTATION

1.1 GENERATION OF SEQUENCES

Project 1.1 Unit sample and unit step sequences

A copy of Program P1_1 is given below.

%UNIT SAMPLE
clf;
n=-15:15;
x=[zeros(1,15) 1 zeros(1,15)];% create array of zeros
stem(n,x); %plot discrete sequence data
xlabel('time');%label x axis
ylabel('amplitude');%label y axis;
title('unit sample sequence');% title of the plot
axis([-15 15 0 1]);% set min & max limits for X, Y axis
grid on;% make gridlines on graph

Answers:

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

unit sample sequence


1

0.9

0.8

0.7

0.6
amplitude

0.5

0.4

0.3

0.2

0.1

0
-15 -10 -5 0 5 10 15
time
Q1.2 The purpose of clf command is – to clear figure window

The purpose of axis command is –to give minimum and maximum limits of X and Y axis

The purpose of title command is –to give the title name of plot

The purpose of xlabel command is –to give name to X axis

The purpose of ylabel command is –to give name to Y axis.

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.

%UNIT SAMPLE SEQUNCE DEALYED BY 11 SAMPLES


clf;
n=-15:15;
x=[zeros(1,26) 1 zeros(1,4)];% create array of zeros
stem(n,x); %plot discrete sequence data
xlabel('time');%label x axis
ylabel('amplitude');%label y axis;
title('unit delay sample sequence u[n-11]');% title of the plot
axis([-15 15 0 1]);% set min & max limits for X, Y axis
grid on;% make gridlines on graph

unit delay sample sequence u[n-11]


1

0.9

0.8

0.7

0.6
amplitude

0.5

0.4

0.3

0.2

0.1

0
-15 -10 -5 0 5 10 15
time
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.

clf;
n=-15:15;
x=[zeros(1,15) 1 ones(1,15)];% create array of zeros and ones
stem(n,x); %plot discrete sequence data
xlabel('time');%label x axis
ylabel('amplitude');%label y axis;
title('unit step sequnce');% title of the plot
axis([-15 15 0 1]);% set min & max limits for X, Y axis
grid on;% make gridlines on graph

unit step sequnce


1

0.9

0.8

0.7

0.6
amplitude

0.5

0.4

0.3

0.2

0.1

0
-15 -10 -5 0 5 10 15
time

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.

clf;
n=-15:15;
x=[zeros(1,8) 1 ones(1,22)];% create array of zeros and ones
stem(n,x); %plot discrete sequence data
xlabel('time');%label x axis
ylabel('amplitude');%label y axis;
title('unit step sequnce delayed by 7 samples');% title of the plot
axis([-15 15 0 1]);% set min & max limits for X, Y axis
grid on;% make gridlines on graph
unit step sequnce delayed by 7 samples
1

0.9

0.8

0.7

0.6
amplitude

0.5

0.4

0.3

0.2

0.1

0
-15 -10 -5 0 5 10 15
time

Project 1.2 Exponential signals


A copy of Programs P1_2 and P1_3 are given below.
%complex-valued exponential sequence
clf;
c = -(1/12)+(pi/6)*i;
K = 2;
n = 0:40;
x = K*exp(c*n);% compex valued exponnetial signal
subplot(2,1,1);% add subplots to a figure
stem(n,real(x));% plot sequence of real part of x vs n
xlabel('Time index n');ylabel('Amplitude');
title('Real part');
subplot(2,1,2);
stem(n,imag(x));%plot sequence of imaginary part of x vs n
xlabel('Time index n');ylabel('Amplitude');
title('Imaginary part');

% Program P1_3
clf;
n = 0:35; a = 1.2; K = 0.2;
x = K*a.^n;
stem(n,x);
xlabel('Time index n');ylabel('Amplitude');

Answers:

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

1
Amplitude
0

-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

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 – graph is reversed

Q1.9 The purpose of the operator real is – to plot real value of X

The purpose of the operator imag is –to plot the imag value of X

Q1.10 The purpose of the command subplot is – to plot 2 or more graphs in one graph

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

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

The parameter controlling the amplitude of this sequence is - x

Q1.13 The difference between the arithmetic operators ^ and .^ is –

^ - one scalar and one matrix

.^- both must be same size of matrix

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

Q1.15 The length of this sequence is - 35


It is controlled by the following MATLAB command line: n = 0:40;
It can be changed to generate sequences with different lengths as follows (give an example
command line and the corresponding length): for length=100, command line- n=0:99;

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 -
Project 1.3 Sinusoidal sequences

A copy of Program P1_4 is given below.

n = 0:40; f = 0.1;
phase = 0; A = 1.5;
arg = 2*pi*f*n - phase; x = A*cos(arg);
clf;
stem(n,x);
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

Q1.18 The frequency of this sequence is – 0.1


It is controlled by the following MATLAB command line: arg = 2*pi*f*n-phase
A sequence with new frequency __f=0.2___ can be generated by the following command
line: f=0.2
arg = 2*pi*f*n-phase
x = A*cos(arg);
The parameter controlling the phase of this sequence is - arg = 2*pi*f*n-phase
The parameter controlling the amplitude of this sequence is - A
The period of this sequence is -10
Q1.19 The length of this sequence is – 41
It is controlled by the following MATLAB command line: n = 0:40;
A sequence with new length ___51__ can be generated by the following command line: n =
0:50;
Q1.20 The average power of the generated sinusoidal sequence is - 0
Q1.21 The purpose of axis command is – to set minimum and maximum X & Y axis limits
The purpose of grid command is – to make grid lines on 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.
n = 0:40; f = 0.9;
phase = 0; A = 1.5;
arg = 2*pi*f*n - phase; x = A*cos(arg);
clf;
stem(n,x);
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 – no
change in graph
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 – no
changes.
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.
The period of this sequence is -12.5

Sinusoidal Sequence
2

1.5

0.5
Amplitude

-0.5

-1

-1.5

-2
0 5 10 15 20 25 30 35 40 45 50
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:

Sinusoidal plot
3

1
Amplitude

-1

-2

-3
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 –
The new one is in the continuous function of time while other one is in discrete
sequence.
Q1.25 By replacing the stem command in Program P1_4 with the stairs command the
plot obtained is as shown below:
Sinusoidal plot
3

1
Amplitude

-1

-2

-3
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 new one is stairstep graph and other is a discrete sequence graph.

1.2 SIMPLE OPERATIONS ON SEQUENCES


Project 1.5 Signal Smoothing
A copy of Program P1_5 is given below.
clc;
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-.');%plot with differnet colours
xlabel('Time index n');
ylabel('Amplitude');
legend('d[n] ','s[n] ','x[n] ');%descriptive label for each data
seies
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');

Answers:
Q1.29 The signals generated by running Program P1_5 are displayed below:
Q1.30 The uncorrupted signal s[n]is - s = 2*m.*(0.9.^m)

The additive noise d[n]is - d = 0.8*(rand(R,1) - 0.5)


Q1.31 The statement x = s + d CAN / CANNOT be used to generate the noise corrupted
signal because– it will generate large number of noise corrupted signal instead of one
corrupted signal.
Q1.32 The relations between the signals x1, x2, and x3, and the signal x are – x is an element
of x1,x2 and x3 matrices.
Q1.33 The purpose of the legend command is –to give descriptive label for each data.
1.3 GENERATION OF COMPLEX SEQUENCES
Project 1.6 Generation of Complex Signals
A copy of Program P1_6 is given below.

% Generation of amplitude modulated sequence


n = 0:300;
m = 1;% modulating index
fH =0.1;
fL =0.005;
xH = sin(2*pi*fH*n);%carrier signal
xL = sin(2*pi*fL*n);%modulating signal
y = (1+m*xL).*xH;% matrix multiplication ant then element wise
multiplication
figure;
stem(n,y);%plot discrete sequence data
grid;
xlabel('Time index n');
ylabel('Amplitude');

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:

Q1.35 The difference between the arithmetic operators * and .* is -

* - matrix multiplication
.* - element wise matrix multiplication
Generation of a swept frequency sinusoidal sequence

A copy of Program P1_7 is given below.


% 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); %plot discrete sequence data
axis([0,300,-1.5,1.5]);%set axis limits
title('Swept-Frequency Sinusoidal Signal');
xlabel('Time index n');
ylabel('Amplitude');
grid;

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

Q1.37 The minimum and maximum frequencies of this signal are = 0 and 0.025 Hz

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:

% Generation of a swept frequency sinusoidal sequence


n = 0:300;
a = pi/2/100;
b = pi/2/0.1;
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');
ylabel('Amplitude');
grid;
axis;

Date: Signature:

You might also like