Vous êtes sur la page 1sur 107

BS LAB 1

1. BASIC OPERATIONS ON MATRICES


AIM: To write a MATLAB Program to perform all the Basic Operations of
Matrices.

OPERATOR: MATLAB Software.

THEORY:

Basic operations on matrices:


Matrix: A system of mn number of elements arranged in the form of in ordered
set of m rows, each row consisting of an ordered set of n numbers between [ ] or
( ) or II II is called a matrix of order or type mxn
Some types of Matrices:
1. Square Matrix: If A=[aij]mxn and m=n then A is called a square matrix.
Sometimes a mxn matrix called n-rowed matrix.
2. Rectangular Matrix: A Matrix of order mxn and m≠n then it is called
Rectangular Matrix.
Ex:

3. Row Matrix: Matrix of order 1xm is called a row matrix.


Ex:

4. Column Matrix: Matrix of order nx1 is called a column matrix.


Ex:

5. Unit Matrix: A=[aij]mxn such that aij=1 for i=j aij=0 for i≠j then A is called
unit matrix.
Ex:

SSIT Dept. of
ECE
BS LAB 2

SSIT Dept. of
ECE
BS LAB 3

6. Null Matrix: A=[aij]mxn such that aij=0 i and j then A is called zero or Null

matrix.
Ex:

Trace of A Square Matrix: The sum of diagonal elements of a square matrix is


called trace of a matrix.

Ex: A= [aij]mxn denotes trace of A denoted by “tr A”

Transpose of A matrix : The matrix obtained from any given matrix A, by


interchanging its rows and columns is called transpose of a matrix, denoted by
A' or AT.
Ex:

Conjugate Matrix: The matrix is obtained by replacing the elements of a give


matrix with the corresponding conjugate complex numbers is called conjugate of
A given matrix. I t is denoted by A.
Ex:

The conjugate transpose of A matrix: The conjugate of the transpose of the


matrix A is called conjugate transpose of A and denoted by A 0.
Ex:

SSIT Dept. of
ECE
BS LAB 4

OBSERVATIONS:

SSIT Dept. of
ECE
BS LAB 5

Triangular Matrix: In a square matrix all the elements below the principle
diagonal are zero then it is upper triangular matrix and if the element above the
diagonal is zero then that is lower triangular matrix.
Symmetric Matrix: If a matrix A=[aij] said to be symmetric if a ij=aij for every i
and thus A=AT
Skew Matrix: If a matrix A=[aij] and aij=-aij then that matrix is called skew
symmetric matrix .

Program (a): Comments

Date % displaying the date.

Pi % Getting pi value.

A=4 % Assigning 4 to a variable A.

A=4; % Because of using ‘;’ command prompt only


displayed in place of answer.

Program (b):

A= [1,2,3] % Representing a row matrix.

A= [1,2,3;4,5,6;5,6,9] % Representing a 3X3 matrix

A= [1:25] % To display 1 to 25 numbers.

A= [10:-2:1] % To display the series having difference 2 in


between 10 and 1.

Program(c): Addition of two matrices

A=[1,2,3;4,5,6;5,6,9 ] % Representing a 3X3 matrix.

B=[5,6,7;1,2,3;8,7,5] % Representing a 3X3 matrix.

C=A+B % Addition of two matrices A and B assigning


that result in another variable C.

Program(d):Subtraction of two matrices

A=[1,2,3;4,5,6;5,6,9 ] % Representing a 3X3 matrix.

B=[5,6,7;1,2,3;8,7,5] % Representing a 3X3 matrix.

C=A-B % Subtraction of two matrices A and B assigning


that result in another variable C.

SSIT Dept. of
ECE
BS LAB 6

OBSERVATIONS:

SSIT Dept. of
ECE
BS LAB 7

Program (e): Multiplication of two matrices

A=[1,2,3;4,5,6;5,6,9 ] % Representing a 3X3 matrix.

B=[5,6,7;1,2,3;8,7,5] % Representing a 3X3 matrix.

C=A*B % Multiplication of two matrices A and B


assigning that result in another variable C.

F=A’ %Finding the transpose of A by using ‘ operator.

Program (f):

B=[5,6,7;1,2,3;8,7,5] % Representing a 3X3 matrix.

P=inv(B) %Finding inverse of matrix B.

T=eye(3) %getting 3X3 unit matrix by using eye function.

R=ones(3) %getting 3X3 matrix of all elements are ones.

L=zeros(3) %getting 3X3 matrix of all elements are zeros.

RESULT:

SSIT Dept. of
ECE
BS LAB 8

SSIT Dept. of
ECE
BS LAB 9

SSIT Dept. of
ECE
BS LAB 10

2. GENERATION OF VARIOUS SIGNALS AND SEQUENCES

AIM:To write a MATLAB Program to Generate various signals and sequences.

OPERATOR: MATLAB Software.

THEORY:

Sine signal: Mathematical representation (Continuous time)


x(t)=A sin =Asin(2πft)ft)

Mathematical representation (Discreet time)


x(n)=A sin

Where A=Amplitude, =Angular frequency .

Cosine signal: Mathematical representation (Continuous time)


x(t)=A cos =Acos(2πft)ft)

Mathematical representation (Discreet time)


x(n)=A cos

Where A=Amplitude, =Angular frequency.

Square signal: It is just like a rectangular signal. But the width of the positive and
negative half cycles is same for square wave.
Saw tooth Signal: It is just like a sine wave. It has amplitude and angular
frequency.
Triangular Signal: It is similar to sawtooth. If the amplitude of sawtooth occur at
the middle of the cycle. It becomes triangular signal.
Rectangular Pulse: the unit rectangular pulse is centered about the y-axis i.e
about t=0.
Mathematically it is represented as
Rect(t)= 1 for -1/2≤t≤1/2 [unit amplitude and unit duration]
0 otherwise

Arect[t/T]= A for –T/2≤t≤T/2


0 otherwise [Amplitude A and duration T]

SSIT Dept. of
ECE
BS LAB 11

SSIT Dept. of
ECE
BS LAB 12

Signum :
Mathematically it is representation

sign(t)= 1 for t>0


-1 for t<0
Sinc Function:
Mathematically it is representation
sinc(t)= 1 at x=0
0 at x=±1,±2,±3,±4…………..

Ramp signal:

Mathematically it is representation

r(t) = 1 for t≥0 [continuous time]


-1 for t<0

r[n] = 1 for n≥0 [discrete time]


-1 for n<0

Unit impulse or delta Function: Due to unity area it is called as a unit impulse
function.

Mathematically it is representation

= 1 for t=0
0 for t≠0

Unit step signal: It has unit amplitude for zero or positive values of time t, and for
negative values of time amplitude is zero.

u(t) = 1 for t≥0 [continuous time]


0 for t<0

u[n] = 1 for n≥0 [discrete time]


0 for n<0

MODELWAVE FORMS:

SSIT Dept. of
ECE
BS LAB 13

OBSERVATIONS:

PROGRAM : GENERATION OF SINE WAVE.

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

SSIT Dept. of
ECE
BS LAB 14

subplot(2,1,2);
stem(t,x,'r');
xlabel('time');
ylabel('amplitude');
title('sinusoidal sequence');
MODELWAVE FORMS:

OBSERVATIONS:

PROGRAM: GENERATION OF COSINE WAVE.

clc;
clear all;
close all;
t=0:0.01:2;
x=cos(2*pi*t);

SSIT Dept. of
ECE
BS LAB 15

subplot(2,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude');
title('Cosine signal');
subplot(2,1,2);
stem(t,x,'r');
xlabel('time');
ylabel('amplitude');
title('Cosine sequence');

MODELWAVE FORMS:

OBSERVATIONS:

SSIT Dept. of
ECE
BS LAB 16

PROGRAM : GENERATION OF SQUARE WAVE.

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');
MODELWAVE FORMS:

PROGRAM: GENERATION OF SAWTOOTH WAVE.

SSIT Dept. of
ECE
BS LAB 17

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');
MODELWAVE FORMS:

SSIT Dept. of
ECE
BS LAB 18

OBSERVATIONS:

PROGRAM : GENERATION OF TRAINGULAR WAVE.

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

xlabel('time');

ylabel('amplitude');

title('trianguler signal');

subplot(2,1,2);

stem(t,x);

xlabel('time');

ylabel('amplitude');

title('trianguler sequence');

MODELWAVE FORMS:

SSIT Dept. of
ECE
BS LAB 19

OBSERVATIONS:
PROGRAM: GENERATION OF RECTANGULAR WAVE.

Amp=5;

t=-5:0.1:5;

Y=Amp*rectpuls(t,5);

subplot(3,3,1);

plot(t,Y);

xlabel ('time');

ylabel ('amplitude');

title('generation of a rectangular wave');

PROGRAM : GENERATION OF A SIGNUM FUNCTION.

Amp=5;

t=-5:0.1:5;

Y=Amp*sign(t);

subplot(3,3,1);

plot(t,Y);

xlabel ('time');

ylabel ('amplitude');

title('generation of a signum function');

MODELWAVE FORMS:

SSIT Dept. of
ECE
BS LAB 20

OBSERVATIONS:
PROGRAM: GENERATION OF A SINC FUNCTION.

Amp=5;

t=-5:0.1:5;

Y=Amp*sinc(t);

subplot(3,3,1);

plot(t,Y);

xlabel ('time');

ylabel ('amplitude');

title('generation of a sinc function');

PROGRAM: GENERATION OF A RAMP SIGNAL.

SSIT Dept. of
ECE
BS LAB 21

n=input('RAMP');

t=0:5;

y=n*t;

subplot(3,3,1);

stem(y);

xlabel ('discrete time');

ylabel ('amplitude');

title('generation of a ramp signal');

MODELWAVE FORMS:

OBSERVATIONS:
PROGRAM: GENERATION OF A IMPULSE FUNCTION.

k1=-5;

SSIT Dept. of
ECE
BS LAB 22

k2=5;

k=k1:k2;

y= (k==0)

Subplot (3, 3, 1);

Stem(y);

xlabel ('discrete time');

ylabel ('amplitude');

title('generation of a impulse function');

PROGRAM: GENERATION OF A STEP SIGNAL.

k1=-5;

k2=5;

k=k1:k2;

y= (k>=0)

Subplot (3, 3, 1);

Stem(y);

xlabel ('discrete time');

ylabel ('amplitude');

title('generation of a step signal');

RESULT:

SSIT Dept. of
ECE
BS LAB 23

3a.OPERATIONS ON SINGLE & MULTIPLE WAVES


AIM: To write a MATLAB program for performing arithmetical operations on
signals.

OPERATOR: MATLAB Software.

THEORY:

Sine wave:
A geometric wave form that oscillates periodically and in other words it is an s-
shaped smooth wave that oscillates above and below zero. It occurs often in
pure mathematics as well as physics, signal processing, electrical engineering.
It is represented as

x (t)=A sin( ]

A=Amplitude % It is the peak deviation of the function from its center

=Angular frequency % specifies how many oscillations occur in a unit time

interval in radians per second

=Phase % It specifies where in its cycle the oscillation begins at

t=0

The sine wave is important in physics. Because it retains its wave shapes when
added to another sine wave of the same frequency and arbitrary phase.
It is only the periodic wave form that has this property. This property leads
to its importance in Fourier analysis and make its acoustically unique. In
continuous-time sine wave representation

X (t) =A sin ( )

Where A=Amplitude
ω=Angular frequency

ω Here =frequency

If we take phase shift as o or 3600 we can neglect

X (t) =A sin

Let us consider A=4 and =5 sec-1

SSIT Dept. of
ECE
BS LAB 24

Time period T=1/ =1/5=0.2

Therefore Time period of sine wave is 0.2sec

MODELWAVE FORMS:

OBSERVATIONS:

SSIT Dept. of
ECE
BS LAB 25

Program: Arithematic Operations(Addition, subtraction,


Multiplication & Division) of two sine waves.

amp=5;
fre=5;
angf=2*pi*fre;
t=0:0.005:0.2;
X=amp*sin (angf*t);
subplot (3,3,1);
plot (t,X);
xlabel ('time');
ylabel ('amplitude');
title ('First sine wave');
Y=amp*sin (angf*t);
subplot (3,3,2);
plot (t,Y);
xlabel ('time');
ylabel ('amplitude');
title ('Second sine wave');
Z=X+Y;
subplot (3,3,3);
plot (t,Z);
xlabel ('time');
ylabel ('amplitude');
title ('Addition of two sine waves');
S=X-Y;
subplot (3,3,4);
plot (t,S);
xlabel ('time');
ylabel ('amplitude');
title ('Subtration of two sine waves');
M=X.*Y;
subplot (3,3,5);
plot (t,M);
xlabel ('time');
ylabel ('amplitude');
title ('Multiplication of two sine waves');
D=X/Y;
subplot (3,3,6);
plot (t,D);
xlabel ('time');
ylabel ('amplitude');

SSIT Dept. of
ECE
BS LAB 26

title ('Division of two sine waves');

RESULT:

SSIT Dept. of
ECE
BS LAB 27

3b. OPERATIONS ON SIGNALS


AIM: To write a MATLAB program for Operations on signals such as shifting,
scaling & folding.

OPERATOR: MATLAB Software.

THEORY:

Time delay and Time advancing: Usually we represent time delay and advancing
by using step signal. We can represent time delay/advancing in both continuous
and discrete form.

Time delay: When the function is delayed it is shifted to right. If we consider a


unit step signal u(t) if it is delayed 2 units it is represented as u(t-2) in
continuous form, u(n-2) in discrete form.

Time advancing: When a signal is advanced it is shifted to left. If we consider a


unit step signal u(t) if it is advanced 2 units. It represented as u(t+2) in
continuous form u(n+2) in discrete form.

Time scaling: Scaling of the independent variable produce a signal that is


compressed or expanded along the independent axis.

Time compression: The axis is compressed. For example y(t)=x(2t), y(t) will be
compressed in time. That means the original signal is y(t)=x(t) so if we want to
get x(t) exactly we should reduce the time axis in case of y(t)=x(2t)
In continuous form:
Ex: y(t)=x(t)
if x(t)=x(2)
in case of y(t)=x(2t)
we get x(2) by taking as 1 so the time axis reduced from 2 to 1
In discrete form:
Ex: y(n)=x(2n)
Then we have
n=0 =>y(0)=x(0)=0
n=1 =>y(1)=x(2)=1
n=2 =>y(2)=x(4)=2

SSIT Dept. of
ECE
BS LAB 28

Thus the signal is compressed. Alternate samples of x(n) are skipped. This is also
called sub sampling.

Time Expansion: Time axis is expanded. For example y(t)=x(t/2). Here y(t) will be
expanded in time axis.
In continuous form:
Let us consider y(t)=x(t/2) the given signal is y(t)=x(t) for getting x(t) we
expand the time axis.

SSIT Dept. of
ECE
BS LAB 29

In discrete form:
Let us consider y(n)=x(n/2)
then we get y(0)=x(0)
y(2)=x(2/2)=x(1)
y(4)=x(4/2)=x(2) By increasing n values from 0 to A we
get the original values of given signal.

Amplitude Scaling:

Amplitude compression: Amplitude compression includes the decrease in


amplitude this is represented as
y(t)=x(t)/2 [in continuous form]
y(n)=x(n)/2 [in discrete form]

Amplitude expansion: Amplitude expansion includes the increase in amplitude


this represented as
y(t)=2x(t) [in continuous form]
y(n)=2x(n) [in discrete form]

Time folding: Time folding used in convolution. Let us consider the continuous
time signal x(t). Then its time folded signal is obtained by replacing t with –t
i.e y(t)=x(-t)
Let us consider a discrete time signal y(n)=x(-n) then n is replaced with –n gives
time folding of y(n)
y(n)=x(-n)
Important Rules for Time shifting and Time scaling
1. If a signal is given as x (t) =x (-at+b).
2. First we apply shifting operation.
3. Next apply scaling operation.
4. Next apply folding operation.

SSIT Dept. of
ECE
BS LAB 30

MODELWAVE FORMS:

OBSERVATIONS:

SSIT Dept. of
ECE
BS LAB 31

Program-A: Program for Time Shifting of Sine Wave

amp=5;
fre=5;
angf=2*pi*fre;
t=0:0.005:0.4;
X=amp*sin(angf*t);
subplot(3,3,1);
plot(t,X);
xlabel('time');
ylabel('amplitude');
title('original signal');
subplot(3,3,2);
plot(t-10,X);
xlabel('time');
ylabel('amplitude');
title('time right shift operation');
subplot(3,3,3);
plot(t+10,X);
xlabel('time');
ylabel('amplitude');
title('time left shift operation');
subplot(3,3,4);
plot(2*t,X);
xlabel('time');
ylabel('amplitude');
title('time expansion');
subplot(3,3,5);

SSIT Dept. of
ECE
BS LAB 32

plot(t/2,X);
xlabel('time');
ylabel('amplitude');
title('time compression');

MODELWAVE FORMS:

OBSERVATIONS:

SSIT Dept. of
ECE
BS LAB 33

Program-B: Program for Amplitude Scaling & Time Folding of a


Sine Wave.

amp=5;

fre=5;

angf=2*pi*fre;

t=0:0.005:0.4;

X=amp*sin(angf*t);

subplot(3,3,1);

plot(t,X);

xlabel('time');

ylabel('amplitude');

title('original signal');

subplot(3,3,2);

plot(t,2*X);

xlabel('time');

ylabel('amplitude');

title('amplitude expansion');

subplot(3,3,3);

plot(t,X/2);

xlabel('time');

ylabel('amplitude');

title('amplitude compression');

subplot(3,3,4);

SSIT Dept. of
ECE
BS LAB 34

plot(-t,X);

xlabel('time');

ylabel('amplitude');

title('time folding');

RESULT:

SSIT Dept. of
ECE
BS LAB 35

4. GENERATION OF EVEN AND ODD PARTS OF A SIGNAL


AIM: To write a MATLAB program for the Generation of EVEN and ODD parts of a
signal.

OPERATOR: MATLAB Software.

THEORY:

Symmetrical or Even signals:


A signal x(t) is said to be symmetrical or even if it satisfies the following
condition.
Condition for symmetry: x(t)=x(-t)
Example for even signal is a cosine wave shown a side and all even signals are
symmetric about y-axis.
x(t)=x(-t) [in continuous time]
x(n)=x(-n) [in discrete time]

Asymmetric or Anti symmetric or Odd signals:


A signal x(t) is said to be asymmetrical or odd if it satisfies the following
condition.
Condition for asymmetry: x(-t)=-x(t)
Example for odd signal is a sine wave and all odd signals are symmetric about
origin.
x(-t)=-x(t) [in continuous time]
x(-n)=-x(n) [in discrete time]

Decomposing a signal into even and odd parts:


Any continuous or discrete signal can be expressed as the summation of
even part and odd part.
x(t)=xe(t)+xo(t)------------- (1)
From the above equation replace t by –t we get
x(-t)=xe(-t)+xo(-t)
= x e(t)-xo(t-------------(2)
From the equations of x(t) and x(-t) we get. The representation of even signal is
obtained by adding x(t) and x(-t)

xe(t)=1/2[x(t)+x(-t)] (In continuous time)


By subtracting x(-t) from x(t) we get the representation of odd signal.
xo(t)=1/2[x(t)-x(-t)] (In continuous time)
xe(n)=1/2[x(n)+x(-n)] (In discrete time)
xo(n)=1/2[x(n)-x(-n)] (In discrete time)

SSIT Dept. of
ECE
BS LAB 36

MODEL WAVEFORMS:

OBSERVATIONS:

SSIT Dept. of
ECE
BS LAB 37

PROGRAM:

amp=4;
f=1;
angf=2*pi*f;
t=0:0.005:2;
x=sin(angf*t)+cos(angf*t);
subplot(2,2,1);
plot(t,x);
xlabel('time');
ylabel('amplitude');
title('original signal');
y=sin(angf*-t)+cos(angf*-t);
subplot(2,2,2);
plot(t,y);
xlabel('time');
ylabel('amplitude');
title('original signal replace by -t');
z=(x+y)/2;
subplot(2,2,3);
plot(t,z);
xlabel('time');
ylabel('amplitude');
title('even part of the signal');
o=(x-y)/2;
subplot(2,2,4);
plot(t,o);
xlabel('time');
ylabel('amplitude');
title('odd part of the signal');

RESULT:

SSIT Dept. of
ECE
BS LAB 38

SSIT Dept. of
ECE
BS LAB 39

5. CONVOLUTION BETWEEN TWO SIGNALS & SEQUENCES


AIM: To write a MATLAB program for computing the Convolution between
signals and Sequences.

OPERATOR: MATLAB Software.

THEORY:

Convolution is a mathematical operation performed to compare the input signal


and output signal in a linear time variant system communication devices.
It is represented by * [star or Astric]
In continuous time

x1(t)*x2(t)= d

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.

SSIT Dept. of
ECE
BS LAB 40

MODEL WAVEFORMS:

Convolution of two signals

Convolution of two sequences


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

OBSERVATIONS:

SSIT Dept. of
ECE
BS LAB 41

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

SSIT Dept. of
ECE
BS LAB 42

ylabel('y(n)');
title('convolution of two sequences');
RESULT:

SSIT Dept. of
ECE
BS LAB 43

6. AUTO CORRELATION AND CROSS CORRELATION


AIM: To Write a MATLAB program to find Autocorrelation and Cross correlation
of
two signals and sequences.

OPERATOR: MATLAB Software.

THEORY:

In signal processing cross-correlation is a measure of similarity of two wave


forms as a function of time 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
duration signal for a shorter known feature. It also has applications in pattern
recognition single particle analysis, electron topographic averaging cryptanalysis
and neurophysiology.
For continuous functions f and g the cross-correlation is defined as
(f*g)(t)

Auto correlation:
Autocorrelation is the cross-correlation of a signal with itself. It is mathematical
tool for finding repeating patterns, such as the presence of periodic signal which
has been buried under noise, or identifying the missing fundamental frequency
in a signal implied by its harmonic frequencies. It is often used in signal
processing for analyzing functions or series of values such as time domain
signals.

Given a signal f(t) the continuous Autocorrelation R ff ( ) is most often

defined as the continuous cross-correlation integral of f(t) which itself lag at .

SSIT Dept. of
ECE
BS LAB 44

MODEL WAVEFORMS:

Auto correlation for a signal

cross correlation for a signal

OBSERVATIONS:

SSIT Dept. of
ECE
BS LAB 45

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

SSIT Dept. of
ECE
BS LAB 46

Auto correlation for a sequence


enter sample values[1 2 3 4]

x= 1 2 3 4

cross correlation for asequence


enter first sequence[1 2 3 4]
enter second sequence[1 2 3 4]

OBSERVATIONS:

SSIT Dept. of
ECE
BS LAB 47

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


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

RESULT:

SSIT Dept. of
ECE
BS LAB 48

SSIT Dept. of
ECE
BS LAB 49

7. VERIFICATION OF LINEARITY & TIME INVARIENCE


PROPERTY OF A GIVEN SYSTEM
AIM: To Write a MATLAB program to verify Linearity & Time-Invarience Property
of a Given System.

i) y(t)=t*x(t)
ii) y(t)=x^2(t)
iii) y(t)=x(t^2)

OPERATOR: MATLAB Software.

THEORY:

Linear or Non linear systems: A system is called linear, if superposition


principle applies to that system. This means that a linear system may be defined
as
“The system whose response to the sum of the weighted inputs is same as the
sum of the weighted responses.”
Let us consider two systems defined as follows
y1(t)=f(x1(t))
Here x1(t) is input and y1(t) is output
y2(t)=f(x2(t))
Here x2(t) is input and y2(t) is output
Then for a linear system
f(a1x1(t)+ a2x2(t)= a1y1(t)+a2y2(t)
Here a1, a2 are constants
For continuous time system
f(a1x1(t)+ a2x2(t)= a1y1(t)+a2y2(t)
For discrete time system
f(a1x1(n)+ a2x2(n)= a1y1(n)+a2y2(n)

Non linear system: For any nonlinear system, the principle of superposition
does not hold true and the equations.
f(a1x1(t)+ a2x2(t)≠ a1y1(t)+a2y2(t)

SSIT Dept. of
ECE
BS LAB 50

SSIT Dept. of
ECE
BS LAB 51

A system is time invariant if the input-output relationship does not vary with
time. This means that a system is time-invariant if its behavior and input-output
characteristics do not change with time. For time-invariant system, the time
shifting in the input signal results in corresponding time shifting in the output.
Mathematically
Let y(t)=f(x(t))
The equation means y(t) is response for x(t), if x(t) is delayed by time t 1, then
output y(t) will also be delayed by the same time
i.e f(x(t-t1))=y(t-t1)
For discrete time system this property is called shift invariance.
f(x(n-k))=y(n-k)
If any system does not satisfy the above equations then it is called time-variant
system.
Thus, if the input-output characteristics of a system changes with the time
then the system is known as the time varying system.

SSIT Dept. of
ECE
BS LAB 52

OBSERVATIONS:

i) z1 =

z2 =

SSIT Dept. of
ECE
BS LAB 53

PROGRAM:

y(t)=t*x(t)

a=4;

b=6;

t=1;

x(t)=0.5;

x1(t)=x(t);

x2(t)=x(t);

y1(t)=t*x1(t);

y2(t)=t*x2(t);

z1(t)=a*y1(t)+b*y2(t)

z2(t)=t*(a*x1(t)+b*x2(t))

if(z1==z2)

disp(' given system is linear')

else

disp(' given system is non-linear')

end;

SSIT Dept. of
ECE
BS LAB 54

OBSERVATIONS:

ii) z1 =

z2 =

SSIT Dept. of
ECE
BS LAB 55

PROGRAM:

y(t)=x^2(t)

a=2;

b=3;

t=1;

x(t)=0.5;

x1(t)=x(t)*x(t);

x2(t)=x(t)*x(t);

y1(t)=x1(t)*x1(t);

y2(t)=x2(t)*x2(t);

z1(t)=a*y1(t)+b*y2(t)

z2(t)=a*x1(t)+b*x2(t)

if(z1==z2)

disp(' given system is linear');

else

disp(' given system is non-linear');

end;

SSIT Dept. of
ECE
BS LAB 56

OBSERVATIONS:

iii) z1 =

z2 =

SSIT Dept. of
ECE
BS LAB 57

PROGRAM:

y(t)=x(t^2)

a=2;

b=3;

t=1;

x(t)=0.5;

x1(t)=x(t*t);

x2(t)=x(t*t);

y1(t)=x1(t*t);

y2(t)=x2(t*t);

z1(t)=a*y1(t)+b*y2(t)

z2 (t)=a*x1(t)+b*x2(t)

if (z1==z2)

disp(' given system is linear');

else

disp(' given system is non-linear');

end;

SSIT Dept. of
ECE
BS LAB 58

SSIT Dept. of
ECE
BS LAB 59

MODEL WAVEFORMS:

OBSERVATIONS:

SSIT Dept. of
ECE
BS LAB 60

PROGRAM for Time Variant & Time Invariant


a=5;
f=0.1;
N=0:40;
angf=2*3.14*f;
Nd=10;
x=a*sin(angf*N);
Subplot(3,3,1);
stem(x);
xlabel('n');
ylabel('amplitude');
title('input');
x1=[zeros(1,Nd) x];
subplot(3,3,2);
stem(x1);
xlabel('n');
ylabel('amplitude');
title('shifted x');
y=x1(N+Nd);
subplot(3,3,3);
stem(y);
xlabel('n');
ylabel('amplitude');
title('left shift');
N1=N+Nd;
y1=N1.*x1(N1);
subplot(3,3,4);
stem(y1);
xlabel('n');
ylabel('amplitude');
title('output');
if(y1==y)
disp(' Given system is time invariant ');
else
disp (' Given system is time variant ');
end;
RESULT:

SSIT Dept. of
ECE
BS LAB 61

SSIT Dept. of
ECE
BS LAB 62

8. COMPUTATION OF UNIT SAMPLE, UNIT STEP AND


SINUSOIDAL RESPONSE OF THE GIVEN LTI SYSTEM
AIM: To Write a MATLAB Program to Computation of Unit Sample, Unit Step and
Sinusoidal Response of The Given LTI System And Verifying Its Physical
Reliability and Stability Properties.
OPERATOR: MATLAB Software.

THEORY:

Linear Time-Invariant Systems:

LTI systems must satisfy two general properties, time invariance and linearity

1. x[n − k ] ↦−→ y [n − k ].

2. T {a1* x1 [n] + a2* x2 [n]} = a1 T {x1 [n]} + a2 T {x2 [n]}.

Unit Step Response of LTI System:

The step response of a discrete-time LTI system is the convolution of the unit
step with the impulse response:-

s[n]=u[n]*h[n].

Via commutative property of convolution, s[n]=h[n]*u[n].

That means s[n] is the response to the input h[n] of a discrete-time LTI system
with unit impulse response u[n].

The impulse response h[n] of an LTI system is just the response to an impulse:

δ[n] → LTI → h[n].

SSIT Dept. of
ECE
BS LAB 63

MODEL WAVEFORMS:

OBSERVATIONS:

SSIT Dept. of
ECE
BS LAB 64

PROGRAM:

b=[1];
a=[1,-1,.9];
x=impulse(0,-20,120);
n = [-20:120];
h=filter(b,a,x);
subplot(3,1,1);
stem(h);
title('impulse response');
xlabel('n');
ylabel('h(n)');
step(0,-20,120);
s=filter(b,a,x);
s=filter(b,a,x);
subplot(3,1,2);
stem(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);

RESULT:

SSIT Dept. of
ECE
BS LAB 65

SSIT Dept. of
ECE
BS LAB 66

9. GIBBS PHENOMENON
AIM: To Write a MATLAB Program to demonstrate the Gibbs Phenomenon.

OPERATOR: MATLAB Software.

THEORY:

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.

SSIT Dept. of
ECE
BS LAB 67

MODEL WAVEFORMS:

No. of Harmonics: 5

OBSERVATIONS:

SSIT Dept. of
ECE
BS LAB 68

PROGRAM:

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

RESULT:

SSIT Dept. of
ECE
BS LAB 69

SSIT Dept. of
ECE
BS LAB 70

10. FOURIER TRANSFORM OF A GIVEN SIGNAL AND


PLOTTING ITS MAGNITUDE AND PHASE SPECTRUM

AIM: To write a MATLAB program to obtain Fourier Transform and Inverse


Fourier Transform of a given signal / sequence and to plot its Magnitude
and Phase Spectra.

OPERATOR: MATLAB Software.

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 e 2πft)inx/T in the Fourier
series of ƒ is given by

By definition

SSIT Dept. of
ECE
BS LAB 71

MODEL WAVEFORMS:-

Fourier Transform

Fourier Transform of input signal

Y= 1/(2+w*i)

Inverse Fourier Transform of input signal

Z= Heaviside(x)/exp(2*x)

OBSERVATIONS:

SSIT Dept. of
ECE
BS LAB 72

PROGRAM:-

%Fourier Transform%

clc
clear all;
close all;
syms t;
x=exp(-2*t)*heaviside(t);
subplot(3,1,1);
ezplot(x);
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(3,1,2);
ezplot(mg);
xlabel('time');
ylabel('amplitude');
title('magnitude spectrum of a input signal');
grid;
pha=atan(imag(y)/real(y));
subplot(3,1,3);
ezplot(pha);
xlabel('time');
ylabel('amplitude');
title('phasespectrum of a input signal');
grid;
RESULT:

SSIT Dept. of
ECE
BS LAB 73

SSIT Dept. of
ECE
BS LAB 74

11. LAPLACE TRANSFORM

AIM: To write a MATLAB program to perform waveform synthesis using


Laplace Transform of a given signal.

OPERATOR: MATLAB Software.

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

SSIT Dept. of
ECE
BS LAB 75

OBSERVATIONS:

Laplace Transform

Laplace Transform of input signal

Y= 1/(s+2)

Inverse Laplace Transform of input signal

Z=1/exp(2*t)

SSIT Dept. of
ECE
BS LAB 76

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

z=ilaplace(y);

disp('Inverse Laplace Transform of input signal');

RESULT:

SSIT Dept. of
ECE
BS LAB 77

SSIT Dept. of
ECE
BS LAB 78

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 write a MATLAB program to locating the zeros and poles and
plotting the pole zero maps in s-plane and z-plane for the given transfer
function.

OPERATOR: MATLAB Software.

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:
 The value(s) for z where the numerator of the transfer function
equals zero
 The complex frequencies that make the overall gain of the filter
transfer function zero.
Poles:

SSIT Dept. of
ECE
BS LAB 79

 The value(s) for z where the denominator of the transfer function


equals zero
 The complex frequencies that make the overall gain of the filter
transfer function infinite.

SSIT Dept. of
ECE
BS LAB 80

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)

SSIT Dept. of
ECE
BS LAB 81

MODEL GRAPHS:

locating poles of zero on s-plane


enter numerator coefficient[1 2 3]
enter denominator coefficient[7 6 5]

locating poles &zeros on z-plane


enter numerator coefficient[1 2 3]
enter denominator coefficient[1 2 3]

SSIT Dept. of
ECE
BS LAB 82

OBSERVATIONS:

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

RESULT:

SSIT Dept. of
ECE
BS LAB 83

SSIT Dept. of
ECE
BS LAB 84

13. GENERATION OF GAUSSIAN NOISE


AIM: To Write a MATLAB Program to generate Gaussian Noise and to compute
its Probability Distribution Function.
OPERATOR: MATLAB Software.

THEORY:

The Gaussian (or normal) distribution is a continuous probability distribution that


has a bell-shaped probability density function, known as the Gaussian function or
informally the bell curve.
The parameter μ is the mean or expectation (location of the peak) and σ 2 is the
variance. σ is known as the standard deviation. The distribution with μ = 0 and
σ 2 = 1 is called the standard normal distribution or the unit normal distribution. A
normal distribution is often used as a first approximation to describe real-valued
random variables that cluster around a single mean value.
Probability density function:
The probability density function (pdf) of a random variable describes the relative
frequencies of different values for that random variable. The pdf of the normal
distribution is given by the formula,
fx(x,µ,2)=(1/(√(2πft) 2)))*exp(-(x-µ)2/(22).
Cumulative distribution function:
The cumulative distribution function (CDF) describes probability of a random
variable falling in the interval [−∞, x].
The CDF of the standard normal distribution is denoted with the capital Greek
letter Φ (phi), and can be computed as an integral of the probability density
function:
Φ(x) =(1/(√(2πft))))*∫ exp –t2/2 dt with in the interval -∞ to x

SSIT Dept. of
ECE
BS LAB 85

MODEL WAVEFORMS:

OBSERVATIONS:

SSIT Dept. of
ECE
BS LAB 86

PROGRAM:

clc
Clear all;
Close all;
% Defining the range for the Random variable
dx=0.01; %delta x
x=-3:dx:3;
[m,n]=size(x);% Defining the parameters of the pdf
mu_x=0; %
mu_x=input('Enter the value of mean');
sig_x=0.1; %
sig_x=input('Enter the value of varience');
%Computing the probability density function
px1=[];a=1/(sqrt(2*pi)*sig_x);
for j=1:n
px1(j)=a*exp([-((x(j)-mu_x)/sig_x)^2]/2);
end
% Computing the cumulative distribution function
cum_Px(1)=0;
for j=2:n
cum_Px(j)=cum_Px(j-1)+dx*px1(j);
end
% Plotting the results
figure(1)
plot(x,px1);
grid
axis([-3 3 0 1]);
title(['Gaussian pdf for mu_x=0 and sigma_x=', num2str(sig_x)]);
xlabel('--> x')
ylabel('--> pdf')
figure(2)
plot(x,cum_Px);
grid
axis([-3 3 0 1]);
title(['Gaussian Probability Distribution Function for mu_x=0 and sigma_x=',
num2str(sig_x)]);
title('\ite^{\omega\tau} = cos(\omega\tau) + isin(\omega\tau)')
xlabel('--> x')
ylabel('--> PDF')

SSIT Dept. of
ECE
BS LAB 87

RESULT:

SSIT Dept. of
ECE
BS LAB 88

14. VERIFICATION OF SAMPLING THEOREM


AIM: To Write a MATLAB Program to Verify the Sampling Theorem.

OPERATOR: MATLAB Software.

THEORY:

The signals we use in the real world, such as our voices, are called "analog"
signals. To process these signals in computers, we need to convert the signals
to "digital" form. While an analog signal is continuous in both time and
amplitude, a digital signal is discrete in both time and amplitude. To convert a
signal from continuous time to discrete time, a process called sampling is used.
The value of the signal is measured at certain intervals in time. Each
measurement is referred to as a sample.
If the signal contains high frequency components, we will need to sample
at a higher rate to avoid losing information that is in the signal. In general, to
preserve the full information in the signal, it is necessary to sample at twice the
maximum frequency of the signal. This is known as the Nyquist rate. The
Sampling Theorem states that a signal can be exactly reproduced if it is sampled
at a frequency F, where F is greater than twice the maximum frequency in the
signal.
When the signal is converted back into a continuous time signal, it will exhibit a
phenomenon called “Aliasing”. Aliasing is the presence of unwanted
components in the reconstructed signal. These components were not present
when the original signal was sampled. In addition, some of the frequencies in
the original signal may be lost in the reconstructed signal. Aliasing occurs
because signal frequencies can overlap if the sampling frequency is too low.
Frequencies "fold" around half the sampling frequency - which is why this
frequency is often referred to as the folding frequency.
A band limited signal x(t) with X(jΩ)=0 for |Ω|>Ωm is uniquely determined)=0 for |Ω|>Ωm is uniquely determinedΩ)=0 for |Ω|>Ωm is uniquely determined|Ω|>Ωm is uniquely determined>Ω)=0 for |Ω|>Ωm is uniquely determinedm is uniquely determined
from its samples x(nT),if the sampling frequency fs >= 2fm, i.e., sampling
frequency must be at least twice highest frequency present in the signal.

SSIT Dept. of
ECE
BS LAB 89

Nyquist rate: the minimum rate at which the signal can be sampled and still be
reconstructed from its samples is called nyquist rate. it is always equal to 2fm
where fm is the maximum frequency component present in the signal.
A signal sampled at greater than the nyquist rate is said to be “over
sampled”, a signal sampled at less than the nyquist rate is said to be “under
sampled”.

MODEL WAVEFORMS:

OBSERVATIONS:

SSIT Dept. of
ECE
BS LAB 90

PROGRAM:
close all;
clear all;
t=-10:0.01:10;
T=8;
fm=1/T;
x=cos(2*pi*fm*t);
fs1=1.2*fm;
fs2=2*fm;
fs3=8*fm;
n1=-4:1:4;
xn1=cos(2*pi*n1*fm/fs1);
subplot(221)
plot(t,x);
xlabel('time in seconds');
ylabel('x(t)');
title('continous time signal');
subplot(222)
stem(n1,xn1);
hold on;
plot(n1,xn1);
xlabel('n');
ylabel('x(n)');
title('discrete time signal with fs<2fm');
n2=-5:1:5;
xn2=cos(2*pi*n2*fm/fs2);
subplot(223)
stem(n2,xn2);
hold on;
plot(n2,xn2);
xlabel('n');
ylabel('x(n)');
title('discrete time signal with fs=2fm');
n3=-20:1:20;
xn3=cos(2*pi*n3*fm/fs3);
subplot(224)
stem(n3,xn3);

SSIT Dept. of
ECE
BS LAB 91

hold on;
plot(n3,xn3);
xlabel('n');
ylabel('x(n)');
title('discrete time signal with fs>2fm');

RESULT:

SSIT Dept. of
ECE
BS LAB 92

15. REMOVAL OF NOISE BY AUTO CORRELATION/CROSS


CORRELATION

AIM: To write a MATLAB program for removal of noise by auto correlation/cross


correlation.

OPERATOR: MATLAB Software.

THEORY:

Detection of a periodic signal masked by random noise is of greater


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

for all T

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)

SSIT Dept. of
ECE
BS LAB 93

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

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

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 a Qnn(T) becomes
small for

SSIT Dept. of
ECE
BS LAB 94

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 frequency as that of S(t)

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

SSIT Dept. of
ECE
BS LAB 95

MODEL WAVEFORMS:

AUTO CORRELATION

OBSERVATIONS:

SSIT Dept. of
ECE
BS LAB 96

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

SSIT Dept. of
ECE
BS LAB 97

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

OBSERVATIONS:

SSIT Dept. of
ECE
BS LAB 98

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

SSIT Dept. of
ECE
BS LAB 99

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

RESULT:

SSIT Dept. of
ECE
BS LAB
100

16. EXTRACTION OF PERIODIC SIGNAL MASKED BY NOISE


USING CORRELATION

AIM: To write a MATLAB program to generate a periodic sequence,


corrupt it with zero mean White noise and extract the sequence using
periodic circular cross correlation.

OPERATOR: MATLAB Software.

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

SSIT Dept. of
ECE
BS LAB
101

spectrum of the input times the power transfer function. This corollary is
used in the parametric method for power spectrum estimation.

MODEL WAVEFORMS:

SSIT Dept. of
ECE
BS LAB
102

OBSERVATIONS:

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

SSIT Dept. of
ECE
BS LAB
103

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

RESULT:

SSIT Dept. of
ECE
BS LAB
104

17.VERIFICATION OF WIENER‒KHINCHIN RELATION

AIM: To write a MATLAB program to Verify the wiener‒khinchine relation.

OPERATOR: MATLAB Software.

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

SSIT Dept. of
ECE
BS LAB
105

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 real valued.

Discrete case:

Where

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

MODEL WAVEFORMS:

Wiener‒khinchine relation

SSIT Dept. of
ECE
BS LAB
106

OBSERVATIONS:

PROGRAM:-

SSIT Dept. of
ECE
BS LAB
107

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

RESULT:

SSIT Dept. of
ECE

Vous aimerez peut-être aussi