0% found this document useful (0 votes)
55 views138 pages

Basic SImulation Lab

Uploaded by

vinayyanjala
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)
55 views138 pages

Basic SImulation Lab

Uploaded by

vinayyanjala
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/ 138

BKM

Basic Simulation Lab Manual


1

Basic
Simulation Lab
Manual 2022
Basic Simulation Lab with MATLAB Written for under
graduate students in the fields of electronics and
communication, this Manual is meant to supplement the
theoretical concepts taught in an introductory course on
A Guide to
signals and systems. Each Simulation contains all the Student for BS
theoretical background information needed for the LAB
simulations as well as the required MATLAB code. Topics
include an introduction to vectors and matrices, operations
on signals and sequences, and the Fourier transform etc.

Department of Electronics and Communication Engineering Page 1


BKM

Basic Simulation Lab Manual


2

LABORATORY MANUAL
BASIC SIMULATION
II B. TECH -I Semester (ECE-R22)

J. B. Institute of Engineering & Technology


(UGC Autonomous)
Accredited by NAAC & NBA, approved by AICTE & Permanently Affiliated to JNTUH
Department of Electronics & Communication Engineering

Department of Electronics and Communication Engineering Page 2


BKM

Basic Simulation Lab Manual


3
DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING

VISION AND MISSION


VISION
 To be a guiding force enabling multifarious applications in Electronics and
Communications Engineering, promote innovative research in the latest
technologies to meet societal needs
MISSION
 To provide and strengthen core competencies among the students through
expert training and industry interaction.
 To promote advanced designing and modeling skills to sustain technical
development and lifelong learning in ECE.
 To promote social responsibility and ethical values, within and outside the
department.

PEO'S, PO'S & PSOS

Program Educational Objectives (PEOs):

PEO 1 Practice Technical skills widely in industrial, societal and real time
applications.
PEO 2 Engage in the pursuit of higher education, delve into extensive research
and development endeavours, and explore creative and innovative
ventures in the domains of science, engineering, technology.

PEO 3 Exhibit professional ethics and moral values and capability of working
with professional skills to contribute towards the need of industry and
society.

Department of Electronics and Communication Engineering Page 3


BKM

Basic Simulation Lab Manual


4

PROGRAM OUTCOMES (POs)

Engineering Graduates will be able to:

1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering


fundamentals, and an engineering specialization to the solution of complex engineering
problems.

2. Problem analysis: Identify, formulate, review research literature, and analyze complex
engineering problems reaching substantiated conclusions using first principles of
mathematics, natural sciences, and engineering sciences.

3. Design/development of solutions: Design solutions for complex engineering problems


and design system components or processes that meet the specified needs with
appropriate consideration for the public health and safety, and the cultural, societal, and
environmental considerations.

4. Conduct investigations of complex problems: Use research-based knowledge and


research methods including design of experiments, analysis and interpretation of data,
and synthesis of the information to provide valid conclusions.

5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and
modern engineering and IT tools including prediction and modeling to complex
engineering activities with an understanding of the limitations.

6. The engineer and society: Apply reasoning informed by the contextual knowledge to
assess societal, health, safety, legal and cultural issues and the consequent responsibilities
relevant to the professional engineering practice.

7. Environment and sustainability: Understand the impact of the professional engineering


solutions in societal and environmental contexts, and demonstrate the knowledge of, and
need for sustainable development.

8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and
norms of engineering practice.

9. Individual and teamwork: Function effectively as an individual, and as a member or


leader in diverse teams, and in multidisciplinary settings.

10. Communication: Communicate effectively on complex engineering activities with the


engineering community and with society at large, such as, being able to comprehend and
write effective reports and design documentation, make effective presentations, and give
and receive clear instructions.

Department of Electronics and Communication Engineering Page 4


BKM

Basic Simulation Lab Manual


5

11. Project management and finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one’s own work, as a member
and leader in a team, to manage projects and in multidisciplinary environments.

12. Life-long learning: Recognize the need for and have the preparation and ability to engage
in independent and life-long learning in the broadest context of technological change.

Program Specific Outcomes (PSOs):

PSO 1 Carry out the Analysis and Design different Analog & Digital circuits
with given specifications.

PSO 2 Construct and test different communication systems for various


applications.

Department of Electronics and Communication Engineering Page 5


BKM

Basic Simulation Lab Manual


6
INSTRUCTIONS TO THE STUDENTS

1. Students are required to attend all labs.

2. Students will work individually in hardware laboratories and in computer laboratories.

3. While coming to the lab bring the lab manual cum observation book, record etc.

4. Take only the lab manual, calculator (if needed) and a pen or pencil to the work area.

5. Before coming to the lab, prepare the prelab questions. Read through the lab
experiment to familiarize yourself with the components and assembly sequence.

6. Utilize 2 hours time properly to perform the experiment (both in software and
hardware) and note down the readings properly. Do the calculations, draw the graph
and take signature from the instructor.

7. If the experiment is not completed in the prescribed time, the pending work has tobe
done in the leisure hour or extended hours.

8. You have to submit the completed record book according to the deadlines set up by
your instructor.

9. For practical subjects there shall be a continuous evaluation during the semester for 30
sessional marks and 70 end examination marks.

10. Of the 30 marks for internal, 20 marks shall be awarded for day-to-day work and 10
marks to be awarded by conducting an internal laboratory test.

Department of Electronics and Communication Engineering Page 6


BKM

Basic Simulation Lab Manual


7
INDEX
SL.NO. EXPERIMENT NAME PAGENO.

1 Basic Operations on Matrices. 8

2 Generation of Various Signals and Sequences (Periodic and Aperiodic),


such as Unit impulse, unit step, square, saw tooth, triangular, sinusoidal, 14
ramp, sinc.
3 Observations on signals and sequences such as addition,
multiplication,scaling, shifting, folding, computation of energy and 31
average power.
4 Finding the even and odd parts of signal/ sequence and real and 41
imaginaryparts of signal.
5 Convolution between signals and sequences.
49
6 Autocorrelation and cross correlation between signals and sequences. 56

7 Verification of linearity and time invariance properties of a given 66


continuous /discrete system.

8 Computation of unit samples, unit step and sinusoidal response of the 74


givenLTI system and verifying its physical realiazability and stability
properties.
9 Gibbs phenomenon. 79

10 Finding the Fourier transform of a given signal and plotting its 84


magnitudeand Phase spectrum.
11 Waveform synthesis using Laplace Transform. 91

12 Checking a random process for stationary in wide sense. 95

13 Generation of Gaussian noise (real and complex), computation of its


mean, M.S. Value and its Skew, Kurtosis, and PSD, Probability 100
DistributionFunction.

14 Sampling theorem verification. 109


15 Removal of noise by autocorrelation / cross correlation. 117
16 Extraction of periodic signal masked by noise using correlation 123

17 Verification of winer- khinchine relations. 128


18 Locating the zeros and poles and plotting the pole-zero maps in S plane 134
and Z-plane for the given transfer function (Experiment beyond syllabus)

Department of Electronics and Communication Engineering Page 7


BKM

Basic Simulation Lab Manual


EXPERMENT NO:1 8
BASIC OPERATIONS ON MATRICES

AIM: - To write a MATLAB program to perform some basic operation on matrices such as addition,
subtraction, multiplication.

SOFTWARE REQURIED: -

1.MATLAB R2010a.
2.Windows XP SP2.

THEORY: -

MATLAB, which stands for MATRIX Laboratory, is a state-of-the-art mathematical software


package, which is used extensively in both academia and industry. It is an interactive program
for numerical computation and data visualization, which along with its programming
capabilities provides a very useful tool for almost all areas of science and engineering. Unlike
other mathematical packages, such as MAPLE or MATHEMATICA, MATLAB cannot perform
symbolic manipulations without the use of additional Toolboxes. It remains however, one of the
leading software packages for numerical computation.
As you might guess from its name, MATLAB deals mainly with matrices. A scalar is a 1-by-1
matrix and a row vector of length say 5, is a 1-by-5 matrix.. One of the many advantages of
MATLAB is the natural notation used. It looks a lot like the notation that you encounter in a
linear algebra. This makes the use of the program especially easy and it is whatmakes MATLAB a
natural choice for numerical computations. The purpose of this experiment is to familiarize
MATLAB, by introducing the basic features and commands of the program.

Built in Functions:
1. Scalar Functions:
Certain MATLAB functions are essentially used on scalars, but operate element-wise
whenapplied to a matrix (or vector). They are summarized below.
1. sin - trigonometric sine
2. cos - trigonometric cosine
3. tan - trigonometric tangent
4. asin - trigonometric inverse sine (arcsine)
5. acos - trigonometric inverse cosine (arccosine)
6. atan - trigonometric inverse tangent (arctangent)
7. exp - exponential
8. log - natural logarithm
9. abs - absolute value

Department of Electronics and Communication Engineering Page 8


BKM

Basic Simulation Lab Manual


10. sqrt - square root
9
11. rem - remainder
12. round - round towards nearest integer
13. floor - round towards negative infinity
14. ceil - round towards positive infinity

2. Vector Functions:

Other MATLAB functions operate essentially on vectors returning a scalar value.


Some ofthese functions are given below.
1. max largest component : get the row in which the maximum element lies
2. min smallest component
3. length length of a vector
4. sort sort in ascending order
5. sum sum of elements
6. prod product of elements
7. median median value
8. mean mean value std standard deviation

3. Matrix Functions:

Much of MATLAB‟ s power comes from its matrix functions. These can be further
separatedinto two sub-categories.
The first one consists of convenient matrix building functions, some of which are
givenbelow.
1. eye - identity matrix
2. zeros - matrix of zeros
3. ones - matrix of ones
4. diag - extract diagonal of a matrix or create diagonal matrices
5. triu - upper triangular part of a matrix
6. tril - lower triangular part of a matrix
7. rand - randomly generated
matrixeg:
diag([0.9092;0.5163;0.2661])
ans =
0.9092 0 0
0 0.5163 0
0 0 0.2661
commands in the second sub-category of matrix functions are
1. size size of a matrix
2. det determinant of a square matrix
3. inv inverse of a matrix
4. rank rank of a matrix
5. rref reduced row echelon form
6. eig eigenvalues and eigenvectors
7. poly characteristic polynomial
Department of Electronics and Communication Engineering Page 9
BKM

Basic Simulation Lab Manual


10
PROCEDURE:-  Open MATLAB
 Open new M-file
 Type the program
 Save in current directory
 Compile and Run the program
 For the output see command window\ Figure window

PROGRAM:-

clc;
close
all;clear
all;
a=[1 2 -9 ; 2 -1 2; 3 -4 3];
b=[1 2 3; 4 5 6; 7 8 9];
disp('The matrix a= ');
a
disp('The matrix b= ');
b
% to find sum of a and b
c=a+b;
disp('The sum of a and b is ');
c
% to find difference of a and b
d=a-b;
disp('The difference of a and b is ');
d
%to find multiplication of a and b
e=a*b;
disp('The product of a and b is ');
e

Department of Electronics and Communication Engineering Page 10


BKM

Basic Simulation Lab Manual


\ 11
OUTPUT:-

The matrix

a=a =

1 2 -9
2 -1 2
3 -4 3

The matrix

b=b =

1 2 3
4 5 6
7 8 9

The sum of a and b is c =

2 4 -6
6 4 8
10 4 12

The difference of a and b isd =

0 0 -12
-2 -6 -4
-4 -12 -6

The product of a and b is e =

-54 -60 66
12 15 18
8 10 12
RESULT:-
Finding addition, subtraction, multiplication using MATLAB
wasSuccessfully completed.

Department of Electronics and Communication Engineering Page 11


BKM

Basic Simulation Lab Manual


VIVA QUESTIONS:- 12

1.Expand MATLAB?And importance of MATLAB?


2.What is clear all and close all will do?
3. What is disp() and input()?
4. What is the syntax to find the eigen values and eigenvectors of the matrix?
5. What is the syntax to find the rank of the matrix?
6. 6.How to determine rank of Matrix?
7. How to determine Rank of Matrix?
8. How to determine Transpose of Matrix?
9. How to determine Trace of Matrix?
10. How to determine Inverse of Matrix?
EXERCISE PROGRAMS

1. Enter the matrix M=[1,3,-1,6:2,4,0,-1;0,-2,3,-1;-1,2,-5,1] and N=[-1,-3,3;2,-1,6;1,4,-1;2,-1,2],


perform multiplication on M and N. Can order of multiplication be switched? Why or why not?
2. Enter the matrix
M = [1,-2,8,0] and N = [1 5 6 8; 2 5 6 9]
Perform addition on M and N and see how matlab reacts.
3. Find the transpose of null matrix using matlab
4. Write a MATLAB program to perform the division operation on the following
matrixA = [24,-30, 64,-81], b= [6,5,8,9] and verify the result.
5. Write a matlab program to perform addition operation using 2x3 matrix. Assume any numbers
6. Enter the matrix
A = [1 6 9 8 5; 9 3 5 8 4; 5 6 3 5 7], B = [6 5 9 3 5; 6 5 4 8 5; 6 3 5 7 9],
C = [2 5 9 3 4; 5 6 3 7 8; 9 8 6 5 4]
Find [(A+B)+C]T
7. Enter the matrix
A = [1 6 9 8 5; 9 3 5 8 4; 5 6 3 5 7], B = [6 5 9 3 5; 6 5 4 8 5; 6 3 5 7 9],
C = [2 5 9 3 4; 5 6 3 7 8; 9 8 6 5 4]
Find [(A-B)+C]-1
8. Write a matlab program to perform addition operation using 3x2 matrix. Assume any
numbers
9. Write a MATLAB program to perform the division operation on the following
matrix A = [25,-35, 121,-21], b= [5,5,11,3] and perform the transpose function on
the answer
10. Find the addition of null matrix and unity matrix of order 3x3.
11. Write a MATLAB program to find rank of the matrix A= [6 5 9 3 5; 6 5 4 8 5; 6 3 5 7 9].
12. Write a MATLAB program to find Eigen of the matrix A= [2 5 9 3 4; 5 6 3 7 8; 9 8 6 5 4].
13. Write a MATLAB program to find inverse of the matrix A= [1 6 9 8 5; 9 3 5 8 4; 5 6 3 5 7]
14. Write a MATLAB program to find determinant of the
matrixA= [1 6 9 8 5; 9 3 5 8 4; 5 6 3 5 7].
15. Write a MATLAB program to find Transpose of the
matrixA=[1 6 9 8 5; 9 3 5 8 4; 5 6 3 5 7]

Department of Electronics and Communication Engineering Page 12


BKM

Basic Simulation Lab Manual


16. Find the multiplication of null matrix and unity matrix of order 3x3.
13
17. Write a matlab program to perform multiplication operation using 2x3 matrix.
Assume anynumbers.
18. Write a MATLAB program to perform the division operation on the following
matrixA = [2,-5, 21,-21], b= [5,15,11,13].
19. Enter the matrix
A = [6 9 8 5;3 5 8 4;6 3 5 7], B = [5 9 3 5;5 4 8 5;3 5 7 9],
C = [5 9 3 4;6 3 7 8;8 6 5 4]
Find [(A-B)+C]-1
20. Write a matlab program to perform division operation using 3x2 matrix. Assume any
numbers
21. Write a MATLAB program to perform the division operation on the following
matrixA = [5,-3,11,-1], b= [6,5,1,13] and perform the transpose function on the
answer.
22. Find the addition of null matrix and Identity matrix of order 4x4.
23. Enter the matrix M=[2,13,-11;12,4,2;-2,3,-1] and N=[2,-1,6;1,4,-1;2,-1,2], perform
multiplication on M and N.
24. Enter the matrix M = [-2,8,0] and N = [1 5 6 8; 2 5 6 9]
Perform addition and multiplication on M and N and see how matlab
reacts. 25. Enter the matrix A = [6 9 8 5;3 5 8 4;6 3 5 7], B = [5 9 3 5;5 4 8
5;3 5 7 9],
C = [2 5 9 3 4; 5 6 3 7 8; 9 8 6 5 4]
Find [(A+B)+C]T
26. Find the addition of null matrix and unity matrix of order 4x4.
27. Write a MATLAB program to find rank of the matrix A= [6 4 9 3 5; 6 2 4 8 5; 6 3 1 7 9].
28. Write a MATLAB program to find Eigen of the matrix A= [2 5 0 3 4; 5 4 3 7 8; 9 1 6 5 4].
29. Write a MATLAB program to find inverse of the matrix A= [1 5 9 8 5;4 3 5 8 4; 5 6 3 5 0]
30. Write a MATLAB program to find determinant of the
matrixA= [1 6 9 8 5; 9 3 5 6 4; 1 6 3 5 6].

Real Time application:


We see the results of matrix mathematics in every computer-generated image that

has areflection, or distortion effects such as light passing through rippling water.

Department of Electronics and Communication Engineering Page 13


BKM

Basic Simulation Lab Manual


EXPERMENT NO:2 14

GENERATION OF VARIOUS SIGNALS & SEQUENCES

AIM:- To write a “MATLAB” Program to generate various signals and sequences,such as


unit impulse, unit step, unit ramp, sinusoidal, square, sawtooth, triangular, sinc
functions.

SOFTWARE REQURIED:-

1.MATLAB R2010a.
2.Windows XP SP2.

THEORY:-
One of the more useful functions in the study of linear systems is the "unit impulse
function." An ideal impulse function is a function that is zero everywhere but at the
origin, where it is infinitely high. However, the area of the impulse is finite. This is, at first
hard to visualize butwe can do so by using the graphs shown below.

Department of Electronics and Communication Engineering Page 14


BKM

Basic Simulation Lab Manual


Key Concept: Sifting Property of the Impulse 15

If b>a, then

Example: Another integral problem

Assume a<b, and evaluate the integral

Solution:

We now that the impulse is zero except at t=0 so

and

Unit Step Function

The unit step function and the impulse function are considered to be fundamental
functions in engineering, and it is strongly recommended that the reader becomes very
familiar with both of these functions.

The unit step function, also known as the Heaviside function, is defined as such:

Department of Electronics and Communication Engineering Page 15


BKM

Basic Simulation Lab Manual


16

Sometimes, u(0) is given other values, usually either 0 or 1. For many applications, it
isirrelevant what the value at zero is. u(0) is generally written as undefined.

Derivative

The unit step function is level in all places except for a discontinuity at t = 0. For this
reason, the derivative of the unit step function is 0 at all points t, except where t = 0. Where
t = 0, the derivative of the unit step function is infinite.

The derivative of a unit step function is called an impulse function. The impulse function
willbe described in more detail next.

Integral

The integral of a unit step function is computed as such:

Department of Electronics and Communication Engineering Page 16


BKM

Basic Simulation Lab Manual


Sinc Function 17

There is a particular form that appears so frequently in communications engineering, that


we give it its own name. This function is called the "Sinc function" and is discussed below:

The Sinc function is defined as below

and Sinc(0)=1

The value of sinc(x) is defined as 1 at x = 0, since

This fact can be proven by noting that for x near 0,

Then, since cos(0) = 1, we can apply the Squeeze Theorem to show that the sinc function
approaches one as x goes to zero. Thus, defining sinc(0) to be 1 makes the sinc function
continuous.

Also, the Sinc function approaches zero as x goes towards infinity, with the envelope of
sinc(x) tapering off as 1/x.

Rect Function

The Rect Function is a function which produces a rectangular-shaped pulse with a width of
1 centered at t = 0. The Rect function pulse also has a height of 1. The Sinc function and the
rectangular function form a Fourier transform pair.

A Rect function can be written in the form:

where the pulse is centered at X and has width Y. We can define the impulse function above
in terms of the rectangle function by centering the pulse at zero (X = 0), setting it's
height to 1/Aand setting the pulse width to A, which approaches zero:

Department of Electronics and Communication Engineering Page 17


BKM

Basic Simulation Lab Manual


18

We can also construct a Rect function out of a pair of unit step functions

Here, both unit step functions are set a distance of Y/2 away from the center point of (t - X).

SAW TOOTH:-

The sawtooth wave (or saw wave) is a kind of non-sinusoidal waveform. It is named a
sawtooth based on its resemblance to the teeth on the blade of a saw. The convention is
that a sawtooth wave ramps upward and then sharply drops. However, there are also
sawtooth waves in which the wave ramps downward and then sharply rises. The latter
type of sawtooth wave is called a 'reverse sawtooth wave' or 'inverse sawtooth wave'. As
audio signals, the two orientations of sawtooth wave sound identical. The piecewise linear
function based on the floor function of time t, is an example of a sawtooth wave with period
1.

Triangle wave

A triangle wave is a non-sinusoidal waveform named for its triangular shape.A bandlimited
triangle wave pictured in the time domain (top) and frequency domain (bottom). The
fundamental is at 220 Hz (A2).Like a square wave, the triangle wave contains only odd
harmonics. However, the higher harmonics roll off much faster than in a square wave
(proportional to the inverse square of the harmonic number as opposed to just the
inverse).It is possible to approximate a triangle wave with additive synthesis by adding odd
harmonics of the fundamental, multiplying every (4n−1)th harmonic by −1 (or changing its
phase by π), and rolling off the harmonics by the inverse square of their relative frequency
to the fundamental.This infinite Fourier series converges to the triangle wave:

Department of Electronics and Communication Engineering Page 18


BKM

Basic Simulation Lab Manual


Sinusoidal Signal Generation 19

The sine wave or sinusoid is a mathematical function that describes a smooth repetitive
oscillation. It occurs often in pure mathematics, as well as physics, signal processing,
electrical engineering and many other fields. Its most basic form as a function of time (t) is:
where:
• A, the amplitude, is the peak deviation of the function from its center position.
• ω, the angular frequency, specifies how many oscillations occur in
a unit timeinterval, in radians per second
• φ, the phase, specifies where in its cycle the oscillation begins at t = 0. A sampled sinusoid
may be written as:

where f is the signal frequency, fs is the sampling frequency, θis the phase
and A is theamplitude of the signal.

PROCEDURE:-
 Open MATLAB
 Open new M-file
 Type the program
 Save in current directory
 Compile and Run the program
 For the output see command window\ Figure window

PROGRAM:-

%unit impulse function%clc;


clear all; close
all; t=-10:1:10;
x=(t==0);
subplot(2,1,1);
plot(t,x,'g');
xlabel('time'); ylabel('amplitude');
title('unit impulse function');subplot(2,1,2);
stem(t,x,'r');
xlabel('time');
ylabel('amplitude');
title('unit impulse discreat function');

Department of Electronics and Communication Engineering Page 19


BKM

Basic Simulation Lab Manual


%unit step function% 20

clc;
clear all;close
all;N=100;
t=1:100;
x=ones(1,N);
subplot(2,1,1);
plot(t,x,'g');
xlabel('time'); ylabel('amplitude');
title('unit step function');subplot(2,1,2);
stem(t,x,'r');
xlabel('time');
ylabel('amplitude');
title('unit step discreat function');

%unit ramp function%clc;


clear all;
close all;
t=0:20;
x=t; subplot(2,1,1);
plot(t,x,'g');
xlabel('time'); ylabel('amplitude');
title('unit ramp function');subplot(2,1,2);
stem(t,x,'r');
xlabel('time');
ylabel('amplitude');
title('unit ramp discreat function');

%sinusoidal function%clc;
clear all; close
all; t=0:0.01:2;
x=sin(2*pi*t);
subplot(2,1,1);
plot(t,x,'g');
xlabel('time');

Department of Electronics and Communication Engineering Page 20


BKM

Basic Simulation Lab Manual


ylabel('amplitude'); title('sinusoidal signal'); 21
subplot(2,1,2);
stem(t,x,'r');
xlabel('time'); ylabel('amplitude');
title('sinusoidal sequence');

%square function%clc;
clear all; close
all; t=0:0.01:2;
x=square(2*pi*t);
subplot(2,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude'); title('square
signal');subplot(2,1,2);
stem(t,x,'r');
xlabel('time'); ylabel('amplitude');
title('square sequence');

%sawtooth function%clc;
clear all; close
all; t=0:0.01:2;
x=sawtooth(2*pi*5*t);
subplot(2,1,1);
plot(t,x,'g');
xlabel('time'); ylabel('amplitude');
title('sawtooth signal');subplot(2,1,2);
stem(t,x,'r');
xlabel('time'); ylabel('amplitude');
title('sawtooth sequence');

Department of Electronics and Communication Engineering Page 21


BKM

Basic Simulation Lab Manual


%trianguler function% 22

clc;
clear all; close
all; t=0:0.01:2;
x=sawtooth(2*pi*5*t,0.5);subplot(2,1,1);
plot(t,x,'g');
xlabel('time'); ylabel('amplitude');
title('trianguler signal');subplot(2,1,2);
stem(t,x,'r');
xlabel('time'); ylabel('amplitude');
title('trianguler sequence');

%sinc function%clc;
clear all;close
all;
t=linspace(-5,5);
x=sinc(t);
subplot(2,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude');
title('sinc signal');
subplot(2,1,2);
stem(t,x,'r');
xlabel('time');
ylabel('amplitude'); title('sinc
sequence');

Department of Electronics and Communication Engineering Page 22


BKM

Basic Simulation Lab Manual


23

Simulations:
unit impulse Discrete function
1
amplitude

0.5

0
-10 -8 -6 -4 -2 0 2 4 6 8 10
time

Unit step function

unit step function


2

1.5
amplitude

0.5

0
0 10 20 30 40 50 60 70 80 90 100
time
unit step discreat function
1
amplitude

0.5

0
0 10 20 30 40 50 60 70 80 90 100
time

Department of Electronics and Communication Engineering Page 23


BKM

Basic Simulation Lab Manual


Unit ramp function 24

unit ramp function


20

15
amplitude

10

0
0 2 4 6 8 10 12 14 16 18 20
time
unit ramp discreat function
20

15
amplitude

10

0
0 2 4 6 8 10 12 14 16 18 20
time

Sinusoidal function

sinusoidal signal
1

0.5
amplitude

-0.5

-1
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
time
sinusoidal sequence
1

0.5
amplitude

-0.5

-1
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
time

Department of Electronics and Communication Engineering Page 24


BKM

Basic Simulation Lab Manual


25

Square function

square signal
1

0.5
amplitude

-0.5

-1
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
time
square sequence
1

0.5
amplitude

-0.5

-1
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
time

Sawtooth function

sawtooth signal
1

0.5
amplitude

-0.5

-1
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
time
sawtooth sequence
1

0.5
amplitude

-0.5

-1
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
time

Department of Electronics and Communication Engineering Page 25


BKM

Basic Simulation Lab Manual


Triangular function 26

trianguler signal
1

0.5
amplitude

-0.5

-1
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
time
trianguler sequence
1

0.5
amplitude

-0.5

-1
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
time

Sinc Function
sinc signal
1

0.5
amplitude

-0.5
-5 -4 -3 -2 -1 0 1 2 3 4 5
time
sinc sequence
1

0.5
amplitude

-0.5
-5 -4 -3 -2 -1 0 1 2 3 4 5
time

RESULT: -

Thus the Generation of continuous time signals like unit step, sawtooth, triangular,
sinusoidal, ramp and sinc functions are successfully completedby using MATLAB.

Department of Electronics and Communication Engineering Page 26


BKM

Basic Simulation Lab Manual


VIVA QUESTIONS: - 27

1. Define Signal?
2. Define deterministic and Random Signal?
3. Define Delta Function?
4. What is Signal Modeling?
5. Define Periodic and a periodic Signal?
6.Write the relation between Step and Impulse signals?
7. Write the relation between Ramp and impulse signals?
8. Write the relation between Ramp and Step signals?9.Define Standard signals?
10. Give examples of Standard signals?

EXERCISE QUESTIONS

1. Generate rectangular pulse function by using MATLAB.


2.

Write a matlab program to get the above output where t0 = 2


3. Write a program to get the result in
signalr(t) = u(t) – 2*u(t+1)
4. Write a program to get the following output t = -1: -5

5.

Write mat lab program to get the above outputX(t) = 1; (0<t<2)


= 10;(2<t<15) Note: Add ramp and unit

Department of Electronics and Communication Engineering Page 27


BKM

Basic Simulation Lab Manual


6. Write a matlab program to generate a sine wave with amplitude = 3, frequency 20Hz. 28
7. Write a matlab program to generate a cos wave with amplitude = 3, frequency 20Hz.
8. Write a matlab program to generate a triangular wave with amplitude = 8,
frequency10Hz.
9. Write a matlab program to generate a square wave with amplitude = 2, frequency 10kHz.
10. Write a matlab program to generate the signum function.
11. Write a matlab program to generate exponential growing signal.
12. Write a matlab program to generate exponential decaying signal.
13. Write a matlab program to generate a triangular wave with amplitude = 6,frequency 1Hz.
14. Write a matlab program to generate a square wave with amplitude = 5, frequency 5kHz.
15. Write a matlab program to generate a sawtooth wave with amplitude = 8, frequency5Khz.
16. Write a matlab program to generate a sine wave with amplitude = 5, frequency 5Hz.
17. Write a matlab program to generate a cos wave with amplitude = 4, frequency 10Hz.
18. Write a matlab program to generate a triangular wave with amplitude = 5, frequency 4Hz.
19. Write a matlab program to generate a square wave with amplitude = 1, frequency 20kHz.
20. Write a matlab program to generate the signum function.
21. Wr ite a matlab program to generate a square wave with amplitude = 4, frequency 5kHz.
22. Write a matlab program to generate a triangular wave with amplitude = 6,
frequency6Hz.
23. Write a matlab program to generate a triangular wave with amplitude = 8,frequency 2Hz.
24. Write a matlab program to generate a square wave with amplitude = 7, frequency 5kHz.
25. Write a matlab program to generate a sawtooth wave with amplitude =10,
frequency10Khz.
26. Write a matlab program to generate the signum function in frquency domain?.
27. Write a matlab program to generate exponential growing signal in time domain?.
28. Write a matlab program to generate exponential decaying signal in time domain?.
29. Write a matlab program to generate a triangular wave with amplitude = 4,frequency 6Hz.
30. Write a matlab program to generate a square wave with amplitude = 8, frequency 4kHz.

Real Time Applications:


• Industrial control and automation (Control the velocity or position of an object)
• Examples: Controlling the position of a valve or shaft of a motor
• Mechanical Translational Systems
• Mechanical Rotational Systems.

Department of Electronics and Communication Engineering Page 28


BKM

Basic Simulation Lab Manual


29
GENERATION OF DISCRETE SIGNALS
PROGRAM:-
clc; clear all; close all;
n=-10:1:10;
L=length(n); for i=1:L
if n(i)==0 x1(i)=1;
else
x1(i)=0;
end;
if n(i)>=0 x2(i)=1;
x3(i)=n(i); else
x2(i)=0;
x3(i)=0;
end; end;
% to generate exponential sequence
a=0.85;
x4=a.^n;
% to generate sinusoidal sequence
f=0.1;
x5=sin(2*pi*f*n); figure;
subplot(3,2,1);
stem(n,x1); xlabel('time n>');
ylabel('amplitude >');
title('Unit step signal'); subplot(3,2,2);
stem(n,x2);xlabel('time n >');
ylabel('amplitude >');
title('Unit impluse signal')
subplot(3,2,3);
stem(n,x3); xlabel('time n>');
ylabel('amplitude >');
title('Unit remp signal');
subplot(3,2,4);
stem(n,x4);xlabel('time n >');
ylabel('amplitude >');
title('exponential signal');
subplot(3,2,[5,6]); stem(n,x5);
xlabel('time n>');
ylabel('amplitude >');
title('sinusoidal signal');

Department of Electronics and Communication Engineering Page 29


BKM

Basic Simulation Lab Manual


GENERATION OF CONTINUOUS
30
SIGNALS
PROGRAM:-
clc;
Clear all;
Close all;
t=-10:0.01:10;
L=length(t); for i=1:L
%to generate unit Step and ramp
function if t(i)<0
x1(i)=0;
x2(i)=0;
else
x1(i)=1;
x2(i)=t(i); end;
end;
%to generate sinusoidal function
f=0.1;
x3=sin(2*pi*f*t);
%to generate Triangular and
Sawtooth waveforms
x4=sawtooth(t,0.5);
x5=sawtooth(t);

%to generate sinc function x6=sinc(t);


figure; subplot(2,3,1);
plot(t,x1);
xlabel('t--->');ylabel('amp--->');
title('unit step');
subplot(2,3,2);
plot(t,x2);
xlabel('t--->');ylabel('amp--->');
title('unit ramp'); subplot(2,3,3);
plot(t,x3);
xlabel('t--->');ylabel('amp--->');
title('sinusoidal'); subplot(2,3,4);
plot(t,x4);
xlabel('t--->');ylabel('amp--->');
title('triangular'); subplot(2,3,5);
plot(t,x5);
xlabel('t--->');ylabel('amp--->');
title('sawtooth');
subplot(2,3,6);
plot(t,x6);
xlabel('t--->');ylabel('amp--->');
title('sinc function');

Department of Electronics and Communication Engineering Page 30


BKM

Basic Simulation Lab Manual


EXPERMENT NO:3 31

OPERATIONS ON SIGNALS & SEQUENCES


AIM: -
To performs operations on signals and sequences such as addition, multiplication,scaling,
shifting, folding, computation of energy and average power.

SOFTWARE REQURIED: -

1.MATLAB R2010a.
2.Windows XP SP2.

THEORY: -

Basic Operation on Signals:

Time shifting: y(t)=x(t-T) The effect that a time shift has on the appearance of a
signalIf T is a positive number, the time shifted signal, x (t -T ) gets shifted to the
right, otherwise it gets shifted left.

Signal Shifting and Delay:

Shifting: y(n)={x(n-k)} ; m=n-k; y=x;


Time reversal: Y(t)=y(-t) Time reversal _ips the signal about t = 0 as
seen inFigure 1.

Signal Addition and Subtraction:

Addition: any two signals can be added to form a third


signal,z (t) = x (t) + y (t)

Department of Electronics and Communication Engineering Page 31


BKM

Basic Simulation Lab Manual


Signal Amplification: 32

Multiplication/Division:

of two signals, their product is also a

signal.z (t) = x (t) y (t)

folding:

y(n)={x(-n)} ; y=fliplr(x); n=-fliplr(n);

PROCEDURE:-
 Open MATLAB
 Open new M-file
 Type the program
 Save in current directory
 Compile and Run the program
 For the output see command window\ Figure window

PROGRAM:-

%Addition and multiplication of two signals%

clc;
clear all; close all;
t=0:0.001:2;
s1=6*sin(2*pi*5*t);
subplot(4,1,1);
plot(t,s1,'g');
xlabel('time');
ylabel('amplitude');

Department of Electronics and Communication Engineering Page 32


BKM

Basic Simulation Lab Manual


title('first signal'); s2=8*sin(2*pi*5*t);subplot(4,1,2); 33
plot(t,s2,'r');
xlabel('time'); ylabel('amplitude'); title('second signal');s3=s1+s2; subplot(4,1,3);
plot(t,s3,'g');
xlabel('time'); ylabel('amplitude'); title('sum of two signals');s4=s1.*s2;
subplot(4,1,4);
plot(t,s4,'g');
xlabel('time'); ylabel('amplitude');
title('multiplication of two signals');

%Amplitude scaling for signals% %Time scaling for signals%

clc; clc; clear all; close all;


clear all; close all; t=0:0.001:2; t=0:0.001:2;
s1=6*sin(2*pi*5*t);subplot(3,1,1); s1=6*sin(2*pi*5*t); subplot(3,1,1);
plot(t,s1,'g'); plot(t,s1,'g');
xlabel('time'); xlabel('time'); ylabel('amplitude');
ylabel('amplitude'); title('sinusoidal signal'); t1=3*t;
title('sinusoidal signal'); subplot(3,1,2);
s2=3*s1; subplot(3,1,2); plot(t1,s1,'r');
plot(t,s2,'r'); xlabel('time'); ylabel('amplitude');
xlabel('time'); title('compressed signal'); t2=t/3;
ylabel('amplitude'); subplot(3,1,3);
title('amplified signal'); plot(t2,s1,'g');
s3=s1/3; subplot(3,1,3); xlabel('time'); ylabel('amplitude');
plot(t,s3,'g'); title('enlarged signal');
xlabel('time'); ylabel('amplitude');
title('attenuated signal');

Department of Electronics and Communication Engineering Page 33


BKM

Basic Simulation Lab Manual


34
%Time shifting of a signal% %Time folding of a signal%

clc; clc;
clear all; close all; t=0:0.001:3; clear all; close all; t=0:0.001:2;
s1=6*sin(2*pi*5*t);subplot(3,1,1); s=sin(2*pi*5*t);m=length(s);
plot(t,s1,'g'); n=[-m:m];
xlabel('time'); ylabel('amplitude'); y=[0,zeros(1,m),s];
title('sinusoidal signal');t1=t+10; subplot(2,1,1);
subplot(3,1,2); plot(n,y,'g');
plot(t1,s1,'r'); xlabel('time'); ylabel('amplitude');
xlabel('time'); ylabel('amplitude'); title('original signal');
title('right shift of the signal');t2=t-10; y1=[fliplr(s),0,zeros(1,m)];
subplot(3,1,3); subplot(2,1,2);
plot(t2,s1,'g'); plot(n,y1,'r');
xlabel('time'); ylabel('amplitude'); xlabel('time'); ylabel('amplitude');
title('left shift of the signal'); title('folded signal');

%Time shifting of a signal% %Time folding of a signal%clc;


clear all; close all; t=0:0.001:2;
clc; s=sin(2*pi*5*t);
clear all; close all; t=0:0.001:3; m=length(s);
s1=6*sin(2*pi*5*t);subplot(3,1,1); n=[-m:m];
plot(t,s1,'g'); y=[0,zeros(1,m),s];
xlabel('time'); ylabel('amplitude'); subplot(2,1,1);
title('sinusoidal signal');t1=t+10; plot(n,y,'g');
subplot(3,1,2); xlabel('time'); ylabel('amplitude');
plot(t1,s1,'r'); title('original signal');
xlabel('time'); ylabel('amplitude'); y1=[fliplr(s),0,zeros(1,m)];
title('right shift of the signal');t2=t-10; subplot(2,1,2);
subplot(3,1,3); plot(n,y1,'r');
plot(t2,s1,'g'); xlabel('time');
xlabel('time'); ylabel('amplitude'); ylabel('amplitude');
title('left shift of the signal'); title('folded signal');

Department of Electronics and Communication Engineering Page 34


BKM

Basic Simulation Lab Manual


35
OUTPUT: -

Addition and multiplication of two signals

first signal
amplitude

10
0
-10
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
time
second signal
amplitude

10
0
-10
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
time
sum of two signals
amplitude

20
0
-20
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
time
multiplication of two signals
amplitude

50

0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
time

Department of Electronics and Communication Engineering Page 35


BKM

Basic Simulation Lab Manual


Amplitude scaling for signals 36

sinusoidal signal
10
amplitude

-10
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
time
amplified signal
20
amplitude

-20
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
time
attenuated signal
2
amplitude

-2
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
time

Department of Electronics and Communication Engineering Page 36


BKM

Basic Simulation Lab Manual


Time scaling for signals 37

sinusoidal signal
10
amplitude

-10
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
time
compressed signal
10
amplitude

-10
0 1 2 3 4 5 6
time
enlarged signal
10
amplitude

-10
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7
time

Department of Electronics and Communication Engineering Page 37


BKM

Basic Simulation Lab Manual


38
Time shifting of a signal

sinusoidal signal
10
amplitude

-10
0 0.5 1 1.5 2 2.5 3
time
right shift of the signal
10
amplitude

-10
10 10.5 11 11.5 12 12.5 13
time
left shift of the signal
10
amplitude

-10
-10 -9.5 -9 -8.5 -8 -7.5 -7
time

Department of Electronics and Communication Engineering Page 38


BKM

Basic Simulation Lab Manual


39
Time folding of a signal

original signal
1

0.5
amplitude

-0.5

-1
-2500 -2000 -1500 -1000 -500 0 500 1000 1500 2000 2500
time
folded signal
1

0.5
amplitude

-0.5

-1
-2500 -2000 -1500 -1000 -500 0 500 1000 1500 2000 2500
time

RESULT: -

In this experiment the various oprations on signals have beenPerformed Using MATLAB have been
demonstrated.

VIVA QUESTIONS: -
1. Define Symmetric and Anti-Symmetric Signals?
2. Define Continuous and Discrete Time Signals?
3. What are the Different types of representation of discrete time signals?
4. What are the Different types of Operation performed on signals?
5. What is System?
6.Explain Even Signals?
7.Explain Odd signals?
8.Define Periodic signals?
9.Define Aperiodic
signals?
10.Differentiate Energy and Power signals with examples?

Department of Electronics and Communication Engineering Page 39


BKM

Basic Simulation Lab Manual


EXERCISE PROGRAMS 40

1. Write a MATLAB program to generate amplitude scaling of a sequence.


2. Write a MATLAB program to subtract two sinusoidal signals.
3. Write a MATLAB program to subtract and multiply two sinusoidal signals.
4. Write a MATLAB program to right shift the signal to 5 times of the original signal.
5. Write a MATLAB program to left shift the signal to 8 times of the original signal.
6. Write a MATLAB program to add two different signals with 2 <t<5
7. Write a MATLAB program to shift a positive time line signal to negative timeline signal.
8. Write a MATLAB program to subtract co-sinusoidal signals.
9. Write a MATLAB program to subtract two sinusoidal signals
10. Write a MATLAB program to division and multiply two co-sinusoidal signals.
11. Write a MATLAB program to generate time scaling of a sequence.
12. Write a MATLAB program to generate time shifting of a sequence.
13. Write a MATLAB program to generate time folding of a sequence.
14. Write a MATLAB program to generate amplitude scaling of a sequence with amplitude 5.
15. Write a MATLAB program to generate time scaling of a sequence with time 2sec.
16. Write a MATLAB program to add two different signals with 4 <t<8
17. Write a MATLAB program to shift a negative time line signal to positive timeline signal.
18. Write a MATLAB program to subtract sinusoidal signals.
19. Write a MATLAB program to subtract and divide two sinusoidal signals
20. Write a MATLAB program to add and multiply two co-sinusoidal signals.
21. Write a MATLAB program to generate time scaling of a signal.
22. Write a MATLAB program to generate time shifting of a signal.
23. Write a MATLAB program to generate time folding of a signal.
24. Write a MATLAB program to generate amplitude scaling of a sequence with amplitude 10.
25. Write a MATLAB program to generate time scaling of a sequence with time 5sec.
26. Write a MATLAB program to substract two different signals with 2 <t<5
27. Write a MATLAB program to compress a positive time line signal to negative timeline signal.
28. Write a MATLAB program to positive shift in delay of co-sinusoidal signals.
29. Write a MATLAB program to subtract two signals.
30. Write a MATLAB program to multiply two co-sinusoidal signals of different
amplitudelevels.

Real Time Applications:


 Stream processing
 Block processing
 Vector processing
 Digital Signal Processing Applications.

Department of Electronics and Communication Engineering Page 40


BKM

Basic Simulation Lab Manual


EXPERMENT NO: 4 41

FINDING EVEN AND ODD & REAL AND IMAGINARY PARTS OF SEQUENCES

AIM: -
Program for finding even and odd parts of sequences Using MATLAB Software& Program
for finding real and imaginary parts of sequences Using MATLAB Software
SOFTWARE REQURIED: -1. MATLAB R2010a.
2.Windows XP SP2.

THEORY: -
Even and Odd Signal
One of characteristics of signal is symmetry that may be useful for signal analysis. Even
signals are symmetric around vertical axis, and Odd signals are symmetric about origin.
Even Signal: A signal is referred to as an even if it is identical to its time-reversed
counterparts; x(t) = x(-t).
Odd Signal: A signal is odd if x(t) = -x(-t).
An odd signal must be 0 at t=0, in other words, odd signal passes the origin.
Using the definition of even and odd signal, any signal may be decomposed into a sum of
its even part, xe(t), and its odd part, xo(t), as follows:

x(t)=xe(t)+xo(t);

x(t)=1/2{x(t)+x(-t)} +1/2{x(t)-x(-t)}where
xe(t)=1/2{x(t)+x(-t)} &xo(t)=1/2{x(t)-x(-t)}

It is an important fact because it is relative concept of Fourier series. In Fourier series, a


periodic signal can be broken into a sum of sine and cosine signals. Notice that sine
function is odd signal and cosine function is even signal.

ENERGY AND POWER SIGNAL:

A signal can be categorized into energy signal or power


signal: An energy signal has a finite energy, 0 < E < ∞. In other words, energy signals
have values only in the limited time duration. For example, a signal having only one
square pulse is energy signal. A signal that decays exponentially has finite energy, so, it is
also an energy signal. The power of an energy signal is 0, because of dividing finite
energy by infinite time (or length).

Department of Electronics and Communication Engineering Page 41


BKM

Basic Simulation Lab Manual


If x(t) is a real-valued signal with Fourier transform X(f), and u(f) is the Heaviside step function, 42
then the function:

contains only the non-negative frequency components of X(f). And the operation is
reversible,due to the Hermitian property of X(f):

X(f)* denotes the complex conjugate of X(f) .

Department of Electronics and Communication Engineering Page 42


BKM

Basic Simulation Lab Manual


The inverse Fourier transform of Xa(f) is the analytic signal: 43

where x^(t) is the Hilbert transform of x(t) and J is the imaginary unit.

PROCEDURE: -
 Open MATLAB
 Open new M-file
 Type the program
 Save in current directory
 Compile and Run the program
 For the output see command window\ Figure window

Department of Electronics and Communication Engineering Page 43


BKM

Basic Simulation Lab Manual


44
PROGRAM: -

%Even, odd, real, imaginary parts %odd part of sequence%


of a sequences%
clc; xodd=(x-xmir)/2; subplot(4,1,4);
clear all; stem(n,xodd,'g');
close all; xlabel('time'); ylabel('amplitude');
h=input('enter no.of samples'); title('odd part of sequence');
m=(h-1)/2;
n=-m:m; %Real&Imaginary parts of a sequences%
x=input('enter sample values'); clc;
subplot(4,1,1);
clear all; close all;
stem(n,x,'g');
y=input('enter complex numbers');
xlabel('time'); ylabel('amplitude');
title('original sequence'); yreal=real(y);
xmir=fliplr(x); subplot(4,1,2); disp('real values of y'); yreal
stem(n,xmir,'r'); yimag=imag(y);
xlabel('time'); ylabel('amplitude'); disp('imaginary values of y');
title('folded sequence'); yimag
%even part of sequence%
xeven=(x+xmir)/2; subplot(4,1,3);
stem(n,xeven,'r');
xlabel('time'); ylabel('amplitude');
title('even part of sequence');

Department of Electronics and Communication Engineering Page 44


BKM

Basic Simulation Lab Manual


OUTPUT:- 45

Even,odd,real,imaginary parts of a

sequencesenter no.of samples5


enter sample values[1 2 3 4 5]

original sequence
amplitude

0
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
time
folded sequence
amplitude

0
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
time
even part of sequence
amplitude

4
2
0
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
time
odd part of sequence
amplitude

2
0
-2
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
time

Real & Imaginary parts of a sequences

enter complex numbers [1+6i 2-5i 3 4+3i

5i]real values of y

yreal = 1 2 3 4 0 imaginary values of y

yimag =
6 -5 0 3 5

RESULT: -

In this experiment even and odd parts of various signals and


energyand power of signals have been calculated Using
MATLAB.

Department of Electronics and Communication Engineering Page 45


BKM

Basic Simulation Lab Manual


PROGRAM:-
46
clc; clear all;
close all;
t=-5:0.001:5; A=0.8; x1=A.^(t);
x2=A.^(-t);
if(x2==x1)
disp('The given signal is even signal');
else
if(x2==(-x1))
disp('The given signal is odd signal');
else
disp('The given signal is neither even
nor odd');
end
end xe=(x1+x2)/2; xo=(x1-x2)/2;
subplot(2,2,1);
plot(t,x1);
xlabel('t');ylabel('x(t)');title('signal
x(t)'); subplot(2,2,2);
plot(t,x2); xlabel('t');ylabel('x(t)');
title('signal x(-t)');
subplot(2,2,3);
plot(t,xe);

xlabel('t');ylabel('x(t)');title('even part
signal x(t)'); subplot(2,2,4);
plot(t,xo);
xlabel('t');ylabel('x(t)');title('odd part
signal x(t)');

Department of Electronics and Communication Engineering Page 46


BKM

Basic Simulation Lab Manual


47
VIVA QUESTIONS

1. What is the formula to find odd part of signal?


2. What is Even Signal?
3. What is Odd Signal?
4. What is the formula to find even part of signal?
5. What is the difference b/w stem&plot?
6.What is Energy Signals?
7.What is Power signals?
Define Systems?
9.How to determine time period of Periodic
signals?10.Define Frequency of signals?

EXERCISE PROGRAM
1. Write a MATLAB program to find even part of a signal by considering 10 input samples.
2. Write a MATLAB program to find odd part of a signal by considering atleast 7 samples.
3. Write a MATLAB program to add even an odd part of a signal and see how matlab
reacts forthe above program.
4. Write a matlab program to get the out put as [-5, 3, 0, 8] as imaginary values and [2 4 6 8 0] as
real values.
5. Write a MATLAB program to subtract even an odd part of a signal and see how matlab
reactsfor the above program.
6. Write a MATLAB program to find real & imaginary values of complex numbers
[1+6i 2-5i 34+3i 5i].
7. Write a MATLAB program to find real & imaginary values of complex numbers
[2+6i 7+5i3 9+3i 5i].
8. Write a MATLAB program to find real & imaginary values of complex numbers
[7+6i 2-5i 38+3i 7i].
9. Write a MATLAB program to find even & odd part of the sequence [5 6 3 2 3 4 7].
10. Write a MATLAB program to find even & odd part of the sequence [7 5 8 6 7].
11.Write a MATLAB program to find even part of a signal by considering 8 input
samples.
12. Write a MATLAB program to find odd part of a signal by considering 10 samples.
13. Write a MATLAB program to multiply even and odd part of a signal and see how
matlabreacts for the above program.
14. Write a matlab program to get the output as [2, 5, -1, 6] imaginary values and
[4, 2, 8, 0] asreal values.
15. Write a MATLAB program to divide even an odd part of a signal and see how matlab
reactsfor the above program.
16. Write a MATLAB program to find real & imaginary values of complex numbers
[2+4i 1-6i4+2i 8i].
17. Write a MATLAB program to find real & imaginary values of complex numbers
[4+8i 6+4i2 6+4i 6i].

Department of Electronics and Communication Engineering Page 47


BKM

Basic Simulation Lab Manual


18. Write a MATLAB program to find real & imaginary values of complex numbers 48
[4+4i 2-5i 46+4i 6i].
19. Write a MATLAB program to find even & odd part of the sequence [4 9 8 4 3 2 1].
20. Write a MATLAB program to find even & odd part of the sequence [5 7 6 7 8].
21. Write a MATLAB program to find even & odd part of the sequence [2 3 6 3 4 3 7].
22. Write a MATLAB program to find even & odd part of the sequence [5 4 6 8 6].
23.Write a MATLAB program to find even part of a signal by considering 6 input
samples.
24. Write a MATLAB program to find odd part of a signal by considering 9 samples.
25. Write a matlab program to get the output as [2, 4, -6, 8] imaginary values and
[1, 5, 9, 3] asreal values.
26.Write a MATLAB program to find even & odd part of the sequence [4 6 3 2 6 3 4 7].
10. Write a MATLAB program to find even & odd part of the sequence [7 5 8 6 4 2 1 7].
11.Write a MATLAB program to find even part of a signal by considering 10 input
samples.
12. Write a MATLAB program to find odd part of a signal by considering 10 input samples.
13. Write a MATLAB program to multiply even and odd part of a signal.

Real Time Applications:

 Synthesis and manipulation: E.g. speech synthesis, music synthesis, graphics.


 Analysis: Seismic data, atmospheric data, stock market analysis.
 Medical Applications.

Department of Electronics and Communication Engineering Page 48


BKM

Basic Simulation Lab Manual


EXPERMENT NO:5 49

Linear Convolution

AIM: -
To find the output with linear convolution operation Using MATLAB Software.

SOFTWARE REQURIED:-

1.MATLAB R2010a.
2.Windows XP SP2.

THEORY:-

Linear Convolution involves the following operations.


1. Folding
2. Multiplication
3. Addition
4. Shifting
These operations can be represented by a Mathematical Expression as follows:

x[n]= Input signal Samples


h[ n-k]= Impulse response co-
efficient.y[ n]= Convolution output.
n = No. of Input samples
h = No. of Impulse response co-efficient.
Example : X(n)={1 2 -1 0 1}, h(n)={ 1,2,3,-1}.

PROCEDURE:-

 Open MATLAB
 Open new M-file
 Type the program
 Save in current directory
 Compile and Run the program
 For the output see command window\ Figure window

Department of Electronics and Communication Engineering Page 49


BKM

Basic Simulation Lab Manual


PROGRAM:- 50

%Convolution of two

signals%

clc;
clear all;
close all; t=0:0.001:10;
x=sin(t); h=square(t); subplot(3,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude');
title('sinusoidal
signal');
subplot(3,1,2);
plot(t,h,'r');
xlabel('time');
ylabel('amplitude');
title('square
function');
y=conv(x,h);
subplot(3,1,3); plot(y); xlabel('time'); ylabel('amplitude');
title('convolution signal');

%Convolution of two sequences%


clc;
clear all;
close all;
L=input('enter the length of 1st
sequence'); M=input('enter the length of
2nd sequence');x=input('enter the first
sequence:x(n)='); h=input('enter the
second sequence:y(n)='); N=0:(L+M-1);
y=conv(x,h);
subplot(3,1,1);
stem(x,'g');
xlabel('discrete
time');ylabel('x(n)');
title('1st sequence');
subplot(3,1,2);
stem(h,'r'); xlabel('discrete time');

Department of Electronics and Communication Engineering Page 50


BKM

Basic Simulation Lab Manual


ylabel('h(n)'); title('second sequence');subplot(3,1,3); 51
stem(y); xlabel('discrete time');ylabel('y(n)');
title('convolution of two sequences');

OUTPUT:-

Convolution of two signals

sinusoidal signal
1
amplitude

-1
0 1 2 3 4 5 6 7 8 9 10
time
square function
1
amplitude

-1
0 1 2 3 4 5 6 7 8 9 10
time
4
x 10 convolution signal
1
amplitude

-1
0 0.5 1 1.5 2 2.5
time 4
x 10

Department of Electronics and Communication Engineering Page 51


BKM

Basic Simulation Lab Manual


52

Convolution of two sequences

enter the length of 1st sequence 4


enter the length of 2nd sequence 4
enter the first sequence:x(n)=[1 2 3 4]
enter the second sequence:y(n)=[1 2 3 4]

1st sequence
4
x(n)

0
1 1.5 2 2.5 3 3.5 4
discrete time
second sequence
4
h(n)

0
1 1.5 2 2.5 3 3.5 4
discrete time
convolution of two sequences
40
y(n)

20

0
1 2 3 4 5 6 7
discrete time

RESULT:-

In this experiment convolution of various signals have


beenperformed Using MATLAB.

Department of Electronics and Communication Engineering Page 52


BKM

Basic Simulation Lab Manual


PROGRAM:-
53
clc; clear all; close all;
n=0:8; x1=1; x2=0;
y1=x1.*(n>=0 & n<=2)+x2.*(n>=2 & n<=8);
subplot(2,2,1);
stem(n,y1); axis([0 8 0 1.5]);
xlabel('time n>');
ylabel('amplitude>');
title('the sequence y1[n]');
y2=x1.*(n>=0 & n<=4)+x2.*(n>=4 & n<=8);
subplot(2,2,2);
stem(n,y2); axis([0 8 0 1.5]);
xlabel('time n>');
ylabel('amplitude>');
title('the sequence y2[n]') ;
y=conv(y1,y2); L=length(y);
n=0:L-1;
subplot(2,2,[3,4]);
stem(n,y);
axis([0 10 0 4]);
xlabel('time n>');
ylabel('amplitude >');
title('the convolution sequence of
y1[n]&y2[n]');

Department of Electronics and Communication Engineering Page 53


BKM

Basic Simulation Lab Manual


VIVA QUESTIONS: - 54

1. Define Convolution?
2. Define Properties of Convolution?
3. What is the Difference Between Convolution& Correlation?
4. What are Dirchlet Conditions of Fourier
Series?5.What is Half Wave Symmetry?
6. Define Linear Convolution?
7. Define Properties of Convolution in time domain?
8. What is the Difference Between Linear Convolution& Circular Correlation?
9. What are Dirchlet Conditions for Fourier
Transform?10.What is Full Wave Symmetry?

EXERCISE PROGRAMS

1. Write the MATLAB program to perform convolution between the following


sequencesX(n)=[1 -1 4 ], h(n) = [ -1 2 -3 1].
2. Write a mat lab program to perform the convolution between sinusoidal and ramp
function andsee how mat lab reacts to it.
3. Write a MATLAB program to perform convolution between square and step signal
and seehow mat lab reacts to it.
4. Write a MATLAB program to perform convolution between sinusoidal and ramp signal
andsee how mat lab reacts to it.
5. Write a MATLAB program to perform the convolution between X (n) = [1 2 3 5] and
y (n) =[- 1 – 2] and see how matlab reacts to it.
6. Write a MATLAB program to perform the convolution between X (n) = [1 -3 5] and
y (n) =[1 2 3 4] and see how matlab reacts to it.
7. Write a MATLAB program to perform the convolution between X (n) = [1 0 1 1] and
y (n) =[1 0 0 0 0] and see how matlab reacts to it.
8. Write a MATLAB program to perform the convolution between X (n) = [1 1 1 1 0 0 0 0] and
y(n) = [1 0 1 0 1 0 1 0] and see how matlab reacts to it.
9. Write a MATLAB program to perform the convolution between X (n) = [1 1 0 0] and
y (n) =[1 1 1 1] and see how matlab reacts to it.
10. Write a MATLAB program to perform the convolution between X (n) = [6 7 8 9 10] and
y (n) = [5 4 3 2 1] and see how matlab reacts to it.
11. Write the MATLAB program to perform convolution between the following
sequencesX(n)=[2 -2 3 2], h(n) = [-2 4 -5 2].
12. Write a mat lab program to perform the convolution between step and ramp function
and seehow mat lab reacts to it.
13. Write a MATLAB program to perform convolution between square and step signal
and seehow mat lab reacts to it.
14. Write a MATLAB program to perform convolution between sinusoidal and square
signal andsee how mat lab reacts to it.
15. Write a MATLAB program to perform the convolution between X (n) = [2 3 4 5] and
y (n) =[-2 –4] and see how matlab reacts to it.

Department of Electronics and Communication Engineering Page 54


BKM

Basic Simulation Lab Manual


16. Write a MATLAB program to perform the convolution between X (n) = [3 -4 6] and 55
y (n) =[2 6 8 6] and see how matlab reacts to it.
17. Write a MATLAB program to perform the convolution between X (n) = [3 1 2 0] and
y (n) =[2 4 3 4 5] and see how matlab reacts to it.
18. Write a MATLAB program to perform the convolution between X (n) = [2 2 1 0 2 1 1 0] and
y (n) = [1 1 1 2 1 0 1 0] and see how matlab reacts to it.
19. Write a MATLAB program to perform the convolution between X (n) = [2 1 2 1] and
y (n) =[1 2 1 2] and see how matlab reacts to it.
20. Write a MATLAB program to perform the convolution between X (n) = [5 6 9 8 7] and
y (n)= [1 2 3 2 1] and see how matlab reacts to it.
21. Write the MATLAB program to perform convolution between the following
sequencesX(n)=[4 -6 5 1], h(n) = [-1 3 -4 3].
22. Write a mat lab program to perform the convolution between ramp and step function
and seehow mat lab reacts to it.
23. Write a MATLAB program to perform convolution between square and step signal
and seehow mat lab reacts to it.
24. Write a MATLAB program to perform convolution between sinusoidal and step signal
andsee how mat lab reacts to it.
25. Write a MATLAB program to perform the convolution between X (n) = [1 5 6 5] and
y (n) =[-3 –6] and see how matlab reacts to it.
26. Write a MATLAB program to perform the Circular Convolution between
X (n) = [1 0 1 1 0]and y (n) = [1 0 0 0 0 1] and see how matlab reacts to it.
27. Write a MATLAB program to perform the Circular Convolution between
X (n) = [1 1 1 1 0 0 0 0] and y (n) = [1 0 1 0 1 0 1 0] and see how matlab reacts to it.
28. Write a MATLAB program to perform the Circular Convolution between
X (n) = [1 1 0 0]and y (n) = [1 1 1 1] and see how matlab reacts to it.
29. Write a MATLAB program to perform the Circular Convolution between
X (n) = [6 7 8 9 10]and y (n) = [5 4 3 2 1] and see how matlab reacts to it.
30. Write the MATLAB program to perform Circular Convolution between the following
sequences X(n)=[2 -2 3 2], h(n) = [-2 4 -5 2].

Real Time Applications:


 The convolution is to determine the response y[n] of a system of a known
impulseresponse h[n] for a given input signal x[n] to obtain y[n].
 Digital Image Processing Applications such as Compression and Restoration.

Department of Electronics and Communication Engineering Page 55


BKM

Basic Simulation Lab Manual


EXPERMENT NO: 6 56

Auto correlation and cross correlation between


Signals and sequences

AIM: -
To compute auto correlation and cross correlation between signals and Sequences.

SOFTWARE REQURIED: -

1. MATLAB R2010a.
2.Windows XP SP2.

THEORY:-

In Signal processing, When the autocorrelation function is normalized by mean and


variance, it is sometimes referred to as the autocorrelation coefficient. Given a signal f(t),
the continuous autocorrelation Rff(T) is most often defined as the continuous cross-
correlation integral of f(t)with itself, at lag T

The discrete autocorrelation Rat lag j for a discrete signal x(n) is

In signal processing, cross-correlation is a measure of similarity of two waveforms as a


function of a time-lag applied to one of them. This is also known as a sliding dot product or
sliding inner- product. It is commonly used for searching a long signal for a shorter, known
feature. It has applications in pattern recognition, single particle analysis, electron
tomographic averaging, cryptanalysis, and neurophysiology.

For continuous functions f and g, the cross-correlation is defined as:

Department of Electronics and Communication Engineering Page 56


BKM

Basic Simulation Lab Manual


where f* denotes the complex conjugate of f and t is the time lag. 57

Similarly, for discrete functions, the cross-correlation is defined as:

PROCEDURE:-
 Open MATLAB
 Open new M-file
 Type the program
 Save in current directory
 Compile and Run the program
 For the output see command window\ Figure window

PROGRAM:-

%Auto correlation for a

signal%

clc;
clear all;
close all; t=0:0.001:1;
x=cos(2*pi*3*t);a=xcorr(x); subplot(2,1,1);
plot(t,x,'g');
xlabel('time'); ylabel('amplitude');title('input signal');subplot(2,1,2);
plot(a,'r');
xlabel('time'); ylabel('amplitude');
title('auto correlation signal');

Department of Electronics and Communication Engineering Page 57


BKM

Basic Simulation Lab Manual


%cross correlation for a signal% 58

clc; clear all;close all;


t=0:0.001:1;
x=cos(2*pi*3*t);y=cos(2*pi*5*t);a=xcorr(x,y);
subplot(3,1,1);
plot(t,x,'g');
xlabel('time'); ylabel('amplitude');title('1st signal'); subplot(3,1,2);
plot(t,y,'r');
xlabel('time'); ylabel('amplitude');title('2nd signal'); subplot(3,1,3);
plot(a,'r');
xlabel('time'); ylabel('amplitude');
title('cross correlation signal');

%Auto correlation for a sequence%clc;


clear
all;close
all;
x=input('enter sample
values')a=xcorr(x);
subplot(2,1,1);
stem(x,'g');
xlabel('time');
ylabel('amplitude');
title('input
sequence');
subplot(2,1,2);
stem(a,'r');
xlabel('time'); ylabel('amplitude');
title('auto correlation sequence');

Department of Electronics and Communication Engineering Page 58


BKM

Basic Simulation Lab Manual


%cross correlation for asequence% 59

clc;
clear
all;close
all;
x=input('enter first sequence'); y=input('enter second sequence');a=xcorr(x,y);
subplot(3,1,1);
stem(x,'g');
xlabel('time'); ylabel('amplitude');title('1st sequence');subplot(3,1,2);
stem(y,'r');
xlabel('time'); ylabel('amplitude'); title('2nd sequence');subplot(3,1,3);
stem(a,'r');
xlabel('time'); ylabel('amplitude');
title('cross correlation sequence');

OUTPUT:-

Auto correlation for a signal

input signal
1

0.5
amplitude

-0.5

-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
time
auto correlation signal
1000

500
amplitude

-500
0 500 1000 1500 2000 2500
time

Department of Electronics and Communication Engineering Page 59


BKM

Basic Simulation Lab Manual


60
cross correlation for a signal

1st signal
1
amplitude

-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
time
2nd signal
1
amplitude

-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
time
cross correlation signal
100
amplitude

-100
0 500 1000 1500 2000 2500
time

Auto correlation for a sequence

enter sample values [1 2 3 4]

x=

1 2 3 4

Department of Electronics and Communication Engineering Page 60


BKM

Basic Simulation Lab Manual

input sequence 61
4

3
amplitude

0
1 1.5 2 2.5 3 3.5 4
time
auto correlation sequence
30

20
amplitude

10

0
1 2 3 4 5 6 7
time

cross correlation for two sequences

enter first sequence [1 2 3 4]


enter second sequence [1 2 3 4]

1st sequence
4
amplitude

0
1 1.5 2 2.5 3 3.5 4
time
2nd sequence
4
amplitude

0
1 1.5 2 2.5 3 3.5 4
time
cross correlation sequence
40
amplitude

20

0
1 2 3 4 5 6 7
time

Department of Electronics and Communication Engineering Page 61


BKM

Basic Simulation Lab Manual


62
PROGRAM:

clc; clear all; close all;


t=0:0.01:1;
f1=3;
x1=sin(2*pi*f1*t); figure;
subplot(2,1,1);
plot(t,x1); title('sine wave');
xlabel('time >');
ylabel('amplitude >');
grid;
[rxx lag1]=xcorr(x1);
subplot(2,1,2); plot(lag1,rxx);
grid;
title('auto-correlation
function of sine wave');
figure;
subplot(2,2,1);
plot(t,x1);
title('sine wave x1');
xlabel('time >');
ylabel('amplitude >');
grid; f2=2;
x2=sin(2*pi*f2*t);
subplot(2,2,2);
plot(t,x2);
title('sine wave x2');
xlabel('time ---->');,
ylabel('amplitude >');
grid;
[cxx lag2]=xcorr(x1,x2);
subplot(2,2,[3,4]);
plot(lag2,cxx);
grid;
title('cross-correlation function
of sine wave');
Department of Electronics and Communication Engineering Page 62
BKM

Basic Simulation Lab Manual


RESULT: -
63
In this experiment correlation of various signals have been performed
UsingMATLAB.

VIVA QUESTIONS: -

1. Define Correlation?
2. Define Auto-Correlation?
3. Define Cross-Correlation?
4. What is the importance of correlation?
5. What is the difference b/w correlation and convolution?
6. Explain two Properties of Auto-Correlation?
7. Explain two Properties of Cross-Correlation?
8. What is the difference b/w Auto-correlation and Cross-
Correlation?9.Define ESD?
10.Define PSD?

EXERCISE PROGRAMS

1. Write a MATLAB program to compute auto correlation between signals and Sequences.
x=cos(2*pi*10*t),y=cos(2*pi*15*t).
2. Write a MATLAB program to compute cross correlation between signals and Sequences.
x=cos(2*pi*7*t),y=cos(2*pi*14*t).
3. Write a MATLAB program to compute the cross correleation between signals and
Sequences. x=cos(2*pi*10*t),y=cos(2*pi*15*t) by increasing the amplitude of the signal by 3
times and verify how matlab reacts to it.
4. Write a MATLAB program to compute the auto correleation between signals and Sequences.
x=cos(2*pi*15*t),y=cos(2*pi*10*t) by increasing the amplitude of the signal by 2 times and
verify how matlab reacts to it.
5. Write a MATLAB program to compute auto correlation between x =sin(2*pi*5*t) ,
y = sin(2*pi*10*t). and see how matlab reacts to it.
6. Write a MATLAB program to compute cross correlation between x =sin(2*pi*5*t) ,
y = cos(2*pi*10*t). and see how matlab reacts to it.
7. Write a MATLAB program to compute cross correlation between two signals
x=9*cos(2*pi*7*t), y=5*cos(2*pi*14*t).

Department of Electronics and Communication Engineering Page 63


BKM

Basic Simulation Lab Manual


8. Write a MATLAB program to compute cross correlation between two Sequences [1 2 3 64
45] &[9 8 7 6 5].
9. Write a MATLAB program to compute auto correlation between two signals
x=9*cos(2*pi*7*t),y=5*cos(2*pi*14*t).
10. Write a MATLAB program to compute auto correlation between two Sequences
[2 4 3 4 5] & [7 9 4 6 3].
11. Write a MATLAB program to compute auto correlation between signals and
Sequences.x=cos(2*pi*20*t),y=cos(2*pi*10*t).
12. Write a MATLAB program to compute cross correlation between signals and
Sequences.x=cos(4*pi*8*t),y=cos(4*pi*10*t).
13. Write a MATLAB program to compute the cross correleation between signals and
Sequences. x=cos(2*pi*20*t),y=cos(2*pi*10*t) by increasing the amplitude of the signal by 2
times and verify how matlab reacts to it.
14. Write a MATLAB program to compute the auto correleation between signals and
Sequences. x=cos(2*pi*5*t),y=cos(2*pi*20*t) by increasing the amplitude of the signal by 4
times and verify how matlab reacts to it.
15. Write a MATLAB program to compute auto correlation between x =sin(2*pi*5*t) , y =
sin(4*pi*20*t). and see how matlab reacts to it.
16. Write a MATLAB program to compute cross correlation between x = sin(3*pi*5*t) , y =
cos(4*pi*5*t). and see how matlab reacts to it.
17. Write a MATLAB program to compute cross correlation between two signals
x=4*cos(2*pi*5*t),y=6*cos(2*pi*10*t).
18. Write a MATLAB program to compute cross correlation between two Sequences [2 6 4 8
5]& [8 9 6 7 5].
19. Write a MATLAB program to compute auto correlation between two signals
x=5*cos(2*pi*10*t),y=5*cos(2*pi*10*t).
20. Write a MATLAB program to compute auto correlation between two Sequences [1 1 4 4
5]& [9 9 7 5 5].
21. Write a MATLAB program to compute auto correlation between signals and
Sequences.x=cos(3*pi*10*t),y=cos(4*pi*5*t).

Department of Electronics and Communication Engineering Page 64


BKM

Basic Simulation Lab Manual


22. Write a MATLAB program to compute cross correlation between signals and Sequences. 65
x=cos(6*pi*6*t),y=cos(4*pi*5*t).
23. Write a MATLAB program to compute the cross correleation between signals and
Sequences. x=cos(2*pi*10*t),y=cos(2*pi*5*t) by increasing the amplitude of the signal by 3
times and verify how matlab reacts to it.
24. Write a MATLAB program to compute the auto correleation between signals and
Sequences. x=cos(4*pi*5*t),y=cos(2*pi*5*t) by increasing the amplitude of the signal by 4
times and verify how matlab reacts to it.
25. Write a MATLAB program to compute auto correlation between x =sin(4*pi*5*t) , y =
sin(4*pi*10*t). and see how matlab reacts to it.
26. Write a MATLAB program to compute auto correlation between x =sin(4*pi*2*t) , y =
sin(4*pi*20*t). and see how matlab reacts to it.
27. Write a MATLAB program to compute cross correlation between x = sin(3*pi*2*t) , y =
cos(5*pi*5*t). and see how matlab reacts to it.
28. Write a MATLAB program to compute auto correlation between two signals
x=4*cos(2*pi*10*t),y=6*cos(6*pi*10*t).
29. Write a MATLAB program to compute cross correlation between two Sequences [2 6 4 8
5] & [8 9 6 7 5].
30. Write a MATLAB program to compute auto correlation between two signals
x=5*cos(8*pi*10*t),y=6*cos(7*pi*10*t).

Real Time Applications:


 Correlation is used to extract second (and higher) order statistics from any
randomsignal.
 Explains Energy and Power of Continuous and discrete systems.

Department of Electronics and Communication Engineering Page 65


BKM

Basic Simulation Lab Manual


66
EXPERMENT NO:7

Verification of linearity and time invariance properties of a given


continuous /discrete system.
AIM: -

To compute linearity and time invariance properties of a given continuous /discrete


System.

SOFTWARE REQURIED: -

1.MATLAB R2010a.
2.Windows XP SP2.

THEORY:-

LINEARITY PROPERTY

a) Homogeneity
b) Superposition

Department of Electronics and Communication Engineering Page 66


BKM

Basic Simulation Lab Manual


67
LINEAR TIME INVARIENT SYSTEMS(LTI)

PROCEDURE:-
 Open MATLAB
 Open new M-file
 Type the program
 Save in current directory
 Compile and Run the program
 For the output see command window\ Figure window

Department of Electronics and Communication Engineering Page 67


BKM

Basic Simulation Lab Manual


PROGRAM: - 68

%Program1:%
clc;
clear all; close all;
n=0:40; a=2; b=1;
x1=cos(2*pi*0.1*n);
x2=cos(2*pi*0.4*n);
x=a*x1+b*x2;
y=n.*x;
y1=n.*x1;
y2=n.*x2;
yt=a*y1+b*y2;
d=y-yt;
d=round(d)
if d
disp('Given system is not
satisfy linearity property');
else
disp('Given system is satisfy
linearity property');
end
subplot(3,1,1), stem(n,y);
grid;
subplot(3,1,2), stem(n,yt);
grid;
subplot(3,1,3), stem(n,d);
grid;

Department of Electronics and Communication Engineering Page 68


BKM

Basic Simulation Lab Manual


69

%Program2:%
clc;
clear all; close all;
n=0:40;
a=2; b=-3;
x1=cos(2*pi*0.1*n);
x2=cos(2*pi*0.4*n);
x=a*x1+b*x2;
y=x.^2;
y1=x1.^2;
y2=x2.^2;
yt=a*y1+b*y2;
d=y-yt;
d=round(d);
if d
disp('Given system is
not satisfy linearity
property'); else
disp('Given system is
satisfy linearity
property'); end
subplot(3,1,1),
stem(n,y); grid;
subplot(3,1,2),
stem(n,yt); grid;
subplot(3,1,3),
stem(n,d);
grid;

Department of Electronics and Communication Engineering Page 69


BKM

Basic Simulation Lab Manual


70
%Program3:%
clc;
close all; clear all;
n=0:40; D=10;
x=3*cos(2*pi*0.1*n)-
2*cos(2*pi*0.4*n);
xd=[zeros(1,D) x];
y=n.*xd(n+D);
n1=n+D;
yd=n1.*x; d=y-yd;
if d
disp('Given system is
not satisfy time
shifting property');
else
disp('Given system is
satisfy time shifting
property'); end
subplot(3,1,1),
stem(y),
grid;
subplot(3,1,2),
stem(yd),
grid;
subplot(3,1,3),
stem(d),
grid;

Department of Electronics and Communication Engineering Page 70


BKM

Basic Simulation Lab Manual


VIVA QUESTIONS: - 71
1. Define Systems?
2. What is LTI Systems?
3. Describe LTV Systems?
4. What is the importance of Linear Systems?
5. What is the difference b/w Linear and Non-Linear Systems?
6. Explain two Properties of LTI Systems?
7. Explain two Properties of LTV Systems?
8. What is the Superposition Principal?
9.What is Difference between CT and DT systems?10.Define Causality of LTI Systems?

EXSERCISE QUESTIONS

1. Write a MATLAB program to verify the linearity prpoerty of the following


sequency x1= sin(2*pi*1*n); x2= sin(2*pi*2*n), and chech whether it satisfies the
linearity property or not.
2. Write a MATLAB program to verify the linearity prpoerty of the following
sequency x1= sin(2*pi*1*n); x2= sin(2*pi*2*n), and chech whether it satisfies the
linearity property or not
3. Write a MATLAB program to verify the linearity prpoerty of the following
sequency x1= sin(2*pi*0.1*n); cos(2*pi*0.3*n), and chech whether it satisfies the
linearity property or not
4. Write a MATLAB program to verify the time invariance prpoerty of the following
sequency x1= sin(2*pi*1*n); x2= sin(2*pi*2*n), and chech whether it satisfies the
time invariance property or not.
5. Write a MATLAB program to verify the time invariance prpoerty of the following
sequency x1= sin(2*pi*1*n); x2= sin(2*pi*2*n), and chech whether it satisfies the
time invariance property or not
6. Write a MATLAB program to verify the time invariance prpoerty of the following
sequency x1= sin(2*pi*0.1*n); cos(2*pi*0.3*n), and chech whether it satisfies the
time invariance property or not.
7. Write a MATLAB program to verify the time variance prpoerty of the following
sequency x1= sin(2*pi*0.1*n); cos(2*pi*0.3*n), and chech whether it satisfies the
time invariance property or not.
8. Write a MATLAB program to verify the non linearity prpoerty of the following
sequency x1= sin(2*pi*0.1*n); cos(2*pi*0.3*n), and chech whether it satisfies the
linearity property or not
9. Write a MATLAB program to verify the time variance prpoerty of the following
sequency x1= sin(2*pi*1*n); x2= sin(2*pi*2*n), and check whether it satisfies the
time invariance property or not.

Department of Electronics and Communication Engineering Page 71


BKM

Basic Simulation Lab Manual


10. Write a MATLAB program to verify the non linearity prpoerty of the following 72
sequency x1= sin(2*pi*1*n); x2= sin(2*pi*2*n), and check whether it satisfies the
linearity property or not.
11. Write a MATLAB program to verify the linearity prpoerty of the following
sequency x1= sin(2*pi*1*n); x2= sin(2*pi*2*n), and check whether it satisfies the
linearity property or not.
12. Write a MATLAB program to verify the linearity prpoerty of the following
sequency x1= sin(2*pi*1*n); x2= sin(2*pi*2*n), and check whether it satisfies the
linearity property or not
13. Write a MATLAB program to verify the linearity prpoerty of the following
sequency x1= sin(2*pi*0.1*n); cos(2*pi*0.3*n), and check whether it satisfies the
linearity property or not
14. Write a MATLAB program to verify the time invariance prpoerty of the following
sequency x1= sin(2*pi*1*n); x2= sin(2*pi*2*n), and check whether it satisfies the
time invariance property or not.
15. Write a MATLAB program to verify the time invariance prpoerty of the following
sequency x1= sin(2*pi*1*n); x2= sin(2*pi*2*n), and check whether it satisfies the
time invariance property or not
16. Write a MATLAB program to verify the time invariance prpoerty of the following
sequency x1= sin(2*pi*0.1*n); cos(2*pi*0.3*n), and check whether it satisfies the
time invariance property or not.
17. Write a MATLAB program to verify the time variance prpoerty of the following
sequency x1= sin(2*pi*0.1*n); cos(2*pi*0.3*n), and check whether it satisfies the
time invariance property or not.
18. Write a MATLAB program to verify the non linearity prpoerty of the following
sequency x1= sin(2*pi*0.1*n); cos(2*pi*0.3*n), and check whether it satisfies the
linearity property or not
19. Write a MATLAB program to verify the time variance prpoerty of the following
sequency x1= sin(2*pi*1*n); x2= sin(2*pi*2*n), and check whether it satisfies the
time invariance property or not.
20. Write a MATLAB program to verify the non linearity prpoerty of the following
sequency x1= sin(2*pi*1*n); x2= sin(2*pi*2*n), and check whether it satisfies the
linearity property or not.
21. Write a MATLAB program to verify the linearity prpoerty of the following
sequency x1= sin(2*pi*1*n); x2= sin(2*pi*2*n), and check whether it satisfies the
linearity property or not.
22. Write a MATLAB program to verify the linearity prpoerty of the following
sequency x1= sin(2*pi*1*n); x2= sin(2*pi*2*n), and check whether it satisfies the
linearity property or not
23. Write a MATLAB program to verify the linearity prpoerty of the following
sequency x1= sin(2*pi*0.1*n); cos(2*pi*0.3*n), and check whether it satisfies the
linearity property or not
24. Write a MATLAB program to verify the time invariance prpoerty of the following
sequency x1= sin(2*pi*1*n); x2= sin(2*pi*2*n), and check whether it satisfies the
time invariance property or not.

Department of Electronics and Communication Engineering Page 72


BKM

Basic Simulation Lab Manual


25. Write a MATLAB program to verify the time invariance prpoerty of the following 73
sequency x1= sin(2*pi*1*n); x2= sin(2*pi*2*n), and check whether it satisfies the
time invariance property or not.
26. Write a MATLAB program to verify the time invariance prpoerty of the following
sequency x1= sin(2*pi*1*n); x2= sin(2*pi*12*n), and check whether it satisfies the
time invariance property or not
27. Write a MATLAB program to verify the time invariance prpoerty of the following
sequency x1= sin(2*pi*0.1*n); 2*cos(2*pi*0.5*n), and check whether it satisfies the
time invariance property or not.
28. Write a MATLAB program to verify the time variance prpoerty of the following
sequency x1= cos(2*pi*0.1*n); cos(2*pi*0.4*n), and check whether it satisfies the
time invariance property or not.
29. Write a MATLAB program to verify the non linearity prpoerty of the following
sequency x1= sin(2*pi*0.1*n); sin(2*pi*0.3*n), and check whether it satisfies the
linearity property or not
30. Write a MATLAB program to verify the time variance prpoerty of the following
sequency x1=6* sin(2*pi*10*n); x2= sin(2*pi*2*n), and check whether it satisfies
the time invariance property or not.

Real Time Applications:

 Wave Propagation such as sound and electromagnetic waves.


 Electrical circuits composed of resistors, capacitors and inductors.
 Robotics Applications.

Department of Electronics and Communication Engineering Page 73


BKM

Basic Simulation Lab Manual


EXPERMENT NO:8 74

Computation of unit sample, unit step and sinusoidal response


of the given LTI system and verifying its physical reliability and
stability Properties.

AIM: -
To Unit Step and Sinusoidal Response of The Given LTI System And Verifying Its
Physical Reliability And Stability Properties.

SOFTWARE REQURIED: -

1.MATLAB R2010a.
2.Windows XP SP2.

THEORY: -

A discrete time system performs an operation on an input signal based on predefined


criteria to produce a modified output signal. The input signal x(n) is the system excitation,
and y(n) is the system response. The transform operation is shown as,
If the input to the system is unit impulse i.e. x(n) = δ(n) then the output of the

system isknown as impulse response denoted by h(n) where,


h(n) = T[δ(n)]
we know that any arbitrary sequence x(n) can be represented as a weighted
sum ofdiscrete impulses. Now the system response is given by,

For linear system (1) reduces to

Department of Electronics and Communication Engineering Page 74


BKM

Basic Simulation Lab Manual


75
PROCEDURE: -

 Open MATLAB
 Open new M-file
 Type the program
 Save in current directory
 Compile and Run the program
PROGRAM: -
%calculate and plot the
impulse response and step
response%
clc;
clear all;
close all;
b=[1];
a=[1,-1,.9];
x=impseq(0,-20,120);
n = [-20:120];
h=filter(b,a,x);
subplot(3,1,1);
stem(n,h);
title('impulse response');
xlabel('n');
ylabel('h(n)');
=stepseq(0,-20,120);
s=filter(b,a,x);
s=filter(b,a,x);
subplot(3,1,2);
stem(n,s);
title('step response');
xlabel('n');
ylabel('s(n)');
t=0:0.1:2*pi;
x1=sin(t);
%impseq(0,-20,120);
n = [-20:120];
h=filter(b,a,x1);
subplot(3,1,3);stem(h);
title('sin response');
xlabel('n');
ylabel('h(n)'); figure;
zplane(b,a);

Department of Electronics and Communication Engineering Page 75


BKM

Basic Simulation Lab Manual


76
PROGRAM:-

clc; clear all;


close all;
syms s complex;
H=1/(s^2+4*s+3);
disp('Impulse response of the
system h(t) is'); h=ilaplace(H);
simplify(h); disp(h);
Y=1/(s*(s^2+4*s+3));
disp('Step response of the
system is');
y=ilaplace(Y);
simplify(y); disp(y);
t=0:0.1:20;
h1=subs(h,t);
subplot(2,1,1);
plot(t,h1);
xlabel('time');
ylabel('h(t)');
title('Impulse response of the
system'); y1=subs(y,t);
subplot(2,1,2);
plot(t,y1);
xlabel('time');
ylabel('x(t)');
title('step response of the
system');

Impulse response of a system h (t) is exp (-2*t)*sinh (t).


The step response of a system is 1/6*exp (-3*t)-1/2*exp (-t) +1/3.

Department of Electronics and Communication Engineering Page 76


BKM

Basic Simulation Lab Manual


77

RESULT: -
In this experiment computation of unit sample, unit step and sinusoidal response of the
given LTI system and verifying its physical Reliability and Stability Properties using MATLAB.

VIVA QUESTIONS: -
1.What operations can be performed on signals and sequence?
2.Define causality?
3. Define scaling property and give its importance?
4.Define shifting property and give its importance?
5.Define folding property and give its importance?
6.Define stability?
7.Give the importance of Causality?
8.Give the importance of Stability?
9. Define Impulse Response?
10.Define Step Response?

Department of Electronics and Communication Engineering Page 77


BKM

Basic Simulation Lab Manual


EXERCISE PROGRAM: - 78
1. Write a MATLAB program for generating u(n)-u(n-1).
2. Write a MATLAB program for generating delayed unit step response
3. Write a MATLAB program for generating delayed impulse response
4. Write a MATLAB program for generating u(n)+u(n-1) and verify how matlab reacts to it.
5. write a MATLAB program to find the energy & power of the signal x(t)=10sin(10t).
6. write a MATLAB program to find the even & odd of the signal x(t)=e^2t.
7. write a MATLAB program to find the even & odd of the signal x(t)=sin(t).
8. write a MATLAB program to find the even & odd of the signal x(t)=cos(t).
9. write a MATLAB program to find the energy & power of the signal x(t)=sin(t).
10. write a MATLAB program to find the energy & power of the signal x(t)=e^2t.
11. Write a MATLAB program for generating u(n-2)-u(n-1).
12. Write a MATLAB program for generating delayed step response with magnitude 2
13. Write a MATLAB program for generating delayed impulse response with magnitude 2.
14. Write a MATLAB program for generating u(n+1)+u(n-1) and verify how matlab reacts to it.
15. Write a MATLAB program to find the energy & power of the signal x(t)=20sin(5t).
16. Write a MATLAB program to find the even & odd of the signal x(t)=e^3t.
17. Write a MATLAB program to find the even & odd of the signal x(t)=sin(t)+cos(t).
18. Write a MATLAB program to find the even & odd of the signal x(t)=cos(t)-sin(t).
19. Write a MATLAB program to find the energy & power of the signal x(t)=sin(t)-cos(t).
20. Write a MATLAB program to find the energy & power of the signal x(t)=e^4t.
21. Write a MATLAB program for generating u(n+2)-u(n-1).
22. Write a MATLAB program for generating delayed unit step response
23. Write a MATLAB program for generating delayed impulse response
24. Write a MATLAB program for generating u(n-3)+u(n-1) and verify how matlab reacts to it.
25. Write a MATLAB program to find the energy & power of the signal x(t)=5sin(20t).
26. Write a MATLAB program to find the energy & power of the signal x(t)=30sin(5t).
27. Write a MATLAB program to find the even & odd of the signal x(t)=e^4t.
28. Write a MATLAB program to find the even & odd of the signal x(t)=sin(t)-cos(t).
29. Write a MATLAB program to find the even & odd of the signal x(t)=cos(t)-2sin(t).
30. Write a MATLAB program to find the energy & power of the signal x(t)=sin(t)-3cos(t).

Real Time Applications:


 Electronic Circuits such as amplifiers and filters.
 Mechanical motion from the interaction of masses, springs and dashpots (dampers).
 LTI systems

Department of Electronics and Communication Engineering Page 78


BKM

Basic Simulation Lab Manual


EXPERMENT NO:9 79
Demonstration of Gibbs Phenomenon
AIM: -

To demonstrate Gibbs Phenomenon using MATLAB.

SOFTWARE REQURIED: -

1.MATLAB R2010a.
2.Windows XP SP2.

THEORY: -
Gibbs Phenomenon:
The peculiar manner in which the Fourier series of a piecewise continuously differentiable
periodic function behaves at a jump discontinuity: the nth partial sum of the Fourier series has
large oscillations near the jump, which might increase the maximum of the partial sum above
that of the function itself. The overshoot does not die out as the frequency increases, but
approaches a finite limit. The Gibbs phenomenon involves both the fact that Fourier sums
overshoot at a jump discontinuity, and that this overshoot does not die out as the frequency
increases.
The best known version of the Gibbs phenomenon is the overshoot that arises when a
discontinuous function is represented by a truncated set of Fourier expansion terms. The
situation is similar if the truncated Fourier expansion is instead obtained by means of
interpolation on an equi spaced grid.

PROCEDURE: -
 Open MATLAB
 Open new M-file
 Type the program
 Save in current directory
 Compile and Run the program
 For the output see command window\ Figure window

Department of Electronics and Communication Engineering Page 79


BKM

Basic Simulation Lab Manual


PROGRAM: - 80

%Gibbs phenomenon%

clc;
clear all;
close all; t=0:0.01:1;
N=input('enter no of harmonics');
x=square(2*pi*t);
plot(t,x);
hold on;
gp=0;
for n=1:2:N;
gp=gp+(4/(n*pi))*sin(2*pi*n*t);
end; plot(t,gp); hold off;
xlabel('time');
ylabel('amplitude');
title('gibbs phenomenon');

OUTPUT: -
Gibbs phenomenon

enter no of harmonics 5
Gibbs Phenomenon
1.5

0.5
amplitude

-0.5

-1

-1.5
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
time

Department of Electronics and Communication Engineering Page 80


BKM

Basic Simulation Lab Manual


81
PROGRAM: -

clc; clear all;


close all;
N=input('enter the no. of signals to reconstruct=');
n_har=input('enter the no. of harmonics in each
signal=');
t=-1:0.001:1;
omega_0=2*pi;
for k=1:N
x=0.5;
for n=1:2:n_har(k) b_n=2/(n*pi);
x=x+b_n*sin(n*omega_0*t);
end subplot(N,1,k);
plot(t,x); xlabel('time--->');
ylabel('amp>');
axis([-1 1 -0.5 1.5]);
text(0.55,1.0,['no.of har=',num2str(n_har(k))]);
end

enter the no. of signals to reconstruct=3


enter the no. of harmonics in each signal=[3,5,59]
RESULT: -
In this experiment Gibbs phenomenon have been demonstratedUsing MATLAB.
EXERCISE PROGRAM: -
1. Write the MATLAB program to perform convolution between the following
sequencesX(n)=[1 8 9 3 ], h(n) = [ 2 4 5 9].
2. Write a mat lab program to perform the convolution between sinusoidal and ramp
function andsee how mat lab reacts to it.
3. Write a MATLAB program to perform convolution between square and step signal
and seehow mat lab reacts to it.
4. Write a MATLAB program to perform convolution between sinusoidal and ramp signal
andsee how mat lab reacts to it.
5. Write a MATLAB program to perform the convolution between X (n) = [8 5 6 9] and y
(n) =[- 1 – 2] and see how matlab reacts to it.
6. Write a MATLAB program to perform the convolution between X (n) = [1 -3 4 5] and y
(n) =[1 2 3 4] and see how matlab reacts to it.
7. Write a MATLAB program to perform the convolution between X (n) = [1 0 1 1] and y
(n) =[1 0 0 0 0] and see how matlab reacts to it.
8. Write a MATLAB program to perform the convolution between X (n) = [1 1 1 1 0 0 0 0] and
y (n) = [1 0 1 0 1 0 1 0] and see how matlab reacts to it.
9. Write a MATLAB program to perform the convolution between X (n) = [1 1 0 0] and y
(n) =[1 1 1 1] and see how matlab reacts to it.
Department of Electronics and Communication Engineering Page 81
BKM

Basic Simulation Lab Manual


10. Write a MATLAB program to perform the convolution between X (n) = [6 9 7 5 2] and y (n)
82
= [8 5 6 4 2] and see how matlab reacts to it.
11. Write the MATLAB program to perform convolution between the following
sequencesX(n)=[2 4 9 3], h(n) = [1 3 7 5].
12. Write a mat lab program to perform the convolution between step and ramp function
and seehow mat lab reacts to it.
13. Write a MATLAB program to perform convolution between sinusoidal and step signal
andsee how mat lab reacts to it.
14. Write a MATLAB program to perform convolution between impulse and ramp signal
and seehow mat lab reacts to it.
15. Write a MATLAB program to perform the convolution between X (n) = [3 2 6 9] and y
(n) =[-2 –4] and see how matlab reacts to it.
16. Write a MATLAB program to perform the convolution between X (n) = [2 -4 2 5] and y (n)
= [4 2 3 4] and see how matlab reacts to it.
17. Write a MATLAB program to perform the convolution between X (n) = [2 1 0 1] and y
(n) =[1 0 1 1] and see how matlab reacts to it.
18. Write a MATLAB program to perform the convolution between X (n) = [1 2 1 2 0 1 0 1]
andy (n) = [2 0 1 1 0 0 2 0] and see how matlab reacts to it.
19. Write a MATLAB program to perform the convolution between X (n) = [2 2 0 2] and y
(n) =[1 1 2 2] and see how matlab reacts to it.
20. Write a MATLAB program to perform the convolution between X (n) = [2 1 4 5 3] and y (n)
= [2 1 6 2 1] and see how matlab reacts to it.
21. Write the MATLAB program to perform convolution between the following
sequencesX(n)=[2 8 7 3], h(n) = [1 4 2 9].
22. Write a mat lab program to perform the convolution between sinusoidal and ramp
functionand see how mat lab reacts to it.
23. Write a MATLAB program to perform convolution between square and step signal
and seehow mat lab reacts to it.
24. Write a MATLAB program to perform convolution between sinusoidal and ramp signal
andsee how mat lab reacts to it.
25. Write a MATLAB program to perform the convolution between X (n) = [4 5 2 1] and y
(n) =[-2 – 1] and see how matlab reacts to it.
26. Write a MATLAB program to perform the correlation between X (n) = [1 1 1 1 0 0 0 0] and
y (n) = [1 0 1 0 1 0 1 0] and see how matlab reacts to it.
27. Write a MATLAB program to perform the correlation between X (n) = [1 1 0 0] and y
(n) =[1 1 1 1] and see how matlab reacts to it.
28. Write a MATLAB program to perform the correlation between X (n) = [6 9 7 5 2] and y
(n) =[8 5 6 4 2] and see how matlab reacts to it.
29. Write the MATLAB program to perform correlation between the following
sequencesX(n)=[2 4 9 3], h(n) = [1 3 7 5].
Department of Electronics and Communication Engineering Page 82
BKM

Basic Simulation Lab Manual


30. Write a mat lab program to perform the correlation between step and ramp function
83
and seehow mat lab reacts to it.

VIVA QUESTIONS: -
1. Define Gibb’s Phenomenon?
2. What is the importance of Gibb’s Phenomenon?
3. What is Static and Dynamic System?
4. What is Causal Signal?
5. What is Causality Condition of the Signal?
6. Define Noise?
7. What is the importance of FS?
8. What is the importance of FT?
9. Define LTV system?
10.Define LTI system?
Real Time Applications:
 The Gibbs phenomenon, discovered by Henry Wilbraham and rediscovered by J.
Willard Gibbs (1899), is the peculiar manner in which the Fourier series of a
piecewise continuously differentiable periodic function behaves at a jump discontinuity.
 To Eliminate noise in Filters.

Department of Electronics and Communication Engineering Page 83


BKM

Basic Simulation Lab Manual


EXPERMENT NO: 10 84

Finding the Fourier transform of a given signal and plot its


magnitude and phase spectrum
AIM: -
To obtain Fourier Transform and Inverse Fourier Transform of a givensignal / sequence and
to plot its Magnitude and Phase Spectra.

SOFTWARE REQURIED: -

1.MATLAB R2010a.
2.Windows XP SP2.

THEORY: -
Fourier Transform Theorems:

We may use Fourier series to motivate the Fourier transform as follows. Suppose that ƒ is a
function which is zero outside of some interval [−L/2, L/2]. Then for any T ≥ L we may expand ƒ
in a Fourier series on the interval [−T/2,T/2], where the "amount" of the wave e2πinx/T in the
Fourier series of ƒ is given by

By definition

Department of Electronics and Communication Engineering Page 84


BKM

Basic Simulation Lab Manual


The fast Fourier transform (FFT) is an efficient algorithm for computing the DFT of a 85
sequence; it is not a separate transform. It is particularly useful in areas such as signal and
image processing, where its uses range from filtering, convolution, and frequency analysis to
power spectrum estimation
For length N input vector x, the DFT is a length N vector X, with elementsN
X(k) = sum x(n)*exp(-j*2*pi*(k-1)*(n-1)/N), 1 <= k <= N.n=1

The inverse DFT (computed by IFFT) is given by N


x(n) = (1/N) sum X(k)*exp( j*2*pi*(k-1)*(n-1)/N), 1 <= n <= N.k=1

PROCEDURE: -
 Open MATLAB
 Open new M-file
 Type the program
 Save in current directory
 Compile and Run the program
 For the output see command window\ Figure window

Department of Electronics and Communication Engineering Page 85


BKM

Basic Simulation Lab Manual


PROGRAM: - 86

%Fourier Transform%
clc;
clear all;
close all;
syms t;
x=exp(-2*t)*heaviside(t);
y=fourier(x);
disp('Fourier Transform of input signal'); y
z=ifourier(y);
disp('Inverse Fourier Transform of input signal'); z
mg=abs(y);
subplot(2,1,1);
ezplot(mg); xlabel('time'); ylabel('amplitude');
title('magnitude spectrum of a input signal'); grid;
pha=atan(imag(y)/real(y)); subplot(2,1,2); ezplot(pha);
xlabel('time'); ylabel('amplitude');
title('phasespectrum of a input signal'); grid;

OUTPUT:-
Fourier Transform
Fourier Transform of input signal Y=
1/(2+w*i)
Inverse Fourier Transform of input signal Z=
Heaviside(x)/exp(2*x)

Department of Electronics and Communication Engineering Page 86


BKM

Basic Simulation Lab Manual


PROGRAM:- To find inverse Fourier transforms of Given functions.
87
To find Fourier transform F1=A*pi*(dirac(w-o)+dirac(w+o));
clc; clear all; close all; syms t s; f1=ifourier(F1,t);
syms w real; disp('the inverse fourier transform of …………..
syms A real; ………………….A*pi*(dirac(w-o)+dirac(w+o)=');
syms o real; disp(f1);
syms b float; F2=A*pi*(dirac(w-o)-dirac(w+o))/i;
f=dirac(t); f2=ifourier(F2,t);
F=fourier(f); disp('the inverse fourier transform of……………..
disp('the fourier transform of dirac(t) ='); ……………..A*pi*(dirac(w-o)+dirac(w+o)/i=');
disp(F); disp(f2);
f1=A*heaviside(t); F1=fourier(f1); F3=A/(1+i*w); f3=ifourier(F3,t);
disp('the fourier transform of A ='); disp(F1); disp('the inverse fourier transform of A/(1+jw)=');
f2=A*exp(-t)*heaviside(t); F2=fourier(f2); disp(f3);
disp('the fourier transform of exp(-t) ='); F4=(3*i*w+14)/((i*w)^2+7*i*w+12); f4=ifourier(F4,t);
disp(F2); disp('the inverse fourier transform of……….
f3=A*t*exp(-b*t)*heaviside(t); F3=fourier(f3); …………..(3*i*w+14)/((i*w)^2+7*i*w+12)=');
disp('the fourier transform of A*t*exp(-b*t)*u(t) disp(f4);
='); disp(F3);
f4=sin(o*t);
F4=fourier(f4);
disp('the fourier transform of sin(o*t) =');
disp(F4);
OUTPUT:-
the fourier transform of dirac(t) =1
the fourier transform of A =A*(pi*dirac(w)-i/w)the fourier transform of exp(-t) = A/(1+i*w)
the fourier transform of A*t*exp(-b*t)*u(t) = A/(b+i*w)^2
the fourier transform of sin(o*t) = *pi*(dirac(w+o)-dirac(w-o))
the inverse fourier transform of A*pi*(dirac(w-o)+dirac(w+o)=A*cos(o*t)
the inverse fourier transform of A*pi*(dirac(w-o)+dirac(w+o)/i=A*sin(o*t)
the inverse fourier transform of A/(1+jw)=A*exp(-t)*heaviside(t)
the inverse fourier transform of (3*i*w+14)/((i*w)^2+7*i*w+12)=heaviside(t)*(-2*exp(-4*t)+5*exp(-3*t))

Department of Electronics and Communication Engineering Page 87


BKM

Basic Simulation Lab Manual


magnitude spectrum of a input signal 88
0.5

0.4
amplitude

0.3

0.2

-6 -4 -2 0 2 4 6
time
phasespectrum of a input signal

1
amplitude

-1

-6 -4 -2 0 2 4 6
Time
RESULT: -
In this experiment the Fourier transform of a given signal and plotting its magnitude
and phase spectrum have been demonstrated using MATLAB.
Magnitude and Phase Spectrum of Fourier Transform
PROGRAM:-
clc; clear all; close all; syms t s ;
syms w float;
f=3*exp(-t)*heaviside(t);
F=fourier(f);
disp('the fourier transform of ……..
………..3*exp(-t)*u(t) =');
disp(F);
w=-2*pi:pi/50:2*pi;
F1=subs(F,w);
Fmag=abs(F1); % to find magnitude
Fphas=angle(F1); % to find phase
subplot(2,1,1);
plot(w,Fmag); xlabel('w >');
ylabel('Magnitude>');
title('Magnitude spectrum'); grid;
subplot(2,1,2); plot(w,Fphas);
xlabel('w>');
ylabel('Phase in radians>');
title('Phase spectrum'); grid;

Department of Electronics and Communication Engineering Page 88


BKM

Basic Simulation Lab Manual


89
VIVA QUESTIONS: -
1. Define Fourier Series?
2. What are the properties of Continuous-Time Fourier Series?
3. What is the Sufficient condition for the existence of F.T?
4. Define the F.T of a signal?
5.What is the difference b/w F.T&F.S?
6.Define Scaling Property of FT?
7. Explain Time Convolution Property of FT?
8. Explain Frequency Convolution Property of FT?
9. Explain the linearity property?
10. Describe the advantages of FT?

EXERCISE PROGRAMS
1. Write a MATLAB program to find the cross correlation using FFT.
2. Write a MATLAB program to find F.T of the causal signal x(t)=t
3. Write a MATLAB program to find F.T of the causal signal x(t)=e^-at
4. Write a MATLAB program to find F.T of the causal signal x(t)=e^at
5. Write a MATLAB program to find F.T of the causal signal x(t)=te^at
6. Write a MATLAB program to find F.T of the causal signal x(t)=te^-at
7. Write a MATLAB program to find F.T of the causal signal x(t)=cost
8. Write a MATLAB program to find F.T of the causal signal x(t)=sint
9. Write a MATLAB program to find F.T of the causal signal x(t)=e^atcos(t)
10. Write a MATLAB program to find F.T of the causal signal x(t)= e^atsin(t)
11. Write a MATLAB program to find the cross correlation using DFT.
12. Write a MATLAB program to find F.T of the causal signal x(t)=at
13. Write a MATLAB program to find F.T of the causal signal x(t)=10e^-at
14. Write a MATLAB program to find F.T of the signal x(t)=1
15. Write a MATLAB program to find F.T of the causal signal x(t)=impulse function
16. Write a MATLAB program to find F.T of the causal signal x(t)=Delta function
17. Write a MATLAB program to find F.T of the causal signal x(t)=cos(at)
18. Write a MATLAB program to find F.T of the causal signal x(t)=sin(at)
19. Write a MATLAB program to find F.T of the causal signal x(t)=e^atcos(at)
20. Write a MATLAB program to find F.T of the causal signal x(t)= e^atsin(at)
21. .Write a MATLAB program to find the auto correlation using FFT.
22. Write a MATLAB program to find F.T of the causal signal x(t)=5t
23. Write a MATLAB program to find F.T of the causal signal x(t)=5e^-at
24. Write a MATLAB program to find F.T of the causal signal x(t)=5e^at
25. Write a MATLAB program to find F.T of the causal signal x(t)=5te^at
26. Write a MATLAB program to find F.T of the causal signal x(t)=e^-2t
27. Write a MATLAB program to find F.T of the causal signal x(t)=e^5t
Department of Electronics and Communication Engineering Page 89
BKM

Basic Simulation Lab Manual


28. Write a MATLAB program to find F.T of the causal signal x(t)=te^4t
90
29. Write a MATLAB program to find F.T of the causal signal x(t)=te^-4t
30. Write a MATLAB program to find F.T of the causal signal x(t)=4cost

Real Time Applications:


Fourier transforms having following applications
 Analysis of differential equations
 Fourier transform spectroscopy
 Quantum mechanics
 Signal processing applications etc

Department of Electronics and Communication Engineering Page 90


BKM

Basic Simulation Lab Manual


EXPERMENT NO:11 91
Waveform Synthesis using Laplace Transform
AIM: -
To perform waveform synthesis using Laplace Transforms of a given signal

SOFTWARE REQURIED: -1.

MATLAB R2010a.
2.Windows XP SP2.

THEORY: -

Bilateral Laplace transform:


When one says "the Laplace transform" without qualification, the unilateral or one-sided
transform is normally intended. The Laplace transform can be alternatively defined as the
bilateral Laplace transform or two-sided Laplace transform by extending the limits of
integration to be the entire real axis. If that is done the common unilateral transform, simply
becomes a special case of the bilateral transform where the definition of the function being
transformed is multiplied by the Heaviside step function.

Inverse Laplace transform

The inverse Laplace transform is given by the following complex integral, which is known by
various names (the Bromwich integral, the Fourier-Mellin integral, and Mellin's inverse formula):

Department of Electronics and Communication Engineering Page 91


BKM

Basic Simulation Lab Manual


92
Example:
Let y(t)=u(t). We have

The integral converges if s>1. The functions exp(t) and 1/(s-1) are partner functions.

Department of Electronics and Communication Engineering Page 92


BKM

Basic Simulation Lab Manual


PROCEDURE: - 93
 Open MATLAB
 Open new M-file
 Type the program
 Save in current directory
 Compile and Run the program
 For the output see command window\ Figure window

PROGRAM:-

%Laplace Transform%
clc
clear all;close all;syms t;
x=exp(-2*t)*heaviside(t);y=laplace(x);
disp('Laplace Transform of input
signal');y
z=ilaplace(y);
disp('Inverse Laplace Transform of input signal');z

OUTPUT: -

Laplace Transform

Laplace Transform of input


signalY=
1/(s+2)
Inverse Laplace Transform of input
signalZ=
1/exp(2*t)

RESULT: -

Laplace and inverse laplace transforms were verified using MATLAB functions.

VIVA QUESTIONS: -

1. Define Laplace-Transform?
2. What is the Condition for Convergence of the L.T?
3. What is the Region of Convergence(ROC)?
4. State the Shifting property of L.T?
5. State convolution Property of L.T?6.Define Scaling Property of L.T?
7. Explain Time Convolution Property of L.T?
8. Explain Frequency Convolution Property of L.T?
9. Explain the linearity property of L.T?10.Describe the advantages of L.T?

Department of Electronics and Communication Engineering Page 93


BKM

Basic Simulation Lab Manual


94
EXERCISE PROGRAMS

1. Write a MATLAB program to find L.T of the causal signal x(t)=t^2


2. Write a MATLAB program to find L.T of the causal signal x(t)=t
3. Write a MATLAB program to find L.T of the causal signal x(t)=e^-at
4. Write a MATLAB program to find L.T of the causal signal x(t)=e^at
5. Write a MATLAB program to find L.T of the causal signal x(t)=te^at
6. Write a MATLAB program to find L.T of the causal signal x(t)=te^-at
7. Write a MATLAB program to find L.T of the causal signal x(t)=cost
8. Write a MATLAB program to find L.T of the causal signal x(t)=sint
9. Write a MATLAB program to find L.T of the causal signal x(t)=e^atcost
10. Write a MATLAB program to find L.T of the causal signalv x(t)=
e^atsint.11.Write a MATLAB program to find the cross correlation using
DFT.
12. Write a MATLAB program to find L.T of the causal signal x(t)=at
13. Write a MATLAB program to find L.T of the causal signal x(t)=10e^-at
14. Write a MATLAB program to find L.T of the signal x(t)=1
15. Write a MATLAB program to find L.T of the causal signal x(t)=impulse function
16. Write a MATLAB program to find L.T of the causal signal x(t)=Delta function
17. Write a MATLAB program to find L.T of the causal signal x(t)=cos(at)
18. Write a MATLAB program to find L.T of the causal signal x(t)=sin(at)
19. Write a MATLAB program to find L.T of the causal signal x(t)=e^atcos(at)
20. Write a MATLAB program to find L.T of the causal signal x(t)= e^atsin(at)
21. .Write a MATLAB program to find the auto correlation using L.T.
22. Write a MATLAB program to find L.T of the causal signal x(t)=5t
23. Write a MATLAB program to find L.T of the causal signal x(t)=5e^-at
24. Write a MATLAB program to find L.T of the causal signal x(t)=5e^at
25. Write a MATLAB program to find L.T of the causal signal
x(t)=5te^at26.Write a MATLAB program to find L.T of the causal
signal x(t)=e^4t
27. Write a MATLAB program to find L.T of the causal signal x(t)=te^5t
28. Write a MATLAB program to find L.T of the causal signal x(t)=te^-4t
29. Write a MATLAB program to find L.T of the causal signal x(t)=7cost
30. Write a MATLAB program to find L.T of the causal signal x(t)=5sint

Real Time Applications:


Laplace transforms having following
applicationsAnalysis of differential
equations
Laplace transform
spectroscopyQuantum
mechanics
Signal processing applications etc

Department of Electronics and Communication Engineering Page 94


BKM

Basic Simulation Lab Manual


95

EXPERMENT NO:12

GAUSSIAN NOISE

AIM: -

To Generate Gaussian Noise and to Compute its Mean, M.S. Values, Skew,
kurtosis,PS and PDF.

SOFTWARE REQURIED: -

1.MATLAB R2010a.
2.Windows XP SP2.

THEORY:-

Gaussian noise is statistical noise that has a probability density function


(abbreviated pdf) of the normal distribution (also known as Gaussian distribution). In other
words, the values tha the noise can take on are Gaussian-distributed. It is most commonly
used as additive white noise to yield additive white Gaussian noise (AWGN).Gaussian noise
is properly defined as the noise with a Gaussian amplitude distribution.says nothing of the
correlation of the noise in timeor of the spectral density of the noise.Labeling Gaussian noise
as 'white' describes the correlation of the noise. It is necessary to use the term "white
Gaussian noise" to be correct. Gaussian noise is sometimes misunderstood tobe white
Gaussian noise, but this is not the case.

PROCEDURE:-

 Open MATLAB
 Open new M-file
 Type the program
 Save in current directory
 Compile and Run the program
 For the output see command window\ Figure window

Department of Electronics and Communication Engineering Page 95


BKM

Basic Simulation Lab Manual


96
PROGRAM:-
%Gaussion noise%

clc; close all;


clear all;
N=input ('enter no of samples');
R1=rand(1,N);
M=mean(R1);
v=var(R1); x=psd(R1); subplot(2,2,1);plot(R1);
xlabel('sample numbers');ylabel('amplitude');
title('normal distributed random
signal');subplot(2,2,2);
hist(R1);
xlabel('sample numbers');ylabel('total');
title('histogram of a random signal');subplot(2,2,[3,4]);
plot(x);
xlabel('sample numbers');ylabel('amplitude');
title('psd of a normal random signal');

OUTPUT:-

Gaussion noise
enter no of samples50

Department of Electronics and Communication Engineering Page 96


BKM

Basic Simulation Lab Manual


97
normal distributed random signal histogram of a random signal
1 8

6
amplitude

total
0.5 4

0 0
0 20 40 60 0 0.5 1
sample numbers sample numbers
psd of a normal random signal
10

8
amplitude

0
0 5 10 15 20 25 30
sample numbers

RESULT: -
Additive White Gaussian noise was generated and its PSD and PDF were plotted and its
Mean, Standard Deviation, Kurtosis, Skew were Computed using MATLABfunctions.

VIVA QUESTIONS: -

1.What is a noise and how many types of noises are there?


2.What is gaussion noise?
3. What is Auto-correlation ?
4.State Parseval’s energy theorem for a periodic signal?
5.What is Signum function?
6. How many types of correlation are there?
7. State Parseval’s Power theorem for a periodic signal?
8. What is Cross-correlation ?
9.Define ESD? Explain the relation between ESD and Auto-correlation ?
10. Define PSD? Explain the relation between PSD and Auto-correlation ?

Department of Electronics and Communication Engineering Page 97


BKM

Basic Simulation Lab Manual


EXERCISE PROGRAMS 98

1. Write a MATLAB program to plot the co-sinusoidal signal.


2. Write a MATLAB program to subtract two sinusoidal signals.
3. Write a MATLAB program to subtract and multiply two sinusoidal signals.
4. Write a MATLAB program to right shift the signal to 5 times of the original signal.
5. Write a MATLAB program to left shift the signal to 8 times of the original signal.
6. Write a MATLAB program to add two different signals with 2 <t<5
7. Write a MATLAB program to shift a positive time line signal to negative timeline signal.
8. Write a MATLAB program to subtract co-sinusoidal signals.
9. Write a MATLAB program to subtract two sinusoidal signals
10. Write a MATLAB program to division and multiply two co-sinusoidal signals.
11. Write a MATLAB program to generate time scaling of a sequence.
12. Write a MATLAB program to generate time shifting of a sequence.
13. Write a MATLAB program to generate time folding of a sequence.
14. Write a MATLAB program to generate amplitude scaling of a sequence with amplitude 5.
15. Write a MATLAB program to generate time scaling of a sequence with time 2sec.
16. Write a MATLAB program to add two different signals with 4 <t<8
17. Write a MATLAB program to shift a negative time line signal to positive timeline signal.
18. Write a MATLAB program to subtract sinusoidal signals.
19. Write a MATLAB program to subtract and divide two sinusoidal signals
20. Write a MATLAB program to add and multiply two co-sinusoidal signals.
21. Write a MATLAB program to generate time scaling of a signal.
22. Write a MATLAB program to generate time shifting of a signal.
23. Write a MATLAB program to generate time folding of a signal.
24. Write a MATLAB program to generate amplitude scaling of a sequence with amplitude 10.
25. Write a MATLAB program to generate time scaling of a sequence with time 5sec.
26. Write a MATLAB program to compute auto correlation between
x =sin(4*pi*2*t), y =sin(4*pi*20*t). and see how matlab reacts to it.
27. Write a MATLAB program to compute cross correlation between x = sin(3*pi*2*t), y
=cos(5*pi*5*t). and see how matlab reacts to it.
28. Write a MATLAB program to compute auto correlation between two
signalsx=4*cos(2*pi*10*t), y=6*cos(6*pi*10*t).
29. Write a MATLAB program to compute cross correlation between two Sequences
[2 6 4 8 5]& [8 9 6 7 5].
30. Write a MATLAB program to compute auto correlation between two signals
x=5*cos(8*pi*10*t), y=6*cos(7*pi*10*t).

Department of Electronics and Communication Engineering Page 98


BKM

Basic Simulation Lab Manual


99

Real Time Applications:


• Stream processing
• Vector processing
• Digital processing applications

Department of Electronics and Communication Engineering Page 99


BKM

Basic Simulation Lab Manual


EXPERMENT NO:13 100

SAMPLING THEORM

AIM: -

To Demonstrate Sampling Theorem and aliasing effect using MATLAB.

SOFTWARE REQURIED: -

1.MATLAB R2010a.
2.Windows XP SP2.

THEORY: -

Sampling Theorem:
The theorem shows that a band limited analog signal that has been sampled can be perfectly
reconstructed from an infinite sequence of samples if the sampling rate exceeds 2B samples
per second, where B is the highest frequency in the original signal.
If a signal contains a component at exactly B hertz, then samples spaced at exactly 1/(2B)
seconds do not completely determine the signal, Shannon's statement notwithstanding.

Proof: Let g(t) be a bandlimited signal whose bandwidth is fm(wm = 2πfm).

Figure 2: (a) Original signal g(t) (b) Spectrum G(w)


δ(t) is the sampling signal with fs = 1/T > 2fm.

Department of Electronics and Communication Engineering Page 100


BKM

Basic Simulation Lab Manual


101

Figure 3: (a) sampling signal δ(t) ) (b) Spectrum δ(w)

Let gs(t) be the sampled signal. Its Fourier Transform Gs(w) isgiven by

Department of Electronics and Communication Engineering Page 101


BKM

Basic Simulation Lab Manual


102

Figure 4: (a) sampled signal gs(t) (b) Spectrum Gs(w)

To recover the original signal G(w):


1. Filter with a Gate function, H2wm(w) of width
2wmScale it by T.

Figure 5: Recovery of signal by filtering with a filter of width 2wm

Department of Electronics and Communication Engineering Page 102


BKM

Basic Simulation Lab Manual


103
Aliasing

{ Aliasing is a phenomenon where the high frequency components of the sampled


signalinterfere with each other because of inadequate sampling ws < 2wm.

Figure 6: Aliasing due to inadequate sampling

Aliasing leads to distortion in recovered signal. This is the


reason why sampling frequency should be atleast twice thebandwidth of the signal.

PROCEDURE:-
 Open MATLAB
 Open new M-file
 Type the program
 Save in current directory
 Compile and Run the program
 For the output see command window\ Figure window

Department of Electronics and Communication Engineering Page 103


BKM

Basic Simulation Lab Manual


PROGRAM:- 104

%sampling
theorem%
clc;
clear all; close all;
t=0:0.001:1;f=5;
x=cos(2*pi*f*t);
plot(t,x);

%when fs>2fm%

fs1=3*f; ts1=1/fs1;
n1=0:ts1:1;
xs1=cos(2*pi*f*n1);
figure;
plot(n1,xs1,'r');
hold on;
plot(t,x);
hold off;

%when fs=2fm%

fs2=2*f;
ts2=1/fs2;
n2=0:ts2:1;
xs2=cos(2*pi*f*n2);
figure; plot(n2,xs2,'r');
hold on;
plot(t,x);
hold off;

%when fs<2fm%

fs3=1.5*f;
ts3=1/fs3;
n3=0:ts3:1;
xs3=cos(2*pi*f*n3);
figure;
plot(n3,xs3,'r');
hold on;
plot(t,x);
hold off;

Department of Electronics and Communication Engineering Page 104


BKM

Basic Simulation Lab Manual


OUTPUT:- 105

sampling theorem

0.8

0.6

0.4

0.2

-0.2

-0.4

-0.6

-0.8

-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

when fs>2fm

0.8

0.6

0.4

0.2

-0.2

-0.4

-0.6

-0.8

-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

Department of Electronics and Communication Engineering Page 105


BKM

Basic Simulation Lab Manual


when fs=2fm 106

0.8

0.6

0.4

0.2

-0.2

-0.4

-0.6

-0.8

-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

when fs<2fm

0.8

0.6

0.4

0.2

-0.2

-0.4

-0.6

-0.8

-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

Department of Electronics and Communication Engineering Page 106


BKM

Basic Simulation Lab Manual


107
RESULT: -

In this experiment the sampling theorem have been verifiedusing MATLAB.

VIVA QUESTIONS: -

1. State Paeseval’s energy theorem for a periodic signal?


2. Define sampling Theorem?
3. What is Aliasing Effect?
4. what is Under sampling?
5. What is Over sampling?
6. Give the importance of Natural Sampling? 7.Give the importance of Flat-top Sampling? 8.Give the
importance of ideal Sampling?
9. What is Anti-Aliasing Effect? 10.Define Stability of LTI system?

EXERCISE PROGRAM: -

1. Write a MATLAB program to find the effect of up sampling in frequency domain.


2. Write a matlab program to get the above output where t0 = 2
3. Write a MATLAB program to find the effect of up sampling in frequency domain for 20khz.
4. Write a program to get the following output t = -
1: -5 5.Write mat lab program to get the above
output
X(t) = 1; (0<t<2)
= 10;(2<t<15) Note: Add ramp and unit
6.Write a matlab program to generate a sine wave with amplitude = 3, frequency 20Hz. 7.Write a
matlab program to generate a cos wave with amplitude = 3, frequency 20Hz. 8.Write a matlab
program to generate a triangular wave with amplitude = 8, frequency 10Hz.
9.Write a matlab program to generate a square wave with amplitude = 2, frequency 10kHz.
10.Write a matlab program to generate the signum function.
11.Write a matlab program to generate exponential growing signal.
12.Write a matlab program to generate exponential decaying signal.
13.Write a matlab program to generate a triangular wave with amplitude = 6,frequency 1Hz.
14.Write a matlab program to generate a square wave with amplitude = 5, frequency 5kHz.
15.Write a matlab program to generate a sawtooth wave with amplitude = 8,
frequency5Khz.
16.Write a matlab program to generate a sine wave with amplitude = 5, frequency 5Hz.
17.Write a matlab program to generate a cos wave with amplitude = 4, frequency 10Hz.
18.Write a matlab program to generate a triangular wave with amplitude = 5,
frequency 4Hz.

Department of Electronics and Communication Engineering Page 107


BKM

Basic Simulation Lab Manual


19.Write a matlab program to generate a square wave with amplitude = 1, frequency 108
20kHz.20.Write a matlab program to generate the signum function.
21.Write a matlab program to generate a square wave with amplitude = 4, frequency 5kHz.
22.Write a matlab program to generate a triangular wave with amplitude = 6, frequency 6Hz.
23.Write a matlab program to generate a triangular wave with amplitude = 8,frequency
2Hz.
24.Write a matlab program to generate a square wave with amplitude = 7, frequency 5kHz.
25.Write a matlab program to generate a sawtooth wave with amplitude =10, frequency 10Khz.
26.Write a matlab program to generate the step function.
27. Write a matlab program to generate exponential growing signal of amplitude =5.
28.Write a matlab program to generate exponential decaying signal of amplitude =7..
29.Write a matlab program to generate a triangular wave with amplitude = 7,frequency
1Hz.
30.Write a matlab program to generate a square wave with amplitude = 7, frequency
10kHz.

Real Time Applications:


 Industrial control and automation (Control the velocity or position of an object)
 Examples: Controlling the position of a valve or shaft of a motor
 Examples: Digital processing applications
 TV reception
 RADAR
 SONAR

Department of Electronics and Communication Engineering Page 108


BKM

Basic Simulation Lab Manual


EXPERMENT NO:14 109

REMOVAL OF NOISE BY AUTO CORRELATION/CROSSCORRELATION

AIM: -

removal of noise by auto correlation/cross correlation.

SOFTWARE REQURIED: -

1.MATLAB R2010a.
2.Windows XP SP2.

THEORY: -

Detection of a periodic signal masked by random noise is of greate importance The noise signal
encountered in practice is a signal with random amplitude variations. A signal is uncorrelated with
any periodic signal. If s(t) is a periodic signal and n(t) is anoise signal then

T/2 1/T
Lim ∫S(t)n(t-T) dt=0 for all T
-T/2

Qsn(T)= cross correlation function of s(t) and n(t) Then


Qsn(T)=0Detection by Auto-Correlation:
S(t)=Periodic Signal mixed with a noise signal n(t).Then f(t) is [s(t ) +
n(t) ]Let Qff(T) =Auto Correlation Function of f(t)
Qss(t) = Auto Correlation Function of
S(t) Qnn(T) = Auto Correlation Function
of n(t)

T/2
Qff(T)= Lim 1/T ∫f(t)f(t-T) dt
T->∞ -T/2

T/2
= Lim 1/T ∫[s(t)+n(t)][s(t-T)+n(t-T)]
dtT--∞ -T/2

=Qss(T)+Qnn(T)+Qsn(T)+Qns(T)

Department of Electronics and Communication Engineering Page 109


BKM

Basic Simulation Lab Manual


The periodic signal s(t) and noise signal n(t) are 110

uncorrelatedQsn(t)=Qns(t)=0 ;Then

Qff(t)=Qss(t)+Qnn(t)

The Auto correlation function of a periodic signal is periodic of the same frequency and the Auto
correlation function of a non periodic signal is tends to zero for large value of T since s(t) is a
periodic signal and n(t) is non periodic signal so Qss(T) is a periodic where

as aQnn(T) becomes small for large values of T Therefore for sufficiently large
values ofT Qff(T) is equal to Qss(T).

Detection by Cross Correlation:

f(t)=s(t)+n(t)

c(t)=Locally generated signal with same frequencyas that of

S(t)T/2
Qfc (t) = Lim 1/T ∫[s(t)+n(t)] [ c(t-T)] dt
T--∞-T/2
= Qsc(T)+Qnc(T)

C(t) is periodic function and uncorrelated with the random noise signal n(t).
HenceQnc(T0=0) Therefore Qfc(T)=Qsc(T)

PROCEDURE:-
 Open MATLAB
 Open new M-file
 Type the program
 Save in current directory
 Compile and Run the program
 For the output see command window\ Figure window

Department of Electronics and Communication Engineering Page 110


BKM

Basic Simulation Lab Manual


PROGRAM:- 111

%auto
correlation%clc;
clear all; close all; t=0:0.1:pi*4;
s=sin(t); k=2;
subplot(6,1,1) plot(s);
title('signal s');xlabel('t');
ylabel('amplitude');n = randn([1 126]);
f=s+n; subplot(6,1,2) plot(f);
title('signal f=s+n');
xlabel('t');
ylabel('amplitude');
as=xcorr(s,s);
subplot(6,1,3);
plot(as);
title('auto correlation of s');
xlabel('t');
ylabel('amplitude'); an=xcorr(n,n);
subplot(6,1,4)
plot(an);
title('auto correlation of n');xlabel('t');
ylabel('amplitude');
cff=xcorr(f,f);
subplot(6,1,5);
plot(cff);
title('auto correlation of f');
xlabel('t');
ylabel('amplitude');
hh=as+an;
subplot(6,1,6);
;plot(hh);
title('addition of as+an');
xlabel('t');
ylabel('amplitude');

Department of Electronics and Communication Engineering Page 111


BKM

Basic Simulation Lab Manual


%CROSS CORRELATION %
112
clc; clear all;close all;
t=0:0.1:pi*4;
s=sin(t); k=2;
%sk=sin(t+k);subplot(7,1,1) ;
plot(s); title('signal s');
xlabel('t');ylabel('amplitude');c=cos(t);
subplot(7,1,2) plot(c); title('signal c');xlabel('t');
ylabel('amplitude');n = randn([1 126]);
f=s+n; subplot(7,1,3) plot(f);
title('signal f=s+n');xlabel('t');
ylabel('amplitude');
asc=xcorr(s,c);
subplot(7,1,4);
plot(asc);
title('auto correlation of s and c');
xlabel('t');ylabel('amplitude'); anc=xcorr(n,c);
subplot(7,1,5)plot(anc);
title('auto correlation of n and c');xlabel('t');
ylabel('amplitude'); cfc=xcorr(f,c);
subplot(7,1,6);
plot(cfc);
title('auto correlation of f and c');
xlabel('t');ylabel('amplitude');
hh=asc+anc;
subplot(7,1,7);
plot(hh);
title('addition of asc+anc'); xlabel('t');
ylabel('amplitude');

Department of Electronics and Communication Engineering Page 112


BKM

Basic Simulation Lab Manual


113

OUTPUT: -

auto correlation

CROSS CORRELATION

Department of Electronics and Communication Engineering Page 113


BKM

Basic Simulation Lab Manual


114

Department of Electronics and Communication Engineering Page 114


BKM

Basic Simulation Lab Manual


115

RESULT:-

In this experiment the removal of noise by autocorrelation/cross correlation have been


verified using MATLAB.

VIVA QUESTIONS:-

1. What is Causal Signal?


2. What are the Different types of Systems?
3. What is Linear System?
4. What is Signum function?
5. What is Static and Dynamic System?
6. Define Linear Convolution?
7. Define Properties of Convolution in time domain?
8. What is the Difference Between Linear Convolution& Circular Correlation?
9. What are Dirchlet Conditions for Fourier Transform?
10. What is Full Wave Symmetry?

EXERCISE PROGRAMS

1. Write a MATLAB program to find the cross correlation using FFT.


2. Write a mat lab program to perform the cross correlation between sinusoidal and
rampfunction and see how mat lab reacts to it.
3. Write a MATLAB program to perform cross correlation between square and step
signal andsee how mat lab reacts to it.
4. Write a MATLAB program to perform cross correlation between sinusoidal and ramp
signaland see how mat lab reacts to it.
5. Write a MATLAB program to perform the cross correlation between X (n) = [1 2 3 5] and y
(n) = [- 1 – 2] and see how matlab reacts to it.
6. Write a MATLAB program to perform the cross correlation between X (n) = [1 -3 5] and y
(n) = [1 2 3 4] and see how matlab reacts to it.
7. Write a MATLAB program to perform the cross correlation between X (n) = [1 0 1 1] and y
(n) = [1 0 0 0 0] and see how matlab reacts to it.
8. Write a MATLAB program to perform the cross correlation between X (n) = [1 1 1 1 0 0 0 0]
and y (n) = [1 0 1 0 1 0 1 0] and see how matlab reacts to it.
9. Write a MATLAB program to perform the cross correlation between X (n) = [1 1 0 0] and y (n)
= [1 1 1 1] and see how matlab reacts to it.
10. Write a MATLAB program to perform the cross correlation between X (n) = [6 7 8 9 10]
andy (n) = [5 4 3 2 1] and see how matlab reacts to it.
11. Write the MATLAB program to perform cross correlation between the following
sequencesX(n)=[2 -2 3 2, h(n) = [-2 4 -5 2].

Department of Electronics and Communication Engineering Page 115


BKM

Basic Simulation Lab Manual


12. Write a mat lab program to perform the convolution between step and ramp function 116
and seehow mat lab reacts to it.
13. Write a MATLAB program to perform convolution between square and step signal
and seehow mat lab reacts to it.
14. Write a MATLAB program to perform convolution between sinusoidal and square
signal andsee how mat lab reacts to it.
15. Write a MATLAB program to perform the convolution between X (n) = [2 3 4 5] and y
(n) =[-2 –4] and see how matlab reacts to it.
16. Write a MATLAB program to perform the convolution between X (n) = [3 -4 6] and y
(n) =[2 6 8 6] and see how matlab reacts to it.
17. Write a MATLAB program to perform the convolution between X (n) = [3 1 2 0] and y
(n) =[2 4 3 4 5] and see how matlab reacts to it.
18. Write a MATLAB program to perform the convolution between X (n) = [2 2 1 0 2 1 1 0] and
y (n) = [1 1 1 2 1 0 1 0] and see how matlab reacts to it.
19. Write a MATLAB program to perform the convolution between X (n) = [2 1 2 1] and y
(n) =[1 2 1 2] and see how matlab reacts to it.
20. Write a MATLAB program to perform the convolution between X (n) = [5 6 9 8 7] and y (n)
= [1 2 3 2 1] and see how matlab reacts to it.
21. Write the MATLAB program to perform cross correlation between the following sequences
X(n)=[4 -6 5 1], h(n) = [-1 3 -4 3].
22. Write a mat lab program to perform the cross correlation between ramp and step function
andsee how mat lab reacts to it.
23. Write a MATLAB program to perform cross correlation between square and step
signal andsee how mat lab reacts to it.
24. Write a MATLAB program to perform cross correlation between sinusoidal and step
signaland see how mat lab reacts to it.
25. Write a MATLAB program to perform the convolution between X (n) = [1 5 6 5] and y
(n) =[-3 –6] and see how matlab reacts to it.
26. Write a MATLAB program to plot the co-sinusoidal signal.
27. Write a MATLAB program to subtract two sinusoidal signals.
28. Write a MATLAB program to subtract and multiply two sinusoidal signals.
29. Write a MATLAB program to right shift the signal to 5 times of the original signal.
30. Write a MATLAB program to left shift the signal to 8 times of the original signal.

Real Time Applications:

• The cross correlation is to determine the response y[n] of a system of a known


impulseresponse h[n] for a given input signal x[n] to obtain y[n]. Digital signal processing
applications etc…

Department of Electronics and Communication Engineering Page 116


BKM

Basic Simulation Lab Manual


117
EXPERMENT NO:15

EXTRACTION OF PERIODIC SIGNAL MASKED BY NOISE USING CORRELATION

AIM: -
To generate a periodic sequence, corrupt it with zero mean White noise and extract the
sequence using periodic circular cross correlation.

SOFTWARE REQURIED:-

1.MATLAB R2010a.
2.Windows XP SP2.

THEORY: -

Removal of noise by Filtering is not the solution because noise contains power
at allfrequencies. Hence we use correlation techniques.

The theorem is useful for analyzing linear time-invariant systems, LTI systems, when the
inputs and outputs are not square integrable, so their Fourier transforms do not exist. A
corollary is that the Fourier transform of the autocorrelation function of the output of an LTI
system is equal to the product of the Fourier transform of the autocorrelation function of the
input of the system times the squared magnitude of the Fourier transform of the system
impulse response. This works even when the Fourier transforms of the input and output
signals do not exist because these signals are not square integrable, so the system inputs and
outputs cannot be directly related by the Fourier transform of the impulse response. Since the
Fourier transform of the autocorrelation function of a signal is the power spectrum of the
signal, this corollary is equivalent to saying that the power spectrum of the output is equal to
the power spectrum of the input times the power transfer function. This corollary is used in
the parametric method for power spectrum estimation.

Department of Electronics and Communication Engineering Page 117


BKM

Basic Simulation Lab Manual


PROCEDURE:-
118
 Open MATLAB
 Open new M-file
 Type the program
 Save in current directory
 Compile and Run the program
 For the output see command window\ Figure window

PROGRAM:-

clc;
clear
all;close
all;
n=256;
k1=0:n-1;
x=cos(32*pi*k1/n)+sin(48*pi*k1/n);
plot(k1,x);
%Module to find period of input
signalk=2;
xm=zeros(k,1);ym=zeros(k,1);hold on;
for i=1:k
[xm(i) ym(i)]=ginput(1);
plot(xm(i),
ym(i),'r*');end;
period=abs(xm(2)-xm(1));
rounded_p=round(period); m=rounded p;
% Adding noise and plotting noisy
signaly=x+randn(1,n);
figure; plot(k1,y);
% To generate impulse train with the period as that of input
signal%d=zeros(1,n);
for i=1:n
if (rem(i-1,m)==0)d(i)=1;
end; end;
% correlating noisy signal and impulse
traincir=cxcorr1(y,d);
%plotting the original and reconstructed
signalm1=0:n/4;
figure
plot(m1,x(m1+1),'r',m1,m*cir(m1+1));

Department of Electronics and Communication Engineering Page 118


BKM

Basic Simulation Lab Manual


119
OUTPUT:-

Department of Electronics and Communication Engineering Page 119


BKM

Basic Simulation Lab Manual


120

RESULT:-

Using Cross- correlation the periodic signal from noise was estimated
usingMATLAB.

Department of Electronics and Communication Engineering Page 120


BKM

Basic Simulation Lab Manual


VIVA QUESTIONS: - 121

1. State the relationship between PSD and ACF?


2. What is the integration of ramp signal?
3. Difference between vectors and signals?
4. What is the important of dot product over cross product in signals?
5. Define Hilbert transforms?
6. What is Hilbert transform of Sin(t)?
7. What is Hilbert transform of Cos(t)?
8.What is difference between Hilbert transforms and Fourier Transforms? 9.What is difference
between Hilbert transforms and Laplace Transforms?10.Explain LTI and LTV systems?

EXERCISE PROGRAM:-

1. Simulate a matlab program on autocorrelation and PSD if x = [1 2 3 4 5 ].


2. Write a mat lab program to perform the cross correlation between sinusoidal and
rampfunction and see how mat lab reacts to it.
3. Write a MATLAB program to perform cross correlation between square and step
signal andsee how mat lab reacts to it.
4. Write a MATLAB program to perform cross correlation between sinusoidal and ramp
signaland see how mat lab reacts to it.
5. Write a MATLAB program to perform the cross correlation between X (n) = [1 2 3 5] and y
(n) = [- 1 – 2] and see how matlab reacts to it.
6. Write a MATLAB program to perform the cross correlation between X (n) = [1 -3 5] and y
(n) = [1 2 3 4] and see how matlab reacts to it.
7. Write a MATLAB program to perform the cross correlation between X (n) = [1 0 1 1] and y
(n) = [1 0 0 0 0] and see how matlab reacts to it.
8. Write a MATLAB program to perform the cross correlation between X (n) = [1 1 1 1 0 0 0 0]
and y (n) = [1 0 1 0 1 0 1 0] and see how matlab reacts to it.
9. Write a MATLAB program to perform the cross correlation between X (n) = [1 1 0 0] and y (n)
= [1 1 1 1] and see how matlab reacts to it.
10. Write a MATLAB program to perform the cross correlation between X (n) = [6 7 8 9 10]
andy (n) = [5 4 3 2 1] and see how matlab reacts to it.
11. Write the MATLAB program to perform cross correlation between the following
sequencesX(n)=[2 -2 3 2, h(n) = [-2 4 -5 2].
12. Write a mat lab program to perform the convolution between step and ramp function
and seehow mat lab reacts to it.
13. Write a MATLAB program to perform convolution between square and step signal
and seehow mat lab reacts to it.
14. Write a MATLAB program to perform convolution between sinusoidal and square
signal andsee how mat lab reacts to it.
15. Write a MATLAB program to perform the convolution between X (n) = [2 3 4 5] and y
(n) =[-2 –4] and see how matlab reacts to it.
16. Write a MATLAB program to perform the convolution between X (n) = [3 -4 6] and y
(n) =[2 6 8 6] and see how matlab reacts to it.

Department of Electronics and Communication Engineering Page 121


BKM

Basic Simulation Lab Manual


17. Write a MATLAB program to perform the convolution between X (n) = [3 1 2 0] and y 122
(n) =[2 4 3 4 5] and see how matlab reacts to it.
18. Write a MATLAB program to perform the convolution between X (n) = [2 2 1 0 2 1 1 0] and
y (n) = [1 1 1 2 1 0 1 0] and see how matlab reacts to it.
19. Write a MATLAB program to perform the convolution between X (n) = [2 1 2 1] and y
(n) =[1 2 1 2] and see how matlab reacts to it.
20. Write a MATLAB program to perform the convolution between X (n) = [5 6 9 8 7] and y (n)
= [1 2 3 2 1] and see how matlab reacts to it.
21. Write the MATLAB program to perform cross correlation between the following
sequencesX(n)=[4 -6 5 1], h(n) = [-1 3 -4 3].
22. Write a mat lab program to perform the cross correlation between ramp and step
function andsee how mat lab reacts to it.
23. Write a MATLAB program to perform cross correlation between square and step
signal andsee how mat lab reacts to it.
24. Write a MATLAB program to perform cross correlation between sinusoidal and step
signaland see how mat lab reacts to it.
25. Write a MATLAB program to perform the convolution between X (n) = [1 5 6 5] and y
(n) =[-3 –6] and see how matlab reacts to it.
26. Write a MATLAB program to find Hilbert transforms of the causal signal x(t)=t^2
27. Write a MATLAB program to find Hilbert transforms of the causal signal x(t)=t
28. Write a MATLAB program to find Hilbert transforms of the causal signal x(t)=e^-at
29. Write a MATLAB program to find Hilbert transforms of the causal signal x(t)=e^at
30. Write a MATLAB program to find Hilbert transforms of the causal signal x(t)=te^at

Real Time Applications:

• The cross correlation is to determine the response y[n] of a system of a known


impulseresponse h[n] for a given input signal x[n] to obtain y[n].
• Digital signal processing applications etc…
• TV reception.

Department of Electronics and Communication Engineering Page 122


BKM

Basic Simulation Lab Manual


EXPERMENT NO:16 123

VERIFICATION OF WIENER–KHINCHIN RELATION

AIM: -
Verification of wiener–khinchine relation.

SOFTWARE REQURIED: -

1.MATLAB R2010a.
2.Windows XP SP2.

THEORY:-

The Wiener–Khinchin theorem (also known as the Wiener–Khintchine theorem and sometimes
as the Wiener–Khinchin–Einstein theorem or the Khinchin–Kolmogorov theorem) states that the
power spectral density of a wide-sense-stationary random process is the Fourier transform of
the corresponding autocorrelation function.
Continuous case:

Where

is the autocorrelation function defined in terms of statistical expectation, and where


is thepower spectral density of the function . Note that the autocorrelation function
is defined in terms of the expected value of a product, and that the Fourier
transform of does not exist in general, because stationary random functions are not
square integrable.
The asterisk denotes complex conjugate, and can be omitted if the random process is real valued.

Discrete case:

Department of Electronics and Communication Engineering Page 123


BKM

Basic Simulation Lab Manual


where 124

and where is the power spectral density of the function with discrete values. Being a sampled and
discrete-time sequence, the spectral density is periodic in the frequencydomain.

PROCEDURE:-
 Open MATLAB
 Open new M-file
 Type the program
 Save in current directory
 Compile and Run the program
 For the output see command window\ Figure window

PROGRAM:-

% wiener–khinchine relation%
clc;
clear all; t=0:0.1:2*pi; x=sin(2*t); subplot(3,2,1);
plot(x); au=xcorr(x,x);
subplot(3,2,2);
plot(au);
v=fft(au); subplot(3,2,3);
plot(abs(v)); fw=fft(x);
subplot(3,2,4); plot(fw);
fw2=(abs(fw)).^2;
subplot(3,2,5);
plot(fw2);

Department of Electronics and Communication Engineering Page 124


BKM

Basic Simulation Lab Manual


125

OUTPUT:-

wiener–khinchine relation

Department of Electronics and Communication Engineering Page 125


BKM

Basic Simulation Lab Manual


126

RESULT:-

Calculation of Auto-correlation function using Weiner-Khinchin theorm was


verifiedusing MATLAB.

VIVA QUESTIONS: -
1. What is mean wiener–khinchine relation?
2. Define fourier transform and its inverse?
3. What is the difference b/w convolution and correlation?
4. What is the importance of power spectrum?
5. What is the importance of correlation?
6. Write the relation between Step and Impulse signals?
7. Write the relation between Ramp and impulse signals?
8. Write the relation between Ramp and Step signals?
9. Define Standerd signals?
10. Give examples of Standerd signals?

EXERCISE PROGRAMS

1. Write a MATLAB program to illustrate the effect of anti-aliasing filter.


2. Write a MATLAB program to subtract two sinusoidal signals.
3. Write a MATLAB program to subtract and multiply two sinusoidal signals.
4. Write a MATLAB program to right shift the signal to 5 times of the original signal.
5. Write a MATLAB program to left shift the signal to 8 times of the original signal.
6. Write a MATLAB program to add two different signals with 2 <t<5
7. Write a MATLAB program to shift a positive time line signal to negative timeline
signal
. 8. Write a MATLAB program to subtract co-sinusoidal signals.
9. Write a MATLAB program to subtract two sinusoidal signals
10. Write a MATLAB program to division and multiply two co-sinusoidal signals.
11. Write a MATLAB program to generate time scaling of a sequence.
12. Write a MATLAB program to generate time shifting of a sequence.
13. Write a MATLAB program to generate time folding of a sequence.
14. Write a MATLAB program to generate amplitude scaling of a sequence with
amplitude 5.
15. Write a MATLAB program to generate time scaling of a sequence with time 2sec.
16. Write a MATLAB program to add two different signals with 4 <t<8
17. Write a MATLAB program to shift a negative time line signal to positive timeline
signal.
18. Write a MATLAB program to subtract sinusoidal signals.

Department of Electronics and Communication Engineering Page 126


BKM

Basic Simulation Lab Manual


19. Write a MATLAB program to subtract and divide two sinusoidal signals 127
20. Write a MATLAB program to add and multiply two co-sinusoidal signals.
21. Write a MATLAB program to generate time scaling of a signal.
22. Write a MATLAB program to generate time shifting of a signal.
23. Write a MATLAB program to generate time folding of a signal.
24. Write a MATLAB program to generate amplitude scaling of a sequence with
amplitude 10.
25. Write a MATLAB program to generate time scaling of a sequence with time 5sec.
26. Find the addition of null matrix and unity matrix of order 4x4.
27. Write a MATLAB program to find rank of the
matrixA= [6 4 9 3 5; 6 2 4 8 5; 6 3 1 7 9].
28. Write a MATLAB program to find Eigen of the
matrixA= [2 5 0 3 4; 5 4 3 7 8; 9 1 6 5 4].
29. Write a MATLAB program to find inverse of the
matrixA= [1 5 9 8 5;4 3 5 8 4; 5 6 3 5 0]
30. Write a MATLAB program to find determinant of the
matrixA= [1 6 9 8 5; 9 3 5 6 4; 1 6 3 5 6].

Real Time Applications:

• Stream processing applications


• Block processing applications
• Vector processing applications
• Signal processing applications

Department of Electronics and Communication Engineering Page 127


BKM

Basic Simulation Lab Manual


128
EXPERMENT NO:17

CHECKING A RANDOM PROCESS FOR STATIONARITY IN WIDE SENSE.

AIM: - Checking a random process for stationarity in wide sense.

SOFTWARE REQURIED:-

1.MATLAB R2010a.
2.Windows XP SP2.

THEORY:-

A stationary process (or strict(ly) stationary process or strong(ly) stationary process) is a


stochastic process whose joint probability distribution does not change when shifted in time
or space. As a result, parameters such as the mean and variance, if they exist, also do not
change over time or position. Weak or wide-sense stationary A weaker form of stationary
commonly employed in signal processing is known as weak-sense stationary, wide-sense
stationarity (WSS)or covariance stationarity. WSS random processes only require that 1st and
2nd moments do notvary with respect to time.

and autocorrelation function

The first property implies that the mean function m x(t) must be constant. The second
property implies that the correlation function depends only on the difference between t1 and
t2 and only needs to be indexed by one variable rather than two variables. Thus, instead of
writing,
Rx(t1-t2,0)we usually abbreviate the notation and write

This also implies that the auto covariance depends only on _ = t1 − t2, since

Stationary and Non Stationary Random Process:

A random X(t) is stationary if its statistical properties are unchanged by a time shift in the time
Department of Electronics and Communication Engineering Page 128
BKM

Basic Simulation Lab Manual


origin. When the auto-Correlation function Rx(t, t+T ) of the random X(t) varies with
129
time difference T and the mean value of the random variable X(t1) is independent of the
choicet1,then X(t) is said to be stationary in the wide sense or wide-sense stationary . So a
continuous- Time random process X(t) which is WSS has the following properties

1) E[X(t)]=μX(t)= μX(t+T)

2) The Autocorrelation function is written as a function of T


that isRX(t, t+T)=Rx(T)

If the statistical properties like mean value or moments depends on time then the random
processis said to be non-stationary.

When dealing with two random process X(t) and Y(t), we say that they are jointly wide-
sensestationary if each process is stationary in the wide-sense.

Rxy(t,t+T)=E[X(t)Y(t+T)]=Rxy(T).

PROCEDURE:-
 Open MATLAB
 Open new M-file
 Type the program
 Save in current directory
 Compile and Run the program
 For the output see command window\ Figure window

PROGRAM:-
Clc; Close all;
clear all
y = randn([1 40]) my=round(mean(y));
z=randn([1 40]) mz=round(mean(z));
vy=round(var(y));
vz=round(var(z));
t = sym('t','real');h0=3;
x=y.*sin(h0*t)+z.*cos(h0*t);
mx=round(mean(x));
k=2;
xk=y.*sin(h0*(t+k))+z.*cos(h0*(t+k));x1=sin(h0*t)*sin(h0*(t+k)); x2=cos(h0*t)*cos(h0*(t+k));
c=vy*x1+vz*x1;

Department of Electronics and Communication Engineering Page 129


BKM

Basic Simulation Lab Manual


OUTPUT: 130

%if we solve "c=2*sin(3*t)*sin(3*t+6)" we get c=2cos(6)


%which is a costant does not depent on variable 't'
% so it is wide sence stationary.

RESULT:-

Checking a random process for stationarity in wide sense by using MATLAB .

VIVA QUESTIONS:-

1. what is the condition for WSS random


process?2.Define random variable with
examples?
3. Define random process with examples?
4. Difference between ACF and CCF?
5. what are the different noises?
6. Explain two Properties of Auto-Correlation?
7. Explain two Properties of Cross-Correlation?
8. What is the difference b/w Auto-correlation and Cross-
Correlation?9.Define ESD?
10.Define PSD?

EXERCISE PROGRAMS

1. Write a program to simulate parseval’s relation


2. Write a mat lab program to perform the cross correlation between sinusoidal and
rampfunction and see how mat lab reacts to it.
3. Write a MATLAB program to perform cross correlation between square and step
signal andsee how mat lab reacts to it.
4. Write a MATLAB program to perform cross correlation between sinusoidal and ramp
signaland see how mat lab reacts to it.
5. Write a MATLAB program to perform the cross correlation between X (n) = [1 2 3 5] and y
(n) = [- 1 – 2] and see how matlab reacts to it.
6. Write a MATLAB program to perform the cross correlation between X (n) = [1 -3 5] and y
(n) = [1 2 3 4] and see how matlab reacts to it.
7. Write a MATLAB program to perform the cross correlation between X (n) = [1 0 1 1] and y
(n) = [1 0 0 0 0] and see how matlab reacts to it.
8. Write a MATLAB program to perform the cross correlation between X (n) = [1 1 1 1 0 0 0 0]
and y (n) = [1 0 1 0 1 0 1 0] and see how matlab reacts to it.
9. Write a MATLAB program to perform the cross correlation between X (n) = [1 1 0 0] and y (n)
= [1 1 1 1] and see how matlab reacts to it.
10. Write a MATLAB program to perform the cross correlation between X (n) = [6 7 8 9 10]
Department of Electronics and Communication Engineering Page 130
BKM

Basic Simulation Lab Manual


andy (n) = [5 4 3 2 1] and see how matlab reacts to it.
131
11. Write the MATLAB program to perform cross correlation between the following
sequencesX(n)=[2 -2 3 2, h(n) = [-2 4 -5 2].
12. Write a mat lab program to perform the convolution between step and ramp function
and seehow mat lab reacts to it.
13. Write a MATLAB program to perform convolution between square and step signal
and seehow mat lab reacts to it.
14. Write a MATLAB program to perform convolution between sinusoidal and square
signal andsee how mat lab reacts to it.
15. Write a MATLAB program to perform the convolution between X (n) = [2 3 4 5] and y
(n) =[-2 –4] and see how matlab reacts to it.
16. Write a MATLAB program to perform the convolution between X (n) = [3 -4 6] and y
(n) =[2 6 8 6] and see how matlab reacts to it.
17. Write a MATLAB program to perform the convolution between X (n) = [3 1 2 0] and y
(n) =[2 4 3 4 5] and see how matlab reacts to it.
18. Write a MATLAB program to perform the convolution between X (n) = [2 2 1 0 2 1 1 0] and
y (n) = [1 1 1 2 1 0 1 0] and see how matlab reacts to it.
19. Write a MATLAB program to perform the convolution between X (n) = [2 1 2 1] and y
(n) =[1 2 1 2] and see how matlab reacts to it.
20. Write a MATLAB program to perform the convolution between X (n) = [5 6 9 8 7] and y (n)
= [1 2 3 2 1] and see how matlab reacts to it.
21. Write the MATLAB program to perform cross correlation between the following
sequencesX(n)=[4 -6 5 1], h(n) = [-1 3 -4 3].
22. Write a mat lab program to perform the cross correlation between ramp and step
function andsee how mat lab reacts to it.
23. Write a MATLAB program to perform cross correlation between square and step
signal andsee how mat lab reacts to it.
24. Write a MATLAB program to perform cross correlation between sinusoidal and step
signaland see how mat lab reacts to it.
25. Write a MATLAB program to perform the convolution between X (n) = [1 5 6 5] and y
(n) =[-3 –6] and see how matlab reacts to it.
26. Write a MATLAB program to illustrate the effect of anti-aliasing filter.
27. Write a MATLAB program to subtract two sinusoidal signals.
28. Write a MATLAB program to subtract and multiply two sinusoidal signals.
29. Write a MATLAB program to right shift the signal to 2 times of the original signal.
30. Write a MATLAB program to left shift the signal to 5 times of the original signal.

Real Time Applications:

• Parseval’s theorem for energy signals


• Parseval’s theorem for power signals
• Digital signal processing applications etc…

Department of Electronics and Communication Engineering Page 131


BKM

Basic Simulation Lab Manual


EXPERMENT NO:18 (Beyond Syllabus)
132
LOCATING THE ZEROS AND POLES AND PLOTTING THE POLE
ZERO MAPS IN S-PLANE AND Z-PLANE FOR THE GIVENTRANSFER
FUNCTION.

AIM: -
To locating the zeros and poles and plotting the pole zero maps in s-plane and z-plane
for the given transfer function.

SOFTWARE REQURIED: -

1.MATLAB R2010a.
2.Windows XP SP2.

THEORY:-

A Transfer Function is the ratio of the output of a system to the input of a system,in the
Laplace domain considering its initial conditions to be zero. If we have an input function of
X(s), and an output function Y(s), we define the transfer function H(s) to be:

transfer function is the Laplace transform of a system‟s impulse response.

Given a continuous-time transfer function in the Laplace domain, H(s) or a discrete-time onein
the Z-domain, H(z), a zero is any value of s or z such that the transfer function is zero, and a
pole is any value of s or z such that the transfer function is infinite.

Zeros:1. The value(s) for z where the numerator of the transfer function equals zero2. The
complex frequencies that make the overall gain of the filter transfer functionzero.

Poles: 1. The value(s) for z where the denominator of the transfer function equals zero 2. The
complex frequencies that make the overall gain of the filter transfer functioninfinite.

Department of Electronics and Communication Engineering Page 132


BKM

Basic Simulation Lab Manual


Z-transforms 133

the Z-transform converts a discrete time-domain signal, which is a sequence of real or complex
numbers, into a complex frequency-domain representation. The Z-transform, likemany other
integral transforms, can be defined as either a one-sided or two-sided transform.

Bilateral Z-transform

The bilateral or two-sided Z-transform of a discrete-time signal x[n] is the function X(z)defined
as

Unilateral Z-transform

Alternatively, in cases where x[n] is defined only for n ≥0, the single-sided or unilateralZ-
transform is defined as

In signal processing, this definition is used when the signal is causal.

The roots of the equation P(z) = 0 correspond to the 'zeros' of X(z)The roots of the equation
Q(z) = 0 correspond to the 'poles' of X(z)

PROCEDURE:-
 Open MATLAB
 Open new M-file
 Type the program
 Save in current directory
 Compile and Run the program
 For the output see command window\ Figure window

Department of Electronics and Communication Engineering Page 133


BKM

Basic Simulation Lab Manual


134
PROGRAM:-

%locating poles of zero on s-plane%

clc;
clear all;
close all;
num=input('enter numerator co-efficients');
den=input('enter denominator co-efficients');h=tf(num,den);
poles=roots(den); zeros=roots(num);sgrid;
pzmap(h);
grid on;
title('locating poles of zeros on s-plane');

%locating poles &zeros on z-


plane%

clc;
clear all;close all;
num=input('enter numerator coefficient'); den=input('enter denominator coefficient');
p=roots(den);
z=roots(num);zplane(p,z); grid;
title('locating poler and zeros on s-plane');

Department of Electronics and Communication Engineering Page 134


BKM

Basic Simulation Lab Manual


OUTPUT: - 135

locating poles of zero on s-plane

enter numerator coefficient[1 2 3]


enter denominator coefficient[7 6 5]

1.5 1.4
0.5 0.36 0.27 0.19 0.12 0.06
1.2
0.66
1
1
0.8
0.6
0.88
0.5 0.4
0.2

0.2
0.4
-0.5 0.88
0.6
0.8
-1 1
0.66
1.2
0.5 0.36 0.27 0.19 0.12 0.06
1.4
-1.5
-1 -0.9 -0.8 -0.7 -0.6 -0.5 -0.4 -0.3 -0.2 -0.1 0

locating poles &zeros on z-plane

enter numerator coefficient [1 2 3]


enter denominator coefficient [1 2 3]

Department of Electronics and Communication Engineering Page 135


BKM

Basic Simulation Lab Manual


136

locating poler and zeros on s-plane


1.5

0.5
Imaginary Part

-0.5

-1

-1.5
-1.5 -1 -0.5 0 0.5 1 1.5
Real Part

RESULT: -

In this experiment the zeros and poles and plotting the pole
zeromaps in s-plane and z-plane for the given transfer
function using MATLAB.
VIVA QUESTIONS: -
1.Study the details of ztrans() and iztrans() functions?
2.What are poles and zeros?
3.How you specify the stability based on poles and zeros?
4.Define S-plane and Z-plane?
5.What is the difference b/w S-plane and Z-plane?6.Define Scaling Property of Z-plane?
7. Explain Time Convolution Property of Z-plane?
8. Explain Frequency Convolution Property of Z-plane
9. Explain the linearity property of Z-plane?10.Describe the advantages of Z-plane?

Department of Electronics and Communication Engineering Page 136


BKM

Basic Simulation Lab Manual


137
EXERCISE PROGRAMS

1. Write a MATLAB program to find the impulse response of the following difference
equation3y(n)-5y(n-1)+4y(n-2)=x(n)-2x(n-1).
2. Write a MATLAB program to find the impulse response of the following difference
equation6y(n)-9y(n-1)-4y(n-2)=x(n)-5x(n-1).
3. Write a MATLAB program to find the impulse response of the following difference
equation8y(n)-6y(n-1)+4y(n-2)=x(n)+2x(n-1).
4. Write a MATLAB program to find the impulse response of the following difference
equation3y(n)+5y(n-1)+9y(n-2)=x(n)-9x(n-1).
5. Write a MATLAB program to find the impulse response of the following difference
equation6y(n)-5y(n-1)+4y(n-2)=x(n)-2x(n-1).
6. Write a MATLAB program to find the impulse response of the following difference
equation7y(n)-5y(n-1)+4y(n-2)=x(n)-9x(n-1).
7. Write a MATLAB program to find the impulse response of the following difference
equation3y(n)-5y(n-1)+4y(n-2)=x(n)-6x(n-1).
8. Write a MATLAB program to find the impulse response of the following difference
equation5y(n)-5y(n-1)+5y(n-2)=x(n)-2x(n-1).
9. Write a MATLAB program to find the impulse response of the following difference
equation3y(n)-6 y(n-1)+4y(n-2)=x(n)-7x(n-1).
10. Write a MATLAB program to find the impulse response of the following difference
equation2y(n)-5y(n-1)+4y(n-2)=x(n)-2x(n-1).
11. Write a MATLAB program to find the impulse response of the following difference
equation3y(n)-5y(n-1)+4y(n-2)=5x(n)-6x(n-1).
12. Write a MATLAB program to find the impulse response of the following difference
equation6y(n)-8y(n-1)-4y(n-2)=7x(n)-5x(n-1).
13. Write a MATLAB program to find the impulse response of the following difference
equation8y(n)-8y(n-1)+9y(n-2)=x(n)+5x(n-1).
14. Write a MATLAB program to find the impulse response of the following difference
equation3y(n)+9y(n-1)+9y(n-2)=9x(n)-5x(n-1).
15. Write a MATLAB program to find the impulse response of the following difference
equation6y(n)-5y(n-1)+4y(n-2)=7x(n)-2x(n-1).
16. Write a MATLAB program to find the impulse response of the following difference
equation7y(n)-5y(n-1)+4y(n-2)=x(n)-7x(n-1).
17. Write a MATLAB program to find the impulse response of the following difference
equation3y(n)-5y(n-1)+4y(n-2)=x(n)-6x(n-1).
18. Write a MATLAB program to find the impulse response of the following difference
equation5y(n)-5y(n-1)+5y(n-2)=7x(n)-2x(n-1).
19. Write a MATLAB program to find the impulse response of the following difference
equation3y(n)-6 y(n-1)+4y(n-2)=4x(n)-x(n-1).
20. Write a MATLAB program to find the impulse response of the following difference
equation2y(n)-5y(n-1)+4y(n-2)=x(n)-2x(n-1).
21. Write a MATLAB program to find the impulse response of the following difference equation

Department of Electronics and Communication Engineering Page 137


BKM

Basic Simulation Lab Manual


7y(n)-5y(n-1)+y(n-2)=x(n)-7x(n-1). 138
22. Write a MATLAB program to find the impulse response of the following difference
equation3y(n)-5y(n-1)+4y(n-2)=x(n)-6x(n-1)+u(n)
23. Write a MATLAB program to find the impulse response of the following difference
equation5y(n)-5y(n-1)+5y(n-2)=7x(n)-2x(n-1)+u(n).
24. Write a MATLAB program to find the impulse response of the following difference
equation3y(n)-6 y(n-1)+4y(n-2)=4x(n)-x(n-1)+u(n).
25. Write a MATLAB program to find the impulse response of the following difference
equation2y(n)-5y(n-1)+4y(n-2)=x(n)-2x(n-1)+u(n).
26. Write a MATLAB program to find the impulse response of the following difference
equation3y(n)-5y(n-1)+4y(n-2)=4x(n)-12x(n-1).
27. Write a MATLAB program to find the impulse response of the following difference
equation6y(n)-9y(n-1)-4y(n-2)=6x(n)-15x(n-1).
28. Write a MATLAB program to find the impulse response of the following difference
equation8y(n)-6y(n-1)+4y(n-2)=8x(n)+2x(n-1).
29. Write a MATLAB program to find the impulse response of the following difference
equation3y(n)+5y(n-1)+9y(n-2)=5x(n)-9x(n-1).
30. Write a MATLAB program to find the impulse response of the following difference
equation6y(n)-5y(n-1)+4y(n-2)=x(n)-6x(n-1).

Real Time Applications:

Z- Transforms having following


applicationsAnalysis of differential
equations
Z- transform
spectroscopyQuantum
mechanics
Signal processing applications etc
Conversion of analog signals to digital signals etc

Department of Electronics and Communication Engineering Page 138

You might also like