Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
21 views48 pages

3EC4-23 Signal Processing Lab

The document outlines the syllabus for the Signal Processing Lab course at Techno India NJR Institute of Technology, detailing the experiments to be conducted using MATLAB and Scilab. It includes instructions, safety measures, and expected outcomes for each experiment, focusing on generating and analyzing continuous and discrete signals. The course aims to equip students with practical skills in signal processing and data analysis.

Uploaded by

Stanley
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)
21 views48 pages

3EC4-23 Signal Processing Lab

The document outlines the syllabus for the Signal Processing Lab course at Techno India NJR Institute of Technology, detailing the experiments to be conducted using MATLAB and Scilab. It includes instructions, safety measures, and expected outcomes for each experiment, focusing on generating and analyzing continuous and discrete signals. The course aims to equip students with practical skills in signal processing and data analysis.

Uploaded by

Stanley
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/ 48

Techno India NJR Institute of Technology

Department of Electronics & Communication Engineering

B.Tech. III Semester


Lab: Signal Processing Lab (3EC4-23)
RAJASTHAN TECHNICAL UNIVERSITY, KOTA
SYLLABUS
II Year - III Semester: B.Tech. (Electronics & Communication Engineering)
3EC4-23: Signal Processing Lab
1 Credit Max. Marks: 50 (IA:30, ETE:20)
0L:0T:2P
List of Experiments
Sr.
Name of Experiment (Simulate using MATLAB environment)
No.
Generation of continuous and discrete elementary signals (periodic and
1.
non periodic) using mathematical expression.
2. Generation of Continuous and Discrete Unit Step Signal.
Generation of Exponential and Ramp signals in Continuous & Discrete
3.
domain.
4. Continuous and discrete time Convolution (using basic definition).
Adding and subtracting two given signals. (Continuous as well as
5.
Discrete signals)
6. To generate uniform random numbers between (0, 1).
7. To generate a random binary wave.
To generate and verify random sequences with arbitrary distributions,
means and variances for following:
8. (a) Rayleigh distribution
(b) Normal distributions: N(0,1).
(c) Gaussion distributions: N (m, x)
To plot the probability density functions. Find mean and variance for
9.
the above distributions
Course Outcome:

Course
Course Course
Outcom Details
Code Name
e
CO 1 Able to generate different Continuous and
Signal Processing Lab

Discrete time signals.


CO 2 Understand the basics of signals and different
operations on signals.
CO 3 Develop simple algorithms for signal
processing and test them using MATLAB
3EC4-23

CO 4 Able to generate the random signals having


different distributions, mean and variance.
CO 5 Design and conduct experiments, interpret and
analyse data and report results.

Syllabus of 2nd Year B. Tech. (ECE) for students admitted in Session 2017-18 onwards Page 31
RAJASTHAN TECHNICAL UNIVERSITY, KOTA
SYLLABUS
II Year - III Semester: B.Tech. (Electronics & Communication Engineering)
CO-PO Mapping:
Subject

Course
PO PO PO PO PO PO PO PO PO PO PO PO
Outcom
1 2 3 4 5 6 7 8 9 10 11 12
es

2 1 2
Signal Processing

CO 1

CO 2 3 1
3EC4-23

Lab

CO 3 1 2 3 1 3

CO 4 2 1 1 2

CO 5 1 1 2 2 2

3: Strongly 2: Moderate 1: Weak

Syllabus of 2nd Year B. Tech. (ECE) for students admitted in Session 2017-18 onwards Page 32
Signal Processing LAB

INSTRUCTIONS OF LAB

DO’S

1. Student should get the record of previous experiment checked before starting the new
experiment.
2. Read the manual carefully before starting the experiment.
3. Before starting the experiment, system checked by the teacher.
4. Get your readings checked by the teacher.
5. Apparatus must be handled carefully.
6. Maintain strict discipline.
7. Keep your mobile phone switched off or in vibration mode.
8. Students should get the experiment allotted for next turn, before leaving the lab.

DON’TS

1. Do not touch or attempt to touch the mains power supply wire with bare hands.
2. Do not overcrowd the tables.
3. Do not tamper with equipments.
4. Do not leave the lab without permission from the teacher.

Department of ECE Page 11


Signal Processing LAB

Safety Measures of Lab

1. Antivirus software is installed for protection against viruses and malwares.


2. External storage devices are not allowed to use in lab.
3. At all times follow the right procedures while starting and shutting down the computer
therefore abrupt switching on and off the computer should be avoided since this can lead to
damaging the computer.
4. Any repairs to the computer should be done by someone who has knowledge regarding
computer repairs.

Department of ECE Page 12


Signal Processing LAB

EXPERIMENT No. 1
AIM: Write a program to generatefollowing continuous and discrete (periodic and
aperiodic) signal.
a) 𝒚(𝒕) = 𝒔𝒊𝒏(𝟐 ∗ 𝟑. 𝟏𝟒 ∗ 𝟓 ∗ 𝒕) + 𝒄𝒐𝒔(𝟐 ∗ 𝟑. 𝟏𝟒 ∗ 𝒕);
b) 𝒚(𝒏) = (−𝟏)𝒏
c) 𝒚(𝒕) = 𝒔𝒊𝒏√𝟐𝝅𝒕 + 𝒄𝒐𝒔𝝅𝒕
d) 𝒙(𝒏) = 𝒏𝟐 + 𝟒

SOFTWARE USED: Scilab 6.1.0.


THEORY:
Continuous and Discrete Time Signals:
A continuous signal or a continuous-time signal is a varying quantity (a signal) whose domain,
which is often time, is a continuum (e.g., a connected interval of the real). That is, the function's
domain is an uncountable set. The function itself need not be continuous. To contrast, a discrete
time signal has a countable domain, like the natural numbers.
A signal of continuous amplitude and time is known as a continuous-time signal or an analog
signal. This (a signal) will have some value at every instant of time. The electrical signals derived
in proportion with the physical quantities such as temperature, pressure, sound etc. are generally
continuous signals. Other examples of continuous signals are sine wave, cosine wave, triangular
wave etc.
The signal is defined over a domain, which may or may not be finite, and there is a functional
mapping from the domain to the value of the signal. The continuity of the time variable, in
connection with the law of density of real numbers, means that the signal value can be found at
any arbitrary point in time.

Fig 1.1 Continuous Time Signal

Signals that can be defined at discrete instant of time is called discrete time signal. Basically
discrete time signals can be obtained by sampling a continuous-time signal. It is denoted
as x(n).A discrete signal or discrete-time signal is a time series consisting of a sequence of quantities.
Unlike a continuous-time signal, a discrete-time signal is not a function of a continuous argument;
however, it may have been obtained by sampling from a continuous-time signal. When a discrete-

Department of ECE Page 13


Signal Processing LAB

time signal is obtained by sampling a sequence at uniformly spaced times, it has an


associated sampling rate.Discrete-time signals may have several origins, but can usually be
classified into one of two groups.

 By acquiring values of an analog signal at constant or variable rate. This process is


called sampling

Fig 1.2 Discrete Time Signal


Periodic and Non-periodic Signals:
A signal 𝑥(𝑡) is said to be periodic if it repeats itself after some amount of time
𝑥(𝑡 + 𝑛𝑇) = 𝑥(𝑡) (1.1)
here, T is time period of the periodic signal, n is any positive or negative integer. The period of
the signal is the minimum value of time for which it exactly repeats itself. The combination of the
periodic signals will be periodic if the ratio of the period of independent signals is rational number.
Fig 1.3 shows a periodic sine wave with period 𝑇 = 2𝜋.

Fig 1.3 Periodic Signal

A signal which does not repeat itself after a certain period of time is called Non-periodic signal.
Fig 1.4 shows a periodic sine wave with period 𝑇 = 2𝜋.

Department of ECE Page 14


Signal Processing LAB

Fig 1.4 Non-Periodic Signal

% SCILAB code
clear all;
clc;
clf;
t=0:0.01:5 ;
y=sin(2*3.14*5*t) + cos(2*3.14*t);
subplot(221)
plot(t,y);
xlabel('Time');
ylabel('Amplitude');
title('Continuous Periodic Signal');
n=0:1:10;
x=(-1).^n;
subplot(222)
plot2d3(n,x);
xlabel('Time');
ylabel('Amplitude');
title('Discrete Periodic Signal');
z=sin(sqrt(2)*3.14*t)+cos(3.14*t);
subplot(223)
plot(t,z);
xlabel('Time');
ylabel('Amplitude');
title('Continuous Non-Periodic Signal');
r=n.^2+4;
subplot(224)
plot2d3(n,r);
xlabel('Time');
ylabel('Amplitude');
title ('Discrete Non-periodic signal')

Department of ECE Page 15


Signal Processing LAB

OUTPUT:

Fig 1.5 Periodic and Non-Periodic Continuous and Discrete signal

RESULT:-We have successfully generated continuous periodic, discrete periodic, continuous


aperiodic and discrete aperiodic signals.Fig1.5 shows continuous time periodic signal of frequency
10 Hz. Fig 1.6 shows discrete time periodic signal of frequency 100 Hz. Fig 1.7 and fig 1.8 shows
continuous time signal and discrete time aperiodic signal.

DISCUSSION:
1. What is a signal.
2. Difference between continuous and discrete signal.
3. Commands difference between plot and stem function.
4. What is the difference between * and .* in MATLAB.
5. Determine which of the following signals are periodic.
1. 𝑥(𝑡) = 𝑠𝑖𝑛 15𝜋𝑡
2. 𝑥(𝑡) = sin √2 𝜋𝑡

Department of ECE Page 16


Signal Processing LAB

EXPERIMENT No. 2

AIM: Write a program to plot continuous and discrete unit step signals.
SOFTWARE USED: MATLAB 7.1

THEORY:
Unit Step : Unit step signal is defined as a signal with magnitude one for time greater and equal to
zero .
We can assume it as a dc signal which got switched on at time equal to zero. Unit step signal is a
basic signal and is denoted by u(t) in continuous domain or u(n ) in discrete domain.

Mathematically, it is defined as.


𝑢(𝑡) = 1, 𝑡 >= 0
0, 𝑡 < 0

Fig 2.1 Continuous time unit step signal

For Discrete time


𝑢(𝑛) = 1, 𝑛 >= 0
0, 𝑛 < 0

Department of ECE Page 17


Signal Processing LAB

Fig2.2 Discrete time unit step signal

SCILABCode for Continuous and Discrete Time unit step Signal:

clear all;
clc;
clf;
t = -10:.01:10;
ut = 1.*(t>=0);
subplot(2,1,1);
plot2d2(t,ut);
xlabel('time ');
ylabel('Amplitude');
title('Continuous time Unit Step Signal');
n = -8:1:8;
un = 1.*(n>=0);
subplot(2,1,2);
plot2d3(n,un);
xlabel('time ');
ylabel('Amplitude');
title('Discrete time Unit Step Signal');

OUTP
UT:

Department of ECE Page 18


Signal Processing LAB

Fig 2.3 Continuous time unit step signal

RESULT: We have generated the continuous and discrete unit step signals. The X axis and Y
axis denotes time and amplitude respectively. The unit step function value will be 1 for positive
value of time input and zero for negative value of time input. Fig 2.3 shows continuous time unit
step signal. Fig 2.4 shows discrete time unit step signal.

DISCUSSION:
1. What is the practical application of unit step function?
2. Differentiate between unit step and unit impulse function.
3. Draw y(t)= u(t+2)- u (t-2)
4. Draw y(t)= 2u(n+1) – u(n-1)

Department of ECE Page 19


Signal Processing LAB

EXPERIMENT No. 3

AIM: Write a program to generate Exponential and Ramp signals in Continuous & Discrete
domain.

SOFTWARE USED: MATLAB 7.1

THEORY: The “exponential” signal literally represents an exponentially increasing or falling


series:

Continuous time: 𝑦(𝑡) = 𝑐𝑒 𝑎𝑡

Discrete time: 𝑦(𝑛) = 𝑐𝑒 𝑎𝑛


where c and a are in general complex numbers.The exponential signal models the behavior of
many phenomena, such as the decay of electrical signals across a capacitor or inductor.

Fig 3.1 Continuous time exponential signal

Department of ECE Page 20


Signal Processing LAB

Fig 3.2 Discrete time exponential signal

The case a > 0 represents exponential growth. Some signals in unstable systems exhibit
exponential growth.
The case a < 0 represents exponential decay. Some signals in stable systems exhibit exponential
decay.
Ramp signal: A signal whose magnitude increases same as time. It can beobtained by integrating
unit step.
Continuous timer(t) = t, t >= 0
0, t<0

Fig 3.3 Continuous time ramp signal

Discrete time r(n) = n, n>= 0


0, n < 0

Fig 3.4 Discrete time ramp signal

Department of ECE Page 21


Signal Processing LAB

SCILAB Code for continuous time exponential signal


clear all;
clc;
clf;
t=0:.01:10;
y1=1*exp(1*t);
subplot(211);
plot(t,y1);
xlabel('Time');
ylabel('Amplitude');
title('Continuous Exponential Signal with scaling factor = 1 and
multiplication factor= 1');
y2=2*exp(-1*t);
subplot(212);
plot(t,y2);
xlabel('Time');
ylabel('Amplitude')
title('Continuous Exponential Signal with scaling factor = -1 and
multiplication factor= 2');

OUTPUT:

Department of ECE Page 22


Signal Processing LAB

Fig 3.5 Continuous time exponential signal

SCILAB code for discrete time exponential signal

clear all;
clc;
clf;
t=0:1:10;
y1=1*exp(1*t);
subplot(211);
plot2d3(t,y1);
xlabel('Time');
ylabel('Amplitude');
title('Discrete Exponential Signal with scaling factor = 1 and
multiplication factor= 1');
y2=2*exp(-1*t);
subplot(212);
plot2d3(t,y2);
xlabel('Time');
ylabel('Amplitude')

Department of ECE Page 23


Signal Processing LAB

title('Discrete Exponential Signal with scaling factor = -1 and


multiplication factor= 2');

OUTPUT:

Fig 3.6 Discrete time exponential signal

SCILAB Code for continuous time ramp Signal

clear all;
clc;
clf;
t=0:.01:10;
y1=t;
y2=-t*2;
subplot(211);
plot(t,y1);
xlabel('Time');
ylabel('Amplitude');
title('Continuous Ramp Signal with multiplication factor= 1');
subplot(212);
plot(t,y2);

Department of ECE Page 24


Signal Processing LAB

xlabel('Time');
ylabel('Amplitude');
title('Continuous Ramp Signal with multiplication factor= -2');

OUTPUT:

Fig 3.7 Continuous time ramp signal


SCILAB code for discrete time ramp signal
clear all;
clc;
clf;
t=0:1:10;
y1=t;
y2=-t*2;
subplot(211);
plot2d3(t,y1);
xlabel('Time');
ylabel('Amplitude');
title('Discrete Ramp Signal with multiplication factor= 1');
subplot(212);

Department of ECE Page 25


Signal Processing LAB

plot2d3(t,y2);
xlabel('Time');
ylabel('Amplitude');
title('Discrete Ramp Signal with multiplication factor= -2');

OUTPUT:

Fig. 3.8 Discrete time ramp signal

RESULT: We have plotted the continuous and discrete time exponential and ramp signals. The
X axis and Y axis denotes time and amplitude respectively. Multiplication factor affects the slope
of exponential and ramp signals as shown in various plots.Fig 3.5 shows continuous time
exponential signal Fig.3.6 shows discrete time exponential signal Fig.3.7 shows continuous time
ramp signal Fig.3.8 shows discrete time ramp signal

DISCUSSION:
1. Explain the role of multiplication factor in exponential and ramp signals.
2. What are the practical applications of exponential and ramp functions?
3. Difference between stable and unstable signal.
4. What is the meaning of exponential decay?

Department of ECE Page 26


Signal Processing LAB

EXPERIMENT No. 4

Department of ECE Page 27


Signal Processing LAB

AIM: To perform continuous and discrete time convolution

Problem Statement:
Suppose an input 𝑥(𝑡) = 𝑢(𝑡) – 𝑢(𝑡 − 1) is applied to a Linear Time Invariant (LTI) system
having impulse response ℎ(𝑡) = 𝑒𝑥𝑝 (𝑡) 𝑓𝑜𝑟 0 < 𝑡 < 4. Find the output of this system using
convolution

SOFTWARE USED: Scilab 6.1.0.


THEORY:

Convolution:
Convolution is defined as an operation which helps to find the output of the LTI (linear and time-
invariant) system when the impulse response of the system and the input signal are known.
(Impulse response is defined as behavior of system under unit impulse signal which is defined for
t=0 only)

(
a
)

(
b
Fig 4.1 LTI system with output represented as convolution
)
between input and impulse response
a) Continuous time system (b) discrete time system

If a continuous-time system is both linear and time-invariant, then the output Y(t) is related to the
input X(t) and impulse response (h(t)) of the system by the equation given below:
:

𝑌(𝑡) = 𝑋(𝑡) ∗ ℎ(𝑡) = ∫−∞ X(τ )h(t − τ )dτ (4.1)

Equation 4.1 is also known as convolution integral between X(t) and h(t)

Similarly, if a discrete-time system is both linear and time-invariant, then the output Y(n) is related
to the input X(n) and impulse response (h(n)) of the system by the equation mentioned below:
𝑌(𝑛) = 𝑋(𝑛) ∗ ℎ(𝑛) = ∑∞ 𝑘=−∞ X(k )h(n − k) (4.2)

Equation 4.2 is also known as convolution sum of X(n) and h(n)

% SCILAB code for continuous signal


clear all;
clc;

Department of ECE Page 28


Signal Processing LAB

clf;
t=-8:.01:8;
x=3*cos(2.*t);
h=exp(-abs(t));
y=convol(x,h);
//figure
subplot(3,1,1);
plot(t,h);
xlabel('time ');
ylabel('Amplitude');
title('Impulse response');
//figure
subplot(3,1,2);
plot(t,x);
xlabel('time ');
ylabel('Amplitude');
title('Input signal');
//figure
t2=-16:.01:16
subplot(3,1,3);
plot(t2,y);
xlabel('time ');
ylabel('Amplitude');
title('Convoluted Output signal');

OUTPUT:
enter the time range for input: -3:0.01:3;
enter range for impulse response:0:0.01:4;

Fig 4.2: a) input b) impulse response c) the convolved output

(
a
% SCILAB code for discrete time convolution )
(
c
)
(
Department of ECE b Page 29
)
Signal Processing LAB

clc;
clear all;
clf;
n1=0:1:12;
h=1.*(n1>=0);
n2=0:1:10;
x=exp((-1/4)*n2).*(n2>=0);
subplot(3,1,1);
plot2d3(n1,h);
xlabel('time');
ylabel('Amplitude');
title('Impulse Response');
subplot(3,1,2);
plot2d3(n2,x);
xlabel('time');
ylabel('Amplitude');
title('Input Signal');
T1=length(h);
T2=length(x);
c=convol(h,x);
t=0:1:T1+T2-2;
subplot(3,1,3);
plot2d3(t,c);
xlabel('time');
ylabel('Amplitude');
title('Convoluted Output');

OUTPUT:
enter the input: [2 3 4 5 2]
x = 2 3 4 5 2

enter the impulse response: [1 2 3 4 5]


h = 1 2 3 4 5

The convolved output is:


y = 2 7 16 30 46 50 46 33 10

Department of ECE Page 30


Signal Processing LAB

Fig 4.3: a) input b) impulse response c) the convolved output of the Discrete System

RESULT:
a. The output of continuous LTI System with x(t) = u(t) – u(t-1) and h(t) = exp (-t) for 0<t<2
is as shown in fig 4.2.
b. The output of discrete LTI System with x(n) = [2 3 4 5 2]and h(n) = [1 2 3 4 5]
is y = [2 7 16 30 46 50 46 33 10]and shown in fig 4.3.

DISCUSSION:
1. Differentiate between linear and circular convolution.
2. Determine the unit step response of the linear time invariant system with impulse
response ℎ(𝑛) = 𝑎𝑛 𝑢(𝑛) 𝑎 < 1
3. Determine the range of values of the parameter for which linear time
invariant system with impulse response ℎ(𝑛) = 𝑎𝑛 𝑢(𝑛) is stable.
4. Describe impulse response of a function and its importance.

Department of ECE Page 31


Signal Processing LAB

EXPERIMENT No. 5

AIM:Write a program to plot Adding and subtracting of two given signals using mathematical
expression.
SOFTWARE USED: Scilab 6.1.0.

THEORY:
 Addition or unary plus. A+B adds the values stored in variables A and B. A and B must have the
same size, unless one is a scalar. A scalar can be added to a matrix of any size.
 Subtraction or unary minus. A-B subtracts the value of B from A. A and B must have the same
size, unless one is a scalar. A scalar can be subtracted from a matrix of any size.

1. Addition

The addition of signals is very similar to traditional mathematics. That is, if x1(t) and x2(t) are the
two continuous time signals, then the addition of these two signals is expressed as x1(t) + x2(t).

The resultant signal can be represented as y(t) from which we can write

𝑦(𝑡) = 𝑥1 (𝑡) + 𝑥2 (𝑡)

Similarly for discrete time signals, x1[n] and x2[n], we can write

𝑦[𝑛] = 𝑥1 [𝑛] + 𝑥2 [𝑛]

2. Subtraction

Similar to the case of addition, subtraction deals with the subtraction of two or more signals in
order to obtain a new signal. Mathematically it can be represented as

𝑦(𝑡) = 𝑥1 (𝑡) − 𝑥2 (𝑡)

for continuous time signals, x1(t) and x2(t)

and 𝑦[𝑛] = 𝑥1 [𝑛] − 𝑥2 [𝑛]

for discrete time signals, x1[n] and x2[n]

% SCILAB code for Addition and Subtraction of two different signals

clc ;
clear all;
clf;

Department of ECE Page 32


Signal Processing LAB

t = -1:0.01:5;
x1 = 1;
x2 = 2;
x3 = 3- t ;
x = x1 .*( t >0 & t <1) + x2 .*( t >=1 & t <=2) + x1 .*( t >2& t
<3) ;
y = t .*( t >0 &t <1) + x1 *( t >=1 &t <=2) + x3 .*( t >2 &t <3) ;
add = x + y ;
sub = x - y ;
subplot(2,2,1);
plot(t,x);
xlabel('t') ;
ylabel('Amplitude') ;
title('input signal = x') ;
subplot(2,2,2);
plot(t,y)
xlabel('t') ;
ylabel('Amplitude') ;
title ('input signal = y') ;
subplot(2,2,3) ;
plot(t,add);
xlabel('t') ;
ylabel('Amplitude') ;
title('Addition of two signals') ;
subplot(2,2,4) ;
plot(t,sub);
xlabel('t') ;
ylabel('Amplitude') ;
title('Subtraction of two signals') ;

OUTPUT:
x = 1 2 3 4

y = 1 1 1 1

add = 1 2 4 5 1 1

sub = 1 2 2 3 -1 -1

Department of ECE Page 33


Signal Processing LAB

OUTPUT:

Fig 5.1 Discrete time signal for Addition and Subtraction

RESULT: -The output of continuous time signal for addition and subtraction shown in fig 5.1
and the output of discrete time signal for addition and subtraction with input sequence a=[1 2 3 4]
and b=[ 1 1 1 1] and result shown in fig. 5.1.

DISCUSSION:
1. How the discrete signals are important when compared to analog signals?
2. How digital signal processing is useful in communication systems?
3. Differentiate between analog signal processing and digital signal processing.

Department of ECE Page 34


Signal Processing LAB

EXPERIMENT No. 6

AIM: To generate uniform random numbers between (0, 1).

SOFTWARE USED: Scilab 6.1.0.

THEORY:
Random numbers are numbers that occur in a sequence such that two conditions are met:
The values are uniformly distributed over a defined interval or set.
It is impossible to predict future values based on past or present ones.
Random numbers are important in statistical analysis and probability theory.
rand() function is used to generate random numbers of required size.
r = rand(n) returns an n-by-n matrix containing pseudorandom values drawn from the standard
uniform distribution on the open interval (0,1).

%SCILAB Code for Random numbers generation in continuous and discrete manner
clc;
clf;
clear all;
t=0:1:9;
x=rand(1,10);
subplot(1,2,1);
plot(t,x);
xlabel('time');
ylabel('Amplitude');
title('continious random signal');
subplot(1,2,2);
plot2d3(t,x);
xlabel('time');
ylabel('Amplitude');
title('Discrete random signal');

OUTPUT:
Enter the total number which is generated N=10

Department of ECE Page 35


Signal Processing LAB

x=rand(1,10)
x= 0.5068534 0.5232976 0.5596948 0.5617307 0.468176 0.7794547 0.7901072
0.9808542 0.8187066

OUTPUT:

Fig 6.1 Continuous and discrete random numbers

Department of ECE Page 36


Signal Processing LAB

RESULT: Uniform random numbers between amplitude range 0-1 has been plotted. The
random number N which is to be generated is taken from user by using input() function. Then
random numbers are generated using rand() function. Continuous random numbers are plotted
using plot function and discrete number is plotted using stem function. The X-axis represents
random number and Y-axis represents amplitude of that random number.10 random numbers are
generated and saved in variable y and plot is shown in fig 6.1.

DISCUSSION:
1. How can we generate signed random numbers?
2. What is the use of random numbers in study of noise?
3. Generate random numbers between amplitude 0 to 3.
4. Generate ten binary random numbers.

Department of ECE Page 37


Signal Processing LAB

EXPERIMENT No. 7

AIM: To generate a random binary wave.

SOFTWARE USED:Scilab 6.1.0.

THEORY:
The term random signal is used primarily to denote signals, which have randomness in its
nature source. As an example we can mention the thermal noise, which is created by the
random movement of electrons in an electric conductor.
Random signals are those signals whose behavior cannot be predicted using any past
reference. Random binary signals are digital signals which are randomly generated. It is very
important for digital communication system.
A random binary signal is a random process that can assume one of two possible values
at any time. A simple method of generating a random binary signal is to take Gaussian white
noise, filter the noise for the desired spectra and then convert the noise to a binary signal by
taking the sign of the filtered signal. The desired spectra are functions of the system time
constraints.

Fig 7.1: Random Binary Waveform

%SCILAB code for random binary wave

clc;
clf;
clear all;
u=prbs_a(20,10)
plot2d2(1:20,u,rect=[0,-1.2,20,1.2]);
xlabel('time');
ylabel('Amplitude');
title('Random Binary Wave');

OUTPUT:
Random Binary Number is = 1. 1. -1. 1. -1. -1. -1. 1. -1. 1. 1. -1. 1. 1. 1.1. -1. -
1. -1. 1.

Department of ECE Page 38


Signal Processing LAB

Fig 7.2: Random Binary Wave Distribution

RESULT: A random binary wave has been plotted for 𝑙 = 10 random binary data as shown
in fig 7.2.

DISCUSSION:
1. What is the importance of random binary wave in communication system?
2. How can we generate random binary data without using randint() ?
3. How the phenomenon of random signals is quite useful in dealing with noise signals?

Department of ECE Page 39


Signal Processing LAB

EXPERIMENT No. 8

AIM: To generate and verify random sequences with arbitrary distributions, means and
variances for following:
(a) Rayleigh distributions
(b) Normal distributions: N (0,1).
(c) Gaussion distributions: N (m, x)

SOFTWARE USED: Scilab 6.1.0.

THEORY:
The term random signal is used primarily to denote signals, which have a randomness in its
nature source. As an example we can mention the thermal noise, which is created by the
random movement of electrons in an electric conductor.
Random signals are those signals whose behavior cannot be predicted using any past
reference.
Random signals are those that do not repeat with any definite sequence, but rather must be
described in terms of some probability. The characteristics of random signal are primarily
determined by its probability distribution function (PDF). There are many types of PDF
available to characterize the behavior of random signals as:
1. Gaussian distribution
2. Rayleigh distribution
3. Gamma distribution
4. Uniform Distribution
And many more……..

In this experiment we are mainly concerned about three types of distribution i.e.
1. Gaussian distribution
2. Rayleigh distribution
3. Normal distribution

Gaussian Distribution:
Gaussian distribution (also known as normal distribution) is a bell-shaped curve, and it is
assumed that during any measurement values will follow a normal distribution with an equal
number of measurements above and below the mean value.
The PDF of Gaussian distribution of random signal x is
1 (x − μ)2
( )
fx x = exp(− )
√2πσ2 2σ2
where σ2 : variance of the PDF, σ is the standard deviation, μ: mean of the PDF. The PDF of
Gaussian distribution is as shown in fig below

Department of ECE Page 40


Signal Processing LAB

Fig 8.1: PDF of Gaussian distributed signal

Communication noise is generally modeled with Gaussian distribution. Noise is assumed to


be AWGN (Additive White Gaussian Noise)

2. Normal Distribution:
Gaussian distribution with mean =0 and variance=1, is known to be standard normal
distribution. The PDF of normal distribution is:
1 (𝑥 )2
( )
𝑓𝑥 𝑥 = exp(− 2 )
√2𝜋 2𝜎
3. Rayleigh Distribution:
In probability theory and statistics, the Rayleigh distribution is a continuous probability
distribution for nonnegative-valued random variables. Wireless channel communication and
its related fading problem is generally characterized by Rayleigh distribution.
x (𝑥)2
𝑓𝑥 (𝑥 ) = 𝜎2 exp(− 2𝜎2 ); x>0

Fig 8.2: Rayleigh distribution

In MATLAB, there is a direct command to find distribution. For eg.normpdf(x,mean, var) is


used for gaussain distribution and raylpdf(x, r) is used for Rayleigh distribution.

Department of ECE Page 41


Signal Processing LAB

For Gaussian Distribution


clc;
clear all;
clf;
x=-4:.01:4;
sd=1.2;
m=1;
pdf=1/(sqrt(2*3.14*sd^2)).*exp(-((x-m)^2)/(2*sd^2));
plot(x,pdf);
xlabel('X');
ylabel('Amplitude');
title('Gaussian Distribution');

For Normal Distribution


clc;
clear all;
clf;
x=-4:.01:4;
sd=1;
m=0;
pdf=1/(sqrt(2*3.14*sd^2)).*exp(-((x-m)^2)/(2*sd^2));
plot(x,pdf);
xlabel('X');
ylabel('Amplitude');
title('Gaussian Distribution');

For Rayleigh Distribution


clc;
clear all;
clf;
x=0:.01:5;
sd=1;
r=(x/(sd^2)).*(exp(-(1/2)*(x/sd)^2));
plot(x,r);
xlabel('X');
ylabel('Amplitude');
title('Rayleigh Distribution');

OUTPUT:

Enter 1 for Gaussian distributon


Enter 2 for Normal distributon
Enter 3 for Rayleigh distributon
enter your choice: 1
enter Your sequence: -2:0.01:2
enter value of mean: 1
enter value of variance: 1

Department of ECE Page 42


Signal Processing LAB

"Do you want to continue press 1 else press 0": 1

Enter 1 for Gaussian distributon

Enter 2 for Normal distributon

Enter 3 for Rayleigh distributon

enter your choice4

"Do you want to continue press 1 else press 0"

Fig8.3: Gaussian Distribution with mean=1 and, variance=1

Fig8.4: Normal Distribution with mean=0 and, variance=1

Department of ECE Page 43


Signal Processing LAB

Fig 8.5: Rayleigh Distribution with mean=0 and, variance=1

RESULT:

The three different probability distribution functions of Gaussian, Normal and Rayleigh are
plotted in Fig 8.3,8.4 and 8.5 respectively

DISCUSSION:
1. Define AWGN and how its useful in communication system?
2. What does the variance of Gaussian distribution specify?
3. What does the mean of probability distribution function specify?
4. Which random data is modeled by Gaussian and Rayleigh probability distribution?

Department of ECE Page 44


Signal Processing LAB

EXPERIMENT No. 9

AIM: To plot the probability density functions (pdf). Find mean and variance for the above
distributions

PROBLEM STATEMENT: Find the pdf/ pmf (probability mass function) of the random
data of arbitrary length and find its mean and variance.

SOFTWARE USED: MATLAB 7.1.

THEORY:
In probability theory, a probability density function (PDF), or density of a continuous
random variable, is a function whose value at any given sample (or point) in the sample
space (the set of possible values taken by the random variable) can be interpreted as
providing a relative likelihood that the value of the random variable would equal that sample.
In a more precise sense, the PDF is used to specify the probability of the random
variable falling within a particular range of values, as opposed to taking on any one value.
This probability is given by the integral of this variable’s PDF over that range—that is, it is
given by the area under the density function
Let f(x) = the probability density function (p.d.f.) .
The total area under f(x) remains 1.

Thus two conditions for a function f(x) of a continuous variable x to be a valid probability
density function are:

f  x   0 x ----(9.1)

 f  x  dx

 1 ----(9.2)

Similarly, in probability and statistics, a probability mass function (PMF) is a function that
gives the probability that a discrete random variable is exactly equal to some value. The
probability mass function is often the primary means of defining a discrete probability
distribution, and such functions exist for either scalar or multivariate random
variables whose domain is discrete.

% MATLAB code for random no and its pdf


clc;
clear all;

Department of ECE Page 45


Signal Processing LAB

close all;
display('enter your chpoice for continous pdf or discrete
pmf')
display('Enter 1 for pdf');
display('Enter 2 for pmf');
ch=input('Enter');
switch(ch)
case 1
x=input('enter Your sequence');
r=input('enter value of rayleigh factor');
y=raylpdf(x,r);
plot(x,y);
xlabel('time');
ylabel('amplitude');
title('RAYLEIGH PDF');
display('mean of random data x is:');
m=mean(y)
display('variance of random data x is:');
v=var(y)
case 2

n=input('number of random data required:');


x=n*rand(1,n);
stem(1:n,x)
xlabelx
ylabelpmf/pdf
title 'pmf/pdf of discrete signal x'
display('mean of random data x is:');
m=mean(x)
display('variance of random data x is:');
v=var(x)
otherwise
display('Invalid choice');
end

OUTPUT:
enter your chpoice for continous pdf or discrete pmf
Enter 1 for pdf
Enter 2 for pmf
Enter1
enter Your sequence0:0.01:3
enter value of rayleigh factor1
mean of random data x is:
m =0.3286

variance of random data x is:


Department of ECE Page 46
Signal Processing LAB

v =0.0393

Fig 9.1 PMF/PDF of random data


enter your chpoice for continous pdf or discrete pmf
Enter 1 for pdf
Enter 2 for pmf
Enter2
number of random data required:10
mean of random data x is:
m =5.8731
variance of random data x is:
v =8.6137

Fig 9.2: PMF of random data

Department of ECE Page 47


Signal Processing LAB

RESULT: The pdf of Rayleigh distribution is as shown in fig 9.1 and mean and variance of
above distribution is 0.3286 and 0.0393 respectively. The PMF of the random data of length
(10) is displayed in fig 9.2 and its mean and variance is 5.8731and 8.6137respectively.

DISCUSSION:
1. What is the importance of random signals in Electronics & communication
Engineering?
2. What is the role of AWGN in digital communication system?
3. Which signal is modeled by Rayleigh Distribution?

Department of ECE Page 48


Signal Processing LAB

EXPERIMENT No. B1

AIM: To design a LTI system with specific input and specific output
PROBLEM STATEMENT: Design a LTI system whose input is unit impulse signal and
output is (𝑒 −2𝑡 − 𝑒 −3𝑡 )𝑢(𝑡). (where u(t) is unit step). Also obtain the magnitude and phase
spectrum.

SOFTWARE USED: MATLAB 7.1.

THEORY:
LTI system is Linear and Time-Invariant system whose output is the convolution integral of
input and impulse response of the system.
Convolution is defined as an operation which helps to find the output of the LTI (linear and
time-invariant) system when the impulse response of the system and the input signal are
known. (Impulse response is defined as behavior of system under unit impulse signal which is
defined for t=0 only)

Fig 11.1 LTI system with output represented as convolution between input and
impulse response

If a continuous-time system is both linear and time-invariant, then the output y(t) is related to
the input x(t) and impulse response (h(t)) of the system by the equation given below::

𝑦(𝑡) = 𝑥 (𝑡) ∗ ℎ(𝑡) = ∫−∞ x(τ )h(t − τ )dτ (10.1)

Equation 10.1 is also known as convolution integral between x(t) and h(t).
𝑌(𝑠) = 𝑋(𝑠)𝐻(𝑠)

Where Y(s), H(s) and X(s) are the Laplace transformation of y(t), h(t) and x(t)

Designing Step:

Let input to the system is x(t)and output to the system is y(t)


𝑥(𝑡) = 𝛿(𝑡)

𝑦(𝑡) = (𝑒 −2𝑡 − 𝑒 −3𝑡 )𝑢(𝑡)

𝑦(𝑡) = 𝑥(𝑡) ∗ ℎ(𝑡)

Department of ECE Page 49


Signal Processing LAB

Taking Laplace Transform


𝑌(𝑠) = 𝑋(𝑠)𝐻(𝑠)

𝐻(𝑠) = 𝑌(𝑠)/𝑋(𝑠)

𝑦(𝑡) = (𝑒 −2𝑡 − 𝑒 −3𝑡 )𝑢(𝑡)


1 1
So, 𝑌(𝑠) = 𝑠+2 − 𝑠+3

𝑥(𝑡) = 𝛿(𝑡),

So, X(s)=1

1 1
𝐻 (𝑠 ) = −
𝑠+2 𝑠+3
1 1
Or 𝐻 (𝑠) = (𝑠+2)(𝑠+3) = 𝑠 2+5𝑠+6

%MATLAB code for to design LTI system:


clear all;
clc;
close all;
a = [1 5 6];
b = [1];
w = logspace(-1,1);
h = freqs(b,a,w);
mag = abs(h);
phase = angle(h);
phasedeg = phase*180/pi;
subplot(2,1,1)
loglog(w,mag)
grid on
xlabel'Frequency (rad/s)'
ylabel ‘Magnitude’
subplot(2,1,2),
semilogx(w,phasedeg)
grid on

Department of ECE Page 50


Signal Processing LAB

xlabel'Frequency (rad/s)',
ylabel'Phase (degrees)'
Output

Fig 10.1: Magnitude and Phase response of LTI system with given input and output.

RESULT:The system response of the system with specified input (impulse response) and
output (𝑒 −2𝑡 − 𝑒 −3𝑡 )𝑢(𝑡).)is________________ and its phase and magnitude response is
plotted as shown in Fig 10.1

DISCUSSION:
1. Explain the LTI system and its importance in communication system.
2. Explain the principle of convolution and why it’s important in LTI system.
3. How Laplace transformation is is different from Fourier Transform?
4. Explain the drichlet’s condition for Fourier Transform.

Department of ECE Page 51


Signal Processing LAB

EXPERIMENT No-B2

AIM:Sampling and Reconstruction of a given signal.

SOFTWARE USED:Scilab 6.1.0.

THEORY:
Theory:The sampling is extremely important and useful in signal processing and digital
communication. The sampling process is usually described in the time domain. With the help
of sampling process, a continuous time signal may be completely represented and recovered
from the knowledge of samples taken uniformly.
A continuous time signal is first converted to discrete time signal by sampling process. The
sufficient number of samples of the signal must be taken so that the original signal is
represented in its samples completely. Also, it should be possible to recover or reconstruct the
original signal completely from its samples.

Sampling Theorem Statement: A continuous time signal may be completely represented in


its samples and recovered back if the sampling frequency is fs>=2fm. Here fs is the sampling
frequency and fm is the maximum frequency present in the signal.

The output sample signal is represented by the samples. These samples are maintained with a
gap, these gaps are termed as sample period or sampling interval (Ts). And the reciprocal of
the sampling period is known as “sampling frequency” or “sampling rate”. The number of
samples is represented in the sampled signal is indicated by the sampling rate.

Consider a continuous time signal x(t) whose spectrum is band limited to fm Hz. Sampling of
x(t) at a rate of fs Hz (Fs samples per second) may be achieved by multiplying x(t) by an
impulse train. Therefore it is called as ideal sampling.
The impulse train consists of unit impulse repeating periodically every T s seconds, where Ts =
1/fs.
The sampled signal may be written as
𝑔(𝑡) = 𝑥(𝑛𝑇𝑠 ) = 𝑥(𝑡). 𝛿𝑇𝑠 (𝑡)
The sampled signal in frequency domain is represented as

1
𝐺 (𝜔 ) = ∑ 𝑋(𝜔 − 𝑛𝜔𝑠 )
𝑇𝑠
𝑛=−∞
The spectrum 𝐺 (𝜔) consist of 𝑋(𝜔) repeating periodically with period 𝜔𝑠 , where

2𝜋 1
𝜔𝑠 = 𝑟𝑎𝑑/ sec 𝑜𝑟𝑓𝑠 = 𝐻𝑧
𝑇𝑠 𝑇𝑠

Department of ECE Page 52


Signal Processing LAB

Fig. 10.1 Sampling Process

When the sampling rate exactly equal to 2fm samples per second, then it is called Nyquist
rate.Nyquist rate is also called the minimum sampling rate.
fs = 2fm Hz
Similarly, maximum sampling interval is called Nyquist interval
Ts = 1/(2fm) Seconds
Signal Reconstruction: The process of reconstructing a continuous time signal x(t) from its
samples is known as interpolation.Interpolation gives either approximate or exact recovery of
the continuous time signal.
A signal x(t) band limited to fm Hz can be reconstructed (interpolated) completely from its
samples, by passing the sampled signal through an ideal low pass filter of cut-off frequency
fm Hz.
Therefore the filter output to g(t), which is x(t), may be expressed as

𝑥𝑟 (𝑡) = 𝑥(𝑡) = ∑ 𝑥(𝑛𝑇𝑠 )𝑠𝑖𝑛𝑐(𝑓𝑠 (𝑡 − 𝑛𝑇𝑠 ))


𝑛=−∞
This is known as interpolation formula, which provides values of x(t) between samples as a
weighted sum of all the sample values.

Fig. 10.2: Signal Reconstruction

Department of ECE Page 53


Signal Processing LAB

% SCILAB code for sampling and reconstruction

clear;
clc;
close;
// Analog Signal
A =1; //Amplitude
Dt = 0.005;
t = -2:Dt:2;
//Continuous Time Signal
x = sin(2*t);
//Discrete Time Signal
Fs =input('Enter the Sampling Frequency in Hertz');//Fs =
1Hz,2Hz,4Hz,20Hz,100Hz
Ts = 1/Fs;
nTs = -2:Ts:2;
xs = sin(2*nTs);
// Analog Signal reconstruction
Dt = 0.005;
t = -2:Dt:2;
xr = xs *sinc(Fs*(ones(length(nTs),1)*t-
nTs'*ones(1,length(t))));
//Plotting the original signal and reconstructed signal
subplot(3,1,1);
plot(t,x);
xlabel('time');
ylabel('amplitude');
title('Message Signal');
subplot(3,1,2);
plot2d3(nTs,xs);
xlabel('time');
ylabel('amplitude');
title('Sampled Signal');
subplot(3,1,3);
plot(t,xr);
xlabel('time');
ylabel('amplitude');
title('Reconstructed Signal');

Department of ECE Page 54


Signal Processing LAB

OUTPUT:

Fig 10.3: Message signal, Sampled signal (with sampling frequency 5Hz) and
Reconstructed Signal

RESULT:Message signal, sampled signal and reconstructed signal is shown in figure 10.3
and the sampling frequency is 5 Hz. Figure shows that message signal is reconstructed at
receivers end using interpolation if sampling frequency is fs>2fm.

DISCUSSION:
Q 1. Explain aliasing effect?
Q 2. Define Nyquist rate and Nyquist interval.
Q 3. Explain demerits of Ideal sampling.
Q 4. What is aperture effect?

Department of ECE Page 55

You might also like