0% found this document useful (0 votes)
390 views

BS Lab Manual PDF

This document provides instructions for students on performing basic operations on matrices in MATLAB. It introduces MATLAB and some of its built-in scalar and vector functions for numerical computation and data visualization. These include functions for basic arithmetic operations on matrices like addition and subtraction as well as trigonometric, logarithmic, exponential and other mathematical functions that operate on matrices element-wise. The aim of the experiment is to familiarize students with MATLAB's matrix-based operations and notation for linear algebra.

Uploaded by

MohdShahid
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)
390 views

BS Lab Manual PDF

This document provides instructions for students on performing basic operations on matrices in MATLAB. It introduces MATLAB and some of its built-in scalar and vector functions for numerical computation and data visualization. These include functions for basic arithmetic operations on matrices like addition and subtraction as well as trigonometric, logarithmic, exponential and other mathematical functions that operate on matrices element-wise. The aim of the experiment is to familiarize students with MATLAB's matrix-based operations and notation for linear algebra.

Uploaded by

MohdShahid
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/ 132

MLRITM BASIC SIMULATION LAB

LABORATORY MANUAL

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

Prepared by

A RAJKIRAN
Asst.Professor
ECE

MARRI EDUCATIONAL SOCIETY’S GROUP OF INSTITUTIONS

MARRI LAXMAN REDDY INSTITUTE OF TECHNOLOGY & MANAGEMENT


(Approved by AICTE, New Delhi & Affiliated JNTU, Hyderabad

Department of Electronics and Communication Engineering Page 1


MLRITM BASIC SIMULATION LAB

MARRI EDUCATIONAL SOCIETY’S GROUP OF INSTITUTIONS


MARRI LAXMAN REDDY INSTITUTE OF TECHNOLOGY & MANAGEMENT
(Approved by AICTE, New Delhi & Affiliated JNTU, Hyderabad)
Dundigal, Quthbullapur (M), Hyderabad – 43

DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING

List of Experiments:

1. Basic Operations on Matrices.


2. Generation of Various Signals and Sequences (Periodic and Aperiodic), such as
Unit impulse, unitstep, square, saw tooth, triangular, sinusoidal, ramp, sinc.
3. Observations on signals and sequences such as addition, multiplication, scaling ,
shifting, folding,computation of energy and average power.
4. Finding the even and odd parts of signal/ sequence and real and imaginary parts
of signal.
5. Convolution between signals and sequences.
6. Autocorrelation and cross correlation between signals and sequences.
7.. Verification of linearity and time invariance properties of a gi
given
ven continuous/
discrete system.
8.. Computation of unit sample, unit step and sinusoidal responses of the given
LTI system andverifying its physical realizability and stability properties.
9. Gibbs phenomenon.
10. Finding the Fourier transform of a given signal and plotting its magnitude and
Phase spectrum.
11. Waveformform synthesis using Laplace Tra
Transform.
12.. Locating the zeros and poles and plotting the pole
pole-zero maps in S plane and
Z-plane
plane for the giventransfer function.
13. Generation
ation of Gaussian noise (real and complex), computation of its mean,
M.S.Value
Value and its Skew,Kurtosis, and PSD, Probability Distribution Function.
14.. Sampling theorem verification.
15.. Removal of noise by autocorrelation / cross correlation.
16.Extraction
action of periodic signal masked by noise using correlation.
17.Verification of winer-khinchine
khinchine relations.
18. Checking a random process for stationary in wide sense.

FG

Department of Electronics and Communication Engineering Page 2


MLRITM BASIC SIMULATION LAB

INSTRUCTIONS TO THE STUDENT FJHINSTRUCTIONS


TO THE STUDENT

FJHFHINSTRUCTIONS TO THE STUDENT

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 3 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 to
be 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
25 sessional marks and 50 end examination marks.

10. Of the 25 marks for internal, 15 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 3


MLRITM BASIC SIMULATION LAB

INDEX

SL.NO. EXPERIMENT NAME PAGENO.

1 Basic Operations on Matrices. 5

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


such as Unit impulse, unit step, square, saw tooth, triangular, sinusoidal, 10
ramp, sinc.
3 Observations on signals and sequences such as addition, multiplication,
scaling ,shifting, folding, computation of energy and average power. 28

4 Finding the even and odd parts of signal/ sequence and real and imaginary
parts of signal. 39

5 Convolution between signals and sequences. 45

6 Autocorrelation and cross correlation between signals and sequences. 50

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


continuous/discrete system.
8 Computation of unit samples, unit step and sinusoidal response of the given 66
LTI system and verifying its physical realiazability and stability properties.
9 Gibbs phenomenon. 72

10 Finding the Fourier transform of a given signal and plotting its magnitude 76
and Phase spectrum.

11 Waveform synthesis using Laplace Transform. 81

12 Locating the zeros and poles and plotting the pole-zero maps in S plane 84
and Z-plane for the given transfer function.

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


M.S. Value and its Skew, Kurtosis, and PSD, Probability Distribution 90
Function.

14 Sampling theorem verification. 94

15 Removal of noise by autocorrelation / cross correlation. 104

16 Removal of noise by auto correlation/cross correlation. 111


17 Verification of winer- khinchine relations. 116

18 Checking a random process for stationary in wide sense.


120

Department of Electronics and Communication Engineering Page 4


MLRITM BASIC SIMULATION LAB

EXPERMENT NO:1

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 what
makes 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 when
applied 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

Department of Electronics and Communication Engineering Page 5


MLRITM BASIC SIMULATION LAB

9. abs - absolute value


10. sqrt - square root
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 of
these 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 separated
into two sub-categories.
The first one consists of convenient matrix building functions, some of which are given
below.
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 matrix
eg: 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 6


MLRITM BASIC SIMULATION LAB

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 7


MLRITM BASIC SIMULATION LAB

\
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 is

d=

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 was
Successfully completed.

Department of Electronics and Communication Engineering Page 8


MLRITM BASIC SIMULATION LAB

VIVA QUESTIONS:-

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?

Department of Electronics and Communication Engineering Page 9


MLRITM BASIC SIMULATION LAB

EXERCISE PROGRAMS

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 matrix
A = [24,-30, 64,-81], b= [6,5,8,9] and verify the result.

5. Write a matlab program to perfom 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 perfom 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.

Department of Electronics and Communication Engineering Page 10


MLRITM BASIC SIMULATION LAB

EXPERMENT NO:2
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,saw tooth,triangular,sinc signals.

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 but
we can do so by using the graphs shown below.

Department of Electronics and Communication Engineering Page 11


MLRITM BASIC SIMULATION LAB

Key Concept: Sifting Property of the Impulse

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 12


MLRITM BASIC SIMULATION LAB

Sometimes, u(0) is given other values, usually either 0 or 1. For many applications, it is
irrelevant 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 will
be described in more detail next.

Integral

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

Department of Electronics and Communication Engineering Page 13


MLRITM BASIC SIMULATION LAB

Sinc Function

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 fu
function"
nction" and is discussed below:

The Sinc function is defined in the following manner:

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 th


the Squeeze Theorem to show that the sinc function
approaches one as x goes to zero. Thus, defining ssinc(0)
inc(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


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/A
and setting the pulse width to A, which approaches zero:

Department of Electronics and Communication Engineering Page 14


MLRITM BASIC SIMULATION LAB

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 15


MLRITM BASIC SIMULATION LAB

Sinusoidal Signal Generation

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 time
interval, 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 the
amplitude 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 16


MLRITM BASIC SIMULATION LAB

%unit step function%

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

Department of Electronics and Communication Engineering Page 17


MLRITM BASIC SIMULATION LAB

xlabel('time');
ylabel('amplitude');
title('sinusoidal signal');
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 18


MLRITM BASIC SIMULATION LAB

%trianguler function%

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 19


MLRITM BASIC SIMULATION LAB

OUTPUT:-

unit impulse function

unit impulse function


1
amplitude

0.5

0
-10 -8 -6 -4 -2 0 2 4 6 8 10
time
unit impulse discreat function
1
amplitude

0.5

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

Department of Electronics and Communication Engineering Page 20


MLRITM BASIC SIMULATION LAB

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 21


MLRITM BASIC SIMULATION LAB

unit ramp function

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

Department of Electronics and Communication Engineering Page 22


MLRITM BASIC SIMULATION LAB

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 23


MLRITM BASIC SIMULATION LAB

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

Department of Electronics and Communication Engineering Page 24


MLRITM BASIC SIMULATION LAB

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


MLRITM BASIC SIMULATION LAB

trianguler function

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

Department of Electronics and Communication Engineering Page 26


MLRITM BASIC SIMULATION LAB

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 completed
by using MATLAB.

Department of Electronics and Communication Engineering Page 27


MLRITM BASIC SIMULATION LAB

Department of Electronics and Communication Engineering Page 28


MLRITM BASIC SIMULATION LAB

VIVA QUESTIONS:-

1. Define Signal?
2. Define determistic and Random Signal?
3. Define Delta Function?
4. What is Signal Modeling?
5. Define Periodic and a periodic Signal?

Department of Electronics and Communication Engineering Page 29


MLRITM BASIC SIMULATION LAB

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 signal
r(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 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 a sinc wave with amplitude = -8, frequency5Khz.

Department of Electronics and Communication Engineering Page 30


MLRITM BASIC SIMULATION LAB

EXPERMENT NO:3

OPERATION 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 signal
If 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 in
Figure 1.

Signal Addition and Substraction :

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


MLRITM BASIC SIMULATION LAB

Signal Amplification/Attuation :

Multiplication/Divition :

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

Department of Electronics and Communication Engineering Page 32


MLRITM BASIC SIMULATION LAB

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');
title('first signal');
s2=8*sin(2*pi*5*t);
subplot(4,1,2);
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%

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

Department of Electronics and Communication Engineering Page 33


MLRITM BASIC SIMULATION LAB

subplot(3,1,2);
plot(t,s2,'r');
xlabel('time');
ylabel('amplitude');
title('amplified signal');
s3=s1/3;
subplot(3,1,3);
plot(t,s3,'g');
xlabel('time');
ylabel('amplitude');
title('attenuated signal');

%Time scaling for signals%

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

%Time shifting of a signal%

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

Department of Electronics and Communication Engineering Page 34


MLRITM BASIC SIMULATION LAB

xlabel('time');
ylabel('amplitude');
title('sinusoidal signal');
t1=t+10;
subplot(3,1,2);
plot(t1,s1,'r');
xlabel('time');
ylabel('amplitude');
title('right shift of the signal');
t2=t-10;
subplot(3,1,3);
plot(t2,s1,'g');
xlabel('time');
ylabel('amplitude');
title('left shift of the signal');

%Time folding of a signal%

clc;
clear all;
close all;
t=0:0.001:2;
s=sin(2*pi*5*t);
m=length(s);
n=[-m:m];
y=[0,zeros(1,m),s];
subplot(2,1,1);
plot(n,y,'g');
xlabel('time');
ylabel('amplitude');
title('original signal');
y1=[fliplr(s),0,zeros(1,m)];
subplot(2,1,2);
plot(n,y1,'r');
xlabel('time');
ylabel('amplitude');
title('folded signal');

Department of Electronics and Communication Engineering Page 35


MLRITM BASIC SIMULATION LAB

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 36


MLRITM BASIC SIMULATION LAB

Amplitude scaling for signals

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 37


MLRITM BASIC SIMULATION LAB

Time scaling for signals

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 38


MLRITM BASIC SIMULATION LAB

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 39


MLRITM BASIC SIMULATION LAB

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 been


Performed Using MATLAB have been demonstrated.

Department of Electronics and Communication Engineering Page 40


MLRITM BASIC SIMULATION LAB

VIVA QUESTIONS:-

1. Define Symetric 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?

Department of Electronics and Communication Engineering Page 41


MLRITM BASIC SIMULATION LAB

EXERCISE PROGRAM

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


2. Write a MATLAB program to subtract to sinusoidal signals.
3. Write a MATLAB program to subtract and multiply to 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 to different signals with 2 <t<5
7. Write a MATLAB progran to to shift a positive time line signal to negative timeline signal.
8. Write a matlab program to get the following output.

Department of Electronics and Communication Engineering Page 42


MLRITM BASIC SIMULATION LAB

EXPERMENT NO:4

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:

Department of Electronics and Communication Engineering Page 43


MLRITM BASIC SIMULATION LAB

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).

If x(t) is a real-valued signal with Fourier transform X(f), and u(f) is the Heaviside step function,
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):

Department of Electronics and Communication Engineering Page 44


MLRITM BASIC SIMULATION LAB

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

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

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

PROGRAM:-

%Even,odd,real,imaginary parts of a sequences%

clc;
clear all;
close all;
h=input('enter no.of samples');
m=(h-1)/2;
n=-m:m;
x=input('enter sample values');
subplot(4,1,1);
stem(n,x,'g');
xlabel('time');
ylabel('amplitude');
title('original sequence');

Department of Electronics and Communication Engineering Page 45


MLRITM BASIC SIMULATION LAB

xmir=fliplr(x);
subplot(4,1,2);
stem(n,xmir,'r');
xlabel('time');
ylabel('amplitude');
title('folded sequence');

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

%odd part of sequence%

xodd=(x-xmir)/2;
subplot(4,1,4);
stem(n,xodd,'g');
xlabel('time');
ylabel('amplitude');
title('odd part of sequence');

%Real&Imaginary parts of a sequences%

clc;
clear all;
close all;
y=input('enter complex numbers');
yreal=real(y);
disp('real values of y');
yreal
yimag=imag(y);
disp('imaginary values of y');
yimag

Department of Electronics and Communication Engineering Page 46


MLRITM BASIC SIMULATION LAB

OUTPUT:-

Even,odd,real,imaginary parts of a sequences

enter 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 =

Department of Electronics and Communication Engineering Page 47


MLRITM BASIC SIMULATION LAB

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 energy
and power of signals have been calculated Using MATLAB.

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?

Department of Electronics and Communication Engineering Page 48


MLRITM BASIC SIMULATION LAB

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 for
the 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 reacts
for the above program.

Department of Electronics and Communication Engineering Page 49


MLRITM BASIC SIMULATION LAB

EXPERMENT NO:5

LINEAR CONVOLUTION

AIM: -
To find the out put 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 50


MLRITM BASIC SIMULATION LAB

PROGRAM:-

%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);
Department of Electronics and Communication Engineering Page 51
MLRITM BASIC SIMULATION LAB

stem(h,'r');
xlabel('discrete time');
ylabel('h(n)');
title('second sequence');
subplot(3,1,3);
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 convolution signal
x 10
1
amplitude

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

Department of Electronics and Communication Engineering Page 52


MLRITM BASIC SIMULATION LAB

Convolution of two sequences

enter the length of 1st sequence4


enter the length of 2nd sequence4
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 been


performed Using MATLAB.

Department of Electronics and Communication Engineering Page 53


MLRITM BASIC SIMULATION LAB

VIVA QUESTIONS:-

1. Define Convolution?
2. Define Properties of Convolution?
3. What is the Difference Between Convolution& Correlation?
4. What are Dirchlet Condition?
5.What is Half Wave Symmetry?

Department of Electronics and Communication Engineering Page 54


MLRITM BASIC SIMULATION LAB

EXERCISE PROGRAMS

1.Write the MATLAB program to perform convolution between the following sequences
X(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 and
see how mat lab reacts to it.
3. Write a MATLAB program to perform convolution between square and step signal and see
how mat lab reacts to it.
4. Write a MATLAB program to perform convolution between sinusoidal and ramp signal and
see 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.

Department of Electronics and Communication Engineering Page 55


MLRITM BASIC SIMULATION LAB

EXPERMENT NO:6

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
autocorrelationRff(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


MLRITM BASIC SIMULATION LAB

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

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


MLRITM BASIC SIMULATION LAB

%cross correlation for a signal%

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

%cross correlation for asequence%

Department of Electronics and Communication Engineering Page 58


MLRITM BASIC SIMULATION LAB

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

Department of Electronics and Communication Engineering Page 59


MLRITM BASIC SIMULATION LAB

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 60


MLRITM BASIC SIMULATION LAB

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

Department of Electronics and Communication Engineering Page 61


MLRITM BASIC SIMULATION LAB

Auto correlation for a sequence

enter sample values[1 2 3 4]

x=

1 2 3 4

input sequence
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

Department of Electronics and Communication Engineering Page 62


MLRITM BASIC SIMULATION LAB

cross correlation for asequence

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

RESULT:-

In this experiment correlation of various signals have been performed Using


MATLAB.

Department of Electronics and Communication Engineering Page 63


MLRITM BASIC SIMULATION LAB

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?

Department of Electronics and Communication Engineering Page 64


MLRITM BASIC SIMULATION LAB

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.

Department of Electronics and Communication Engineering Page 65


MLRITM BASIC SIMULATION LAB

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

LINEAR TIME INVARIENT SYSTEMS(LTI)

Department of Electronics and Communication Engineering Page 66


MLRITM BASIC SIMULATION LAB

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:-

Department of Electronics and Communication Engineering Page 67


MLRITM BASIC SIMULATION LAB

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

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

Department of Electronics and Communication Engineering Page 68


MLRITM BASIC SIMULATION LAB

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;

%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 69


MLRITM BASIC SIMULATION LAB

OUTPUT:-

Program1:

Department of Electronics and Communication Engineering Page 70


MLRITM BASIC SIMULATION LAB

Program2:

Department of Electronics and Communication Engineering Page 71


MLRITM BASIC SIMULATION LAB

Program3:

Department of Electronics and Communication Engineering Page 72


MLRITM BASIC SIMULATION LAB

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

Department of Electronics and Communication Engineering Page 73


MLRITM BASIC SIMULATION LAB

EXPERMENT NO:8

COMPUTATION OF UNIT SAMPLE, UNIT STEP AND


SINUSOIDAL RESPONSE OF THE GIVEN LTI SYSTEM AND
VERIFYING ITS PHYSICAL REALIZABILITY AND STABILITY
PROPERTIES.

AIM: -

To Unit Step And Sinusoidal Response Of The Given LTI System And Verifying
Its Physical Realizability 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 is
known 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 of
discrete impulses. Now the system response is given by,

Department of Electronics and Communication Engineering Page 74


MLRITM BASIC SIMULATION LAB

For linear system (1) reduces to

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 75


MLRITM BASIC SIMULATION LAB

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 76


MLRITM BASIC SIMULATION LAB

OUTPUT:-

plot the impulse response and step response

Department of Electronics and Communication Engineering Page 77


MLRITM BASIC SIMULATION LAB

RESULT:-

In this experiment computation of unit sample, unit step and


sinusoidal response of the given lti system and verifying its physical realizability
andstability properties Using MATLAB.

Department of Electronics and Communication Engineering Page 78


MLRITM BASIC SIMULATION LAB

VIVA QUESTIONS:-

1.What operations can be performed on signals and sequence?


2.Define causality and stability?
3.Define scaling property and give its importance?
4. Define shifting property and give its importance?
5.Define folding property and give its importance?

EXERCISE PROGRAM:-

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.

Department of Electronics and Communication Engineering Page 79


MLRITM BASIC SIMULATION LAB

EXPERMENT NO:9

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 equispaced 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 80


MLRITM BASIC SIMULATION LAB

PROGRAM:-

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

Department of Electronics and Communication Engineering Page 81


MLRITM BASIC SIMULATION LAB

OUTPUT:-

Gibbs phenomenon

enter no of harmonics5

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 82


MLRITM BASIC SIMULATION LAB

RESULT:-

In this experiment Gibbs phenomenon have been demonstrated


Using MATLAB.

EXERCISE PROGRAM:-

1. perform convolution between the. Two periodic sequences


x1(t)=e-3t{u(t)-u(t-2)} , x2(t)= e -3t for 0 ≤ t ≤ 2.

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?

Department of Electronics and Communication Engineering Page 83


MLRITM BASIC SIMULATION LAB

EXPERMENT NO:10

FINDING THE FOURIER TRANSFORM OF A GIVEN SIGNAL


AND PLOTTING ITS MAGNITUDE AND PHASE SPECTRUM

AIM: -

To obtain Fourier Transform and Inverse Fourier Transform of a given


signal / 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


MLRITM BASIC SIMULATION LAB

The fast Fourier transform (FFT) is an efficient algorithm for computing the DFT of a
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 elements

N
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


MLRITM BASIC SIMULATION LAB

PROGRAM:-

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

Department of Electronics and Communication Engineering Page 86


MLRITM BASIC SIMULATION LAB

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)

magnitude spectrum of a input signal

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

Department of Electronics and Communication Engineering Page 87


MLRITM BASIC SIMULATION LAB

RESULT:-

In this experiment the fourier transform of a given signal and plotting


its magnitude and phase spectrum have been demonstrated using MATLAB.

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?

EXERCISE PROGRAMS

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

Department of Electronics and Communication Engineering Page 88


MLRITM BASIC SIMULATION LAB

EXPERMENT NO:11

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.
The bilateral Laplace transform is defined as follows:

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):

Example :
Let y(t)=exp(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 89


MLRITM BASIC SIMULATION LAB

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:-

%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 signal


Y=
1/(s+2)
Inverse Laplace Transform of input signal
Z=
1/exp(2*t)

Department of Electronics and Communication Engineering Page 90


MLRITM BASIC SIMULATION LAB

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?

EXERCISE PROGRAMS

1.Write a MATLAB program to find the Laplace transform of a sinusoidal signals.

Department of Electronics and Communication Engineering Page 91


MLRITM BASIC SIMULATION LAB

EXPERMENT NO:12

LOCATING THE ZEROS AND POLES AND PLOTTING THE


POLE ZERO MAPS IN S-PLANE AND Z-PLANE FOR THE GIVEN
TRANSFER 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 one
in 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 zero
2. The complex frequencies that make the overall gain of the filter transfer function
zero.

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 function
infinite.

Department of Electronics and Communication Engineering Page 92


MLRITM BASIC SIMULATION LAB

Z-transforms

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, like
many 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 unilateral
Z-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 93


MLRITM BASIC SIMULATION LAB

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 94


MLRITM BASIC SIMULATION LAB

OUTPUT:-

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.5 0.88 0.4
0.2

0.2

-0.5 0.88 0.4

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

Department of Electronics and Communication Engineering Page 95


MLRITM BASIC SIMULATION LAB

locating poles &zeros on z-plane

enter numerator coefficient[1 2 3]


enter denominator coefficient[1 2 3]

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 zero

Department of Electronics and Communication Engineering Page 96


MLRITM BASIC SIMULATION LAB

maps 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?

EXERCISE PROGRAMS

1.Write a MATLAB program to find the impulse response of the following difference equation
3y(n)-5y(n-1)+4y(n-2)=x(n)-2x(n-1).

Department of Electronics and Communication Engineering Page 97


MLRITM BASIC SIMULATION LAB

EXPERMENT NO:13

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 time
or 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 98


MLRITM BASIC SIMULATION LAB

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

Department of Electronics and Communication Engineering Page 99


MLRITM BASIC SIMULATION LAB

OUTPUT:-

Gaussion noise

enter no of samples50

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

Department of Electronics and Communication Engineering Page 100


MLRITM BASIC SIMULATION LAB

RESULT:-

Additive White Gaussian noise was generated and its PSD and PDF were plotted
and its Mean, Standard Deviation, Kurtosis, Skew were Computed using MATLAB
functions.

VIVA QUESTIONS:-

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


2.What is gaussion noise?
3.What is correlation ?How many types of correlation are there?
4.State Paeseval’s energy theorem for a periodic signal?
5.What is Signum function?

EXERCISE PROGRAMS

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

Department of Electronics and Communication Engineering Page 101


MLRITM BASIC SIMULATION LAB

EXPERMENT NO:14

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).

Department of Electronics and Communication Engineering Page 102


MLRITM BASIC SIMULATION LAB

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


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

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

Department of Electronics and Communication Engineering Page 103


MLRITM BASIC SIMULATION LAB

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

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

Department of Electronics and Communication Engineering Page 104


MLRITM BASIC SIMULATION LAB

To recover the original signal G(w):


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

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

Aliasing

{ Aliasing is a phenomenon where the high frequency components of the sampled signal
interfere with each other because of inadequate sampling ws < 2wm.

Department of Electronics and Communication Engineering Page 105


MLRITM BASIC SIMULATION LAB

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

PROGRAM:-

%sampling theorem%
clc;
clear all;

Department of Electronics and Communication Engineering Page 106


MLRITM BASIC SIMULATION LAB

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 107


MLRITM BASIC SIMULATION LAB

OUTPUT:-

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

Department of Electronics and Communication Engineering Page 108


MLRITM BASIC SIMULATION LAB

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 109


MLRITM BASIC SIMULATION LAB

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 110


MLRITM BASIC SIMULATION LAB

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

RESULT:-

Department of Electronics and Communication Engineering Page 111


MLRITM BASIC SIMULATION LAB

In this experiment the sampling theorem have been verified


using 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?

EXERCISE PROGRAM:-

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

EXPERMENT NO:15

Department of Electronics and Communication Engineering Page 112


MLRITM BASIC SIMULATION LAB

REMOVAL OF NOISE BY AUTO CORRELATION/CROSS


CORRELATION

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 a
noise signal then

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

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


Detection 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)] dt
T--∞ -T/2

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

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

Department of Electronics and Communication Engineering Page 113


MLRITM BASIC SIMULATION LAB

Qsn(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 of
T 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). Hence
Qnc(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

PROGRAM:-

Department of Electronics and Communication Engineering Page 114


MLRITM BASIC SIMULATION LAB

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

Department of Electronics and Communication Engineering Page 115


MLRITM BASIC SIMULATION LAB

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 116


MLRITM BASIC SIMULATION LAB

OUTPUT:-

auto correlation

CROSS CORRELATION

Department of Electronics and Communication Engineering Page 117


MLRITM BASIC SIMULATION LAB

Department of Electronics and Communication Engineering Page 118


MLRITM BASIC SIMULATION LAB

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?

EXERCISE PROGRAMS

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

Department of Electronics and Communication Engineering Page 119


MLRITM BASIC SIMULATION LAB

EXPERMENT NO:16

EXTRACTION OF PERIODIC SIGNAL MASKED BY NOISE USING CORRELATION


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 all
frequencies. 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.

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 120


MLRITM BASIC SIMULATION LAB

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 signal
k=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 signal
y=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 train
cir=cxcorr1(y,d);
%plotting the original and reconstructed signal
m1=0:n/4;
figure
plot(m1,x(m1+1),'r',m1,m*cir(m1+1));

Department of Electronics and Communication Engineering Page 121


MLRITM BASIC SIMULATION LAB

OUTPUT:-

Department of Electronics and Communication Engineering Page 122


MLRITM BASIC SIMULATION LAB

Department of Electronics and Communication Engineering Page 123


MLRITM BASIC SIMULATION LAB

RESULT:-

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

VIVA QUESTIONS:-

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?

EXERCISE PROGRAM:-

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

Department of Electronics and Communication Engineering Page 124


MLRITM BASIC SIMULATION LAB

EXPERMENT NO:17

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 the
power 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 realvalued.

Discrete case:

where

Department of Electronics and Communication Engineering Page 125


MLRITM BASIC SIMULATION LAB

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 frequency
domain.

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 126


MLRITM BASIC SIMULATION LAB

OUTPUT:-

wiener‒khinchine relation

Department of Electronics and Communication Engineering Page 127


MLRITM BASIC SIMULATION LAB

RESULT:-

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


using 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?

EXERCISE PROGRAMS

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

Department of Electronics and Communication Engineering Page 128


MLRITM BASIC SIMULATION LAB

EXPERMENT NO:18

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 not
vary 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

Department of Electronics and Communication Engineering Page 129


MLRITM BASIC SIMULATION LAB

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
origin. When the auto-Correlation function Rx(t, t+T ) of the random X(t) varies with 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 is


RX(t, t+T)=Rx(T)

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

When dealing with two random process X(t) and Y(t), we say that they are jointly wide-sense
stationary 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

Department of Electronics and Communication Engineering Page 130


MLRITM BASIC SIMULATION LAB

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;

OUTPUT:-

%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 .

Department of Electronics and Communication Engineering Page 131


MLRITM BASIC SIMULATION LAB

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?

EXERCISE PROGRAMS

1.Write a program to simulate parseval’s relation

Department of Electronics and Communication Engineering Page 132

You might also like