BS Lab Manual PDF
BS Lab Manual PDF
LABORATORY MANUAL
BASIC SIMULATION
II B.TECH -I Semester (ECE)
Prepared by
A RAJKIRAN
Asst.Professor
ECE
List of Experiments:
FG
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.
INDEX
4 Finding the even and odd parts of signal/ sequence and real and imaginary
parts of signal. 39
10 Finding the Fourier transform of a given signal and plotting its magnitude 76
and Phase spectrum.
12 Locating the zeros and poles and plotting the pole-zero maps in S plane 84
and Z-plane for the given transfer function.
EXPERMENT NO:1
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:-
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
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
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
\
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
c=
2 4 -6
6 4 8
10 4 12
d=
0 0 -12
-2 -6 -4
-4 -12 -6
e=
VIVA QUESTIONS:-
EXERCISE PROGRAMS
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
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.
EXPERMENT NO:2
GENERATION OF VARIOUS SIGNALS&SEQUENCES
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.
If b>a, then
Solution:
And
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:
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
Sinc Function
And
Sinc(0)=1
Also, the Sinc function approaches zero as x goes towards infinity, with the envelope of sinc(x)
tapering off as 1/x.
Rect Function
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:
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:-
Triangle wave
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:-
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');
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');
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');
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');
%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');
OUTPUT:-
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
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
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
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
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
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.
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?
EXERCISE QUESTIONS
5.
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.
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:-
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 Amplification/Attuation :
Multiplication/Divition :
folding:
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;
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');
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;
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');
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');
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');
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');
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');
OUTPUT:-
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
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
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
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
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:-
VIVA QUESTIONS:-
EXERCISE PROGRAM
EXPERMENT NO:4
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:-
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)}
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):
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:-
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');
xmir=fliplr(x);
subplot(4,1,2);
stem(n,xmir,'r');
xlabel('time');
ylabel('amplitude');
title('folded sequence');
xeven=(x+xmir)/2;
subplot(4,1,3);
stem(n,xeven,'r');
xlabel('time');
ylabel('amplitude');
title('even part of sequence');
xodd=(x-xmir)/2;
subplot(4,1,4);
stem(n,xodd,'g');
xlabel('time');
ylabel('amplitude');
title('odd part of sequence');
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
OUTPUT:-
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 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 energy
and power of signals have been calculated Using MATLAB.
VIVA QUESTIONS:-
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.
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:-
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;
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');
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:-
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
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:-
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?
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.
EXPERMENT NO:6
AIM: -
To compute auto correlation and cross correlation between signals and
Sequences.
SOFTWARE REQURIED:-
1.MATLAB R2010a.
2.Windows XP SP2.
THEORY:-
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;
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');
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');\
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');
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:-
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
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
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
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:-
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?
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.
EXPERMENT NO:7
AIM: -
SOFTWARE REQURIED:-
1.MATLAB R2010a.
2.Windows XP SP2.
THEORY:-
LINEARITY PROPERTY
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:-
%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');
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;
OUTPUT:-
Program1:
Program2:
Program3:
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
EXPERMENT NO:8
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:-
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,
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;
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);
OUTPUT:-
RESULT:-
VIVA QUESTIONS:-
EXERCISE PROGRAM:-
EXPERMENT NO:9
AIM: -
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
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');
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
RESULT:-
EXERCISE PROGRAM:-
VIVA QUESTIONS:-
EXPERMENT NO:10
AIM: -
SOFTWARE REQURIED:-
1.MATLAB R2010a.
2.Windows XP SP2.
THEORY:-
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
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
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
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;
OUTPUT:-
Fourier Transform
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:-
VIVA QUESTIONS:-
EXERCISE PROGRAMS
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:-
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:
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.
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
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
EXPERMENT NO:12
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:
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.
Z-transforms
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
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;
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');
OUTPUT:-
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.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
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
VIVA QUESTIONS:-
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).
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
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
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 MATLAB
functions.
VIVA QUESTIONS:-
EXERCISE PROGRAMS
EXPERMENT NO:14
SAMPLING THEORM
AIM: -
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.
Let gs(t) be the sampled signal. Its Fourier Transform Gs(w) isgiven by
Aliasing
{ Aliasing is a phenomenon where the high frequency components of the sampled signal
interfere with each other because of inadequate sampling ws < 2wm.
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;
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;
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
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
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:-
VIVA QUESTIONS:-
EXERCISE PROGRAM:-
EXPERMENT NO:15
AIM: -
SOFTWARE REQURIED:-
1.MATLAB R2010a.
2.Windows XP SP2.
THEORY:-
T/2 1/T
Lim ∫ S(t)n(t-T) dt=0 for all T
T∞ -T/2
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
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).
f(t)=s(t)+n(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:-
%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 %
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');
OUTPUT:-
auto correlation
CROSS CORRELATION
RESULT:-
VIVA QUESTIONS:-
EXERCISE PROGRAMS
EXPERMENT NO:16
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
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));
OUTPUT:-
RESULT:-
Using Cross- correlation the periodic signal from noise was estimated using
MATLAB.
VIVA QUESTIONS:-
EXERCISE PROGRAM:-
EXPERMENT NO:17
AIM: -
Verification of wiener‒khinchine relation.
SOFTWARE REQURIED:-
1.MATLAB R2010a.
2.Windows XP SP2.
THEORY:-
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
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);
OUTPUT:-
wiener‒khinchine relation
RESULT:-
VIVA QUESTIONS:-
EXERCISE PROGRAMS
EXPERMENT NO:18
AIM: -
SOFTWARE REQURIED:-
1.MATLAB R2010a.
2.Windows XP SP2.
THEORY:-
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
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)
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
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:-
RESULT:-
VIVA QUESTIONS:-
EXERCISE PROGRAMS