0% found this document useful (0 votes)
82 views190 pages

II.b.tech-i-sem Bs Lab M

The document is a laboratory manual for the Basic Simulation Lab course in the Electronics and Communication Engineering department. It contains 16 experiments on topics such as operations on matrices, generation of signals and sequences, operations on signals, Fourier transforms, Laplace transforms, filtering, sampling theory, and random processes. The manual provides the aim, theory, MATLAB code and expected output for each experiment to help students learn and demonstrate various signal processing concepts.

Uploaded by

shylu Shyny
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views190 pages

II.b.tech-i-sem Bs Lab M

The document is a laboratory manual for the Basic Simulation Lab course in the Electronics and Communication Engineering department. It contains 16 experiments on topics such as operations on matrices, generation of signals and sequences, operations on signals, Fourier transforms, Laplace transforms, filtering, sampling theory, and random processes. The manual provides the aim, theory, MATLAB code and expected output for each experiment to help students learn and demonstrate various signal processing concepts.

Uploaded by

shylu Shyny
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 190

Department of ECE BS Lab Manual

JYOTHISHMATHI INSTITUTE OF TECHNOLOGICAL SSCIENCES


Ramakrishna Colony, Karimnagar

LABORATORY MANUAL
(BASIC SIMULATION LAB)

II B. Tech I-SEM

Department of
ELECTRONICS & COMMUNICATION ENGINEERING
1
Department of ECE BS Lab Manual

CONTENTS

S.No Experiment Name Page No.


LIST OF EXPERIMENTS:

1. Basic operations on matrices. 3


2. Generation on various signals and Sequences 8
(periodic and aperiodic), such as unit impulse, unit step,
square, sawtooth, triangular, sinusoidal, ramp, sinc.
3. Operations on signals and sequences such as addition, 17
multiplication, scaling, shifting, folding, computation of
energy and average power.
4. Finding the even and odd parts of signal/sequence 30
and real and imaginary part of signal.
5. Convolution between signals and sequences. 36
6. Auto correlation and cross correlation between 41
signals and sequences.
7. Verification of linearity and time invariance 46
properties of a given continuous /discrete system.
8. Computation of unit sample, unit step and sinusoidal 54
response of the given LTI system and verifying its
physical Realizability and stability properties.
9. Gibbs phenomenon. 59
10. Finding the Fourier transform of a given 61
signal and plotting its magnitude and phase spectrum.
11. Waveform synthesis using Laplace Transform. 64
12. Locating the zeros and poles and plotting the
pole zero maps in s-plane and z-plane for the given 69
transfer function.
13. Generation of Gaussian Noise(real and complex), 74
computation of its mean, M.S. Value and its skew,
kurtosis, and PSD, probability distribution function.
14. Sampling theorem verification. 79
15. Removal of noise by auto correlation/cross correlation. 85
16. Extraction of periodic signal masked by noise 89
using correlation.
17. Verification of Weiner-Khinchine relations. 93
18. Checking a random process for stationarity in wide sense.
2
Department of ECE BS Lab Manual

Experiment No-1
OPERATIONS ON MATRICES

AIM: Generate a matrix and perform basic operation on matrices


using Matlab software.

Software Required:
Matlab software 7.0 and above.

Theory:

MATLAB treats all variables as matrices.


Vectors are special forms of matrices and contain only one row or one
column. Where as scalars are special forms of matrices and contain only one
row and one column.
A matrix with one row is called row vector and a matrix with single
column is called column vector.
Extracting Sub matrix:
Sub_matrix=matrix(r1:r2,c1:c2)
Col_vector=matrix( : , column number)
row_vector=matrix( : , row number)

Program:

% Creating a column vector

>> colvec=[13;20;5]

colvec =

13
20
5
% Creating a row vector
>> rowvec=[1 2 3]
3
Department of ECE BS Lab Manual

rowvec =

1 2 3
% Creating a matrix
>> matrix=[1 2 3;4 6 9;2 6 9]

matrix =

1 2 3
4 6 9
2 6 9
% Extracting sub matrix from matrix
>> sub_matrix=matrix(2:3,2:3)

sub_matrix =

6 9
6 9
% extracting column vector from matrix
>> col_vector=matrix(:,2)

col_vector =

2
6
6
% extracting row vector from matrix
>> row_vector=matrix(3,:)

row_vector =

2 6 9
4
Department of ECE BS Lab Manual

% creation of two matrices a and b

>> a=[2 4 -1;-2 1 9;-1 -1 0]

a=

2 4 -1
-2 1 9
-1 -1 0

>> b=[0 2 3;1 0 2;1 4 6]

b=

0 2 3
1 0 2
1 4 6

% matrix multiplication
>> x1=a*b

x1 =

3 0 8
10 32 50
-1 -2 -5

% vector multiplication
>> x2=a.*b

x2 =

0 8 -3
-2 0 18
-1 -4 0

% matrix addition
>> x3=a+b
5
Department of ECE BS Lab Manual

x3 =

2 6 2
-1 1 11
0 3 6
% matrix subtraction

>> x4=a-b

x4 =

2 2 -4
-3 1 7
-2 -5 -6

% matrix division

>> x5=a/b

x5 =

-9.0000 -3.5000 5.5000


12.0000 3.7500 -5.7500
3.0000 0.7500 -1.7500

% vector division

>> x6=a./b
Warning: Divide by zero.

x6 =

Inf 2.0000 -0.3333


-2.0000 Inf 4.5000
-1.0000 -0.2500 0

% inverse of matrix
a >> x7=inv(a)
6
Department of ECE BS Lab Manual

x7 =

-0.4286 -0.0476 -1.7619


0.4286 0.0476 0.7619 -
0.1429 0.0952 -0.4762

% transpose of matrix a

>> x8=a'

x8 =

2 -2 -1
4 1 -1
-1 9 0

% cube of matrix a( power of the


matrix) >> x9=a^3

x9 =

-66 -33 120 -


9 -87 -129
18 3 -45

% vector power 3 of matrix


a >> x10=a.^3

x10 =

8 64 -1
-8 1 729
-1 -1 0

RESULT: Matrix operations are performed using Matlab software.


7
Department of ECE BS Lab Manual

Experiment No.-2
GENERATION OF SIGNALS AND SEQUENCES
AIM: Generate various signals and sequences (periodic and aperiodic) (
ramp,Impulse,unit step,square,sawtooth,triangular sinusoidal and sinc) using
Matlab software.

Software Required:
Matlab software 7.0 and above.

Theory: If the amplitude of the signal is defined at every instant of time


then it is called continuous signal. If the amplitude of the signal is defined at
only at some instants of time then it is called discrete signal.

If the signal repeats itself at regular intervals then it is called periodic signal.
Otherwise they are called aperiodic signals.

EX: ramp,Impulse,unit step, sinc- Aperiodic signals


square,sawtooth,triangular sinusoidal – periodic signals.

Ramp sinal:
r(t)= t when t>=0

Unit impulse signal:


Y(t)= 1 only when t=0
=0 other wise

Unit step signal:


u(t)= 1 only when t>=0
=0 other wise
Sinc signal:
G(x)=(sinx)/x

PROGRAM:

%generation of rampsignal
clc;
clear all;
close all;
8
Department of ECE BS Lab Manual

fs=500;
t=0:1/fs:0.1;
y1=t;
subplot(2,2,1);
plot(t,y1);
xlabel('time');
ylabel('amplitude');
title('ramp signal');
%generation of ramp
sequence subplot(2,2,2);
stem(y1);
xlabel('n');
ylabel('amplitude');
title('ramp sequence');

%generation of impulse signal


y2=(t==0);
subplot(2,2,3);
plot(t,y2);
axis([-1 1 0 1])
xlabel('time');
ylabel('amplitude');
title('impulse signal');
%generation of impulse sequence
subplot(2,2,4);
stem(y2);
xlabel('n');
ylabel('amplitude');
title('impulse sequence');

%generation of unit stepsignal


n=-10:1:10;
y3=(n>=0);
figure;
subplot(2,2,1);
plot(n,y3);
xlabel('time');
ylabel('amplitude');
title('unit step signal');
%generation of unit step sequence
9
Department of ECE BS Lab Manual

subplot(2,2,2);
stem(n,y3);
xlabel('n');
ylabel('amplitude');
title('unit step sequence');

%generation of square wave signal


y4=square(2*pi*50*t);
subplot(2,2,3);
plot(t,y4);
axis([0 0.1 -2 2]);
xlabel('time');
ylabel('amplitude');
title('square wave signal');
%generation of square wave sequence
subplot(2,2,4);
stem(y4);
xlabel('n');
ylabel('amplitude');
title('square wave sequence');

%generation of sawtooth signal


y5=sawtooth(2*pi*50*t);
figure;
subplot(2,2,1);
plot(t,y5);
axis([0 0.1 -22]);
xlabel('time');
ylabel('amplitude');
title('sawtooth wave signal');
%generation of sawtooth sequence
subplot(2,2,2);
stem(y5);
xlabel('n');
ylabel('amplitude');
title('sawtooth wave sequence');

%generation of triangular wave signal


y6=sawtooth(2*pi*50*t,.5);
subplot(2,2,3);
10
Department of ECE BS Lab Manual

plot(t,y6);;
axis([0 0.1 -2 2]);
xlabel('time');
ylabel('amplitude');
title(' triangular wave signal');
%generation of triangular wave sequence
subplot(2,2,4);
stem(y6);
xlabel('n');
ylabel('amplitude');
title('triangular wave sequence');

%generation of sinsoidal wavesignal


y7=sin(2*pi*50*t);
figure;
subplot(2,2,1);
plot(t,y7);
axis([0 0.1 -2 2]);
xlabel('time');
ylabel('amplitude');
title(' sinsoidal wave signal');
%generation of sin wave sequence
subplot(2,2,2);
stem(y7);
xlabel('n');
ylabel('amplitude');
title('sin wave sequence');

%generation of sinc signal


t1=linspace(-5,5);
y8=sinc(t1);
subplot(2,2,3);
plot(t1,y8);
xlabel('time');
ylabel('amplitude');
title(' sinc signal');
%generation of sinc sequence
subplot(2,2,4);
stem(y8);
11
Department of ECE BS Lab Manual

xlabel('n');
ylabel('amplitude');
title('sinc sequence');

Result: Various signals & sequences generated using Matlab software.


12
Department of ECE BS Lab Manual

output:
13
Department of ECE BS Lab Manual
14
Department of ECE BS Lab Manual
15
Department of ECE BS Lab Manual
16
Department of ECE BS Lab Manual

Experiment No. -3
BASIC OPERATIONS ON SIGNALS AND SEQUENCES

AIM: perform the operations on signals and sequences such as addition ,


multiplication , scaling . shifting , folding and also compute energy and power.

Software Required:
Matlab software 7.0 and above
.
Theory:

Signal Addition

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

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

Multiplication :
Multiplication of two signals can be obtained by multiplying their values at
every instants . z (t) = x (t) y (t)

Time reversal/Folding:
Time reversal of a signal x(t) can be obtained by folding the signal about
t=0. Y(t)=y(-t)

Signal Amplification/Scaling : Y(n)=ax(n) if a < 1 attnuation


a >1 amplification
17
Department of ECE BS Lab Manual

Time shifting: The time shifting of x(n) obtained by delay or advance the
signal in time by using y(n)=x(n+k)

If k is a positive number, y(n) shifted to the right i e the shifting delays the
signal
If k is a negative number, y(n ) it gets shifted left. Signal Shifting advances
the signal

Energy:
E=sum(abs(X).^2)

Average power:
P= (sum(abs(X).^2))/ length(x)

Program:

clc;
clear all;
close all;
t=0:.01:1;
% generating two input
signals x1=sin(2*pi*4*t);
x2=sin(2*pi*8*t);
subplot(2,2,1);
plot(t,x1);
xlabel('time');
ylabel('amplitude');
title('signal1:sine wave of frequency4Hz');
subplot(2,2,2);
plot(t,x2);
xlabel('time');
18
Department of ECE BS Lab Manual
ylabel('amplitude');
title('signal2:sine wave of frequency 8Hz');

% addition of
signals
y1=x1+x2;
subplot(2,2,3);
plot(t,y1);
xlabel('time');
ylabel('amplitude');
title('resultant signal:signal1+signal2');

% multiplication of
signals y2=x1.*x2;
subplot(2,2,4);
plot(t,y2);
xlabel('time');
ylabel('amplitude');
title('resultant signal:dot product of signal1 and signal2');

% scaling of a signal1
A=10;
y3=A*x1;
figure;
subplot(2,2,1);
plot(t,x1);
xlabel('time');
ylabel('amplitude');
title('sine wave of frequency
4Hz') subplot(2,2,2);
plot(t,y3);
xlabel('time');
ylabel('amplitude');
title('amplified input signal1 ');

% folding of a signal1
l1=length(x1);
nx=0:l1-1;
subplot(2,2,3);
plot(nx,x1);
xlabel('nx');
19
Department of ECE BS Lab Manual

ylabel('amplitude');
title('sine wave of frequency4Hz')
y4=fliplr(x1);
nf=-fliplr(nx);
subplot(2,2,4);
plot(nf,y4);
xlabel('nf');
ylabel('amplitude');
title('folded signal');

%shifting of asignal
figure;
t1=0:.01:pi;
x3=8*sin(2*pi*2*t1);
subplot(3,1,1);
plot(t1,x3);
xlabel('time t1');
ylabel('amplitude');
title('sine wave of frequency2Hz');
subplot(3,1,2);
plot(t1+10,x3);
xlabel('t1+10');
ylabel('amplitude');
title('right shifted
signal'); subplot(3,1,3);
plot(t1-10,x3);
xlabel('t1-10');
ylabel('amplitude');
title('left shifted signal');

%operations on sequences
n1=1:1:9;
s1=[1 2 3 0 5 8 0 2 4];
figure; subplot(2,2,1);
stem(n1,s1);
xlabel('n1');
ylabel('amplitude');
title('input sequence1');
20
Department of ECE BS Lab Manual

n2=-2:1:6;
s2=[1 1 2 4 6 0 5 3 6];
subplot(2,2,2);
stem(n2,s2);
xlabel('n2');
ylabel('amplitude');
title('input sequence2');

% addition of
sequences s3=s1+s2;
subplot(2,2,3);
stem(n1,s3);
xlabel('n1');
ylabel('amplitude');
title('sum of two sequences');

% multiplication of sequences
s4=s1.*s2;
subplot(2,2,4);
stem(n1,s4);
xlabel('n1');
ylabel('amplitude');
title('product of two sequences');

% scaling of a sequence
figure;
subplot(2,2,1);
stem(n1,s1);
xlabel('n1');
ylabel('amplitude');
title('input sequence1');
s5=4*s1; subplot(2,2,2);
stem(n1,s5);
xlabel('n1');
ylabel('amplitude');
title('scaled sequence1');

% shifting of a sequence
subplot(2,2,3);
21
Department of ECE BS Lab Manual

stem(n1-2,s1);
xlabel('n1');
ylabel('amplitude');
title('left shifted
sequence1');
subplot(2,2,4);
stem(n1+2,s1);
xlabel('n1');
ylabel('amplitude');
title('right shifted sequence1');

% folding of a
sequence l2=length(s1);
nx1=0:l2-1;
figure;
subplot(2,1,1);
stem(nx1,s1);
xlabel('nx1');
ylabel('amplitude');
title('input sequence1');
s6=fliplr(s1);
nf2=-fliplr(nx1);
subplot(2,1,2);
stem(nf2,s6);
xlabel('nf2');
ylabel('amplitude');
title('folded sequence1');

% program for energy of a sequence

z1=input('enter the input sequence');


e1=sum(abs(z1).^2)
e1

% program for energy of a signal


t=0:pi:10*pi;
z2=cos(2*pi*50*t).^2;
e2=sum(abs(z2).^2);
e2
% program for power of a saequence
22
Department of ECE BS Lab Manual

p1= (sum(abs(z1).^2))/length(z1);
p1

% program for power of a signal


p2=(sum(abs(z2).^2))/length(z2);
p2

OUTPUT:

enter the input sequence [1 3 5 6]

e1 =

71

e2 =

4.0388

p1 =

17.7500

p2 =

0.3672

Result: Various operations on signals and sequences are performed.


23
Department of ECE BS Lab Manual
24
Department of ECE BS Lab Manual
25
Department of ECE BS Lab Manual
26
Department of ECE BS Lab Manual
27
Department of ECE BS Lab Manual
28
Department of ECE BS Lab Manual
29
Department of ECE BS Lab Manual

Experiment No.-4
EVEN AND ODD PARTS OF SIGNAL AND SEQUENCE
& REAL AND IMAGINARY PARTS
AIM: Finding even and odd part of the signal and sequence and also find
real and imaginary parts of signal.

Software Required:
Matlab software 7.0 and above.

Theory:

EVEN AND ODD PART OF A SIGNAL:


Any signal x(t) can be expressed as sum of even and odd components I e
X(t)=xe(t)+xo(t)

Program:
Clc;
close all;
clear all;
% Even and odd parts of a signal
t=0:.005:4*pi;
x=sin(t)+cos(t); % x(t)=sint(t)+cos(t)
subplot(2,2,1)
plot(t,x)
xlabel('t');
ylabel('amplitude')
title('input signal') y=sin(-
t)+cos( -t) % y=x(-t)
subplot(2,2,2)
plot(t,y)

30
Department of ECE
subplot(
2,2,1);
xlabel('t');
ylabel('amplitude')
title('input signal with t=-
t') z=x+y
subplot(2,2,3)
plot(t,z/2)
xlabel('t');
ylabel('amplitude') title('even
part of the signal') p=x-y

subplot(2,2,4)
plot(t,p/2)
xlabel('t');
ylabel('amplitude'); title('odd
part of the signal');
% Even and odd parts of a sequence
z=[0,2+j*4,-3+j*2,5-j*1,-2-j*4,-j*3,0];
n=-3:3

% plotting real and imginary parts of the


sequence figure;
subplot( 2,1,1);
stem(n,real(z));
xlabel('n');
ylabel('amplitude');
title('real part of the complex sequence');
subplot( 2,1,2);
stem(n,imag(z));
xlabel('n');
ylabel('amplitude');
title('imaginary part of the complex sequence');

% complex conjugate of a signal


zc=conj(z);
zc_folded= fliplr(zc);
zc_even=.5*(z+zc_folded);
zc_odd=.5*(z-zc_folded);
% plotting even and odd parts of the
sequence figure;
BS Lab Manual
Department of ECE BS Lab Manual

stem(n,real(zc_even));
xlabel('n');
ylabel('amplitude');
title('real part of the even sequence');
subplot( 2,2,2);
stem(n,imag(zc_even));
xlabel('n');
ylabel('amplitude');
title('imaginary part of the even sequence');
subplot( 2,2,3);
stem(n,real(zc_odd));
xlabel('n');
ylabel('amplitude');
title('real part of the odd
sequence'); subplot( 2,2,4);
stem(n,imag(zc_odd));
xlabel('n');
ylabel('amplitude');
title('imaginary part of the odd sequence');

RESULT: Even and odd part of the signal and sequence is computed.
32
Department of ECE BS Lab Manual

Output:
33
Department of ECE BS Lab Manual
34
Department of ECE BS Lab Manual
35
Department of ECE BS Lab Manual

Experiment No.-5
CONVOLUTION BETWEEN SIGNALS& SEQUENCES

Aim: Write the program for convolution between two signals and also
between two sequences.

Software Required:
Matlab software 7.0 and above.

Theory:

If x(n)=h(n) [ impulse ) then output y(n) is known as impulse response of


the system.
x(n)=δ(n)

y(n)=T[x(n)]=h(n) similarly δ (n-k)= h(n-k)


x(n) cab represented as weighted sum of impulses such as

y(n)=T[x(n)]

T[δ(n)=h(n) then T[ δ (n-k)] = h(n-k)

Thus output of LTI system is geven by weighted


sum of time-shifted impulse responses ---------------- Linear Convolution
equation
36
Department of ECE BS Lab Manual

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:

Program:

clc;
close all;
clear all;
%program for convolution of two
sequences x=input('enter input sequence');
h=input('enter impulse response');
y=conv(x,h);
subplot(3,1,1);
stem(x);
xlabel('n');
ylabel('x(n)');
title('input signal')
subplot(3,1,2);
stem(h);
xlabel('n');
ylabel('h(n)');
title('impulse response')
subplot(3,1,3); stem(y);

xlabel('n');
ylabel('y(n)'); title('linear
convolution')
disp('The resultant signal is');
disp(y)
37
Department of ECE BS Lab Manual

%program for signal


convolution t=0:0.1:10;
x1=sin(2*pi*t);
h1=cos(2*pi*t);
y1=conv(x1,h1);
figure;
subplot(3,1,1);
plot(t,x1);
xlabel('t');
ylabel('x(t)');
title('input signal')
subplot(3,1,2);
plot(t,h1);
xlabel('t');
ylabel('h(t)');
title('impulse response')
subplot(3,1,3);
plot(y1);
xlabel('n');
ylabel('y(n)'); title('linear
convolution');

RESULT: convolution between signals and sequences is computed.

Output:

enter input sequence[2 4 6 8]


enter impulse response[1 3 9
6] The resultant signal is
2 10 36 74 102 108 48
38
Department of ECE BS Lab Manual
39
Department of ECE BS Lab Manual
40
Department of ECE BS Lab Manual

Experiment No. -6
AUTO CORRELATION AND CROSS CORRELATION

AIM: Write the program to compute Auto correlation and Cross correlation
between signals and sequences.

Software Required:
Mat lab software 7.0 and above

Theory:
Correlations of sequences:

It is a measure of the degree to which two sequences are similar. Given


two real-valued sequences x(n) and y(n) of finite energy,

Convolution involves the following operations.

1. Shifting
2. Multiplication
3. Addition

These operations can be represented by a Mathematical Expression as


follows:

Cross correlation +∞

rx, y (l) = ∑x(n) y(n −l)


n=−∞

The index l is called the shift or lag parameter

Autocorrelation
+∞

rx,x (l) = ∑x(n)x(n −l)


n=−∞
41
Department of ECE
f
i
Program: g
u
r
clc;
e
close all;
;
clear all;
% two input sequences x=input('enter
input sequence'); h=input('enter the
impulse suquence'); subplot(2,2,1);

stem(x);
xlabel('n');
ylabel('x(n)');
title('input sequence');
subplot(2,2,2);
stem(h);
xlabel('n');
ylabel('h(n)');
title('impulse signal');
% cross correlation between two sequences
y=xcorr(x,h);
subplot(2,2,3);
stem(y);
xlabel('n');
ylabel('y(n)');
title(' cross correlation between two sequences ');
% auto correlation of input sequence
z=xcorr(x,x);
subplot(2,2,4);
stem(z);
xlabel('n');
ylabel('z(n)');
title('auto correlation of input sequence');

% cross correlation between two signals


% generating two input signals
t=0:0.2:10;
x1=3*exp( -
2*t); h1=exp(t);
BS Lab Manual
Department of ECE BS Lab Manual

subplot(2,2,1);
plot(t,x1);
xlabel('t');
ylabel('x1(t)');
title('input signal');
subplot(2,2,2);
plot(t,h1);
xlabel('t');
ylabel('h1(t)');
title('impulse signal');
% cross correlation
subplot(2,2,3);
z1=xcorr(x1,h1);
plot(z1); xlabel('t');
ylabel('z1(t)');

title('cross correlation ');


% auto correlation
subplot(2,2,4);
z2=xcorr(x1,x1);
plot(z2);
xlabel('t');
ylabel('z2(t)');
title('auto correlation ');

Result: Auto correlation and Cross correlation between signals and


sequences is computed.
43
Department of ECE BS Lab Manual

Output: enter input sequence [1 2 5 7]


Enter the impulse sequence [2 6 0 5 3]
44
Department of ECE BS Lab Manual
45
Department of ECE BS Lab Manual

Experiment No. -7(a)


VERIFICATION OF LINEARITY OF A DISCRETE SYSTEM
AIM: Verify the Linearity of a given Discrete System.

Software Required:
Mat lab software 7.0 and above
Theory:

LINEARITY PROPERTY:
Any system is said to be linear if it satisfies the superposition principal.
superposition principal state that Response to a weighted sum of input
signal equal to the corresponding weighted sum of the outputs of the system
to each of the individual input signals.

X(n) -----------input signal


Y(n) --------- output signal

Y(n)=T[x(n)]

Y1(n)=T[X1(n)] : Y2(n)=T[X2(n)]

x3=[a X1(n)] +b [X2(n) ]

Y3(n)= T [x3(n)]

= T [a X1(n)] +b [X2(n) ] = a Y1(n)+ b [Y

Let a [Y1(n)]+ b [X2(n) ] =Z 3(n)


46
Department of ECE BS Lab Manual

Program:
clc;
clear all;
close all;
% entering two input sequences and impulse sequence
x1 = input (' type the samples of x1 ');
x2 = input (' type the samples of x2 ');
if(length(x1)~=length(x2))
disp('error: Lengths of x1 and x2 are
different'); return;
end;
h = input (' type the samples of h ');
% length of output sequence
N = length(x1) + length(h) -1;
disp('length of the output signal will be
'); disp(N);
% entering scaling factors
a1 = input (' The scale factor a1 is
'); a2 = input (' The scale factor a2
is '); x = a1 * x1 + a2 * x2;
% response of x and
x1 yo1 = conv(x,h);
y1 = conv(x1,h);
% scaled response of
x1 y1s = a1 * y1;
% response of x2
y2 = conv(x2,h);
% scaled response of
x2 y2s = a2 * y2;
yo2 = y1s + y2s;
disp ('Input signal x1 is '); disp(x1);
disp ('Input signal x2 is '); disp(x2);
disp ('Output Sequence yo1 is ');
disp(yo1); disp ('Output Sequence yo2 is');
disp(yo2); if ( yo1 == yo2 )
disp(' yo1 = yo2. Hence the LTI system is LINEAR ')
end;

Result: The Linearity of a given Discrete System is verified.


47
Department of ECE BS Lab Manual

Output:

Type the samples of x1 [1 5 6 7]


Type the samples of x2 [2 3 4 8]
Type the samples of h [2 6 5 4]
Length of the output signal will be
7

The scale factor a1 is 2


The scale factor a2 is 3
Input signal x1 is
1 5 6 7

Input signal x2 is
2348

Output Sequence yo1 is


16 86 202 347 424 286 152

Output Sequence yo2 is


16 86 202 347 424 286 152

yo1 = yo2. Hence the LTI system is LINEAR


48
Department of ECE BS Lab Manual

Experiment No. -7(b)


VERIFICATION OF TIME INVARIANCE OF A DISCRETE
SYSTEM

AIM: Verify the Time Invariance of a given Discrete System.

Software Required:
Mat lab software 7.0 and above
Theory:

TIME INVARIENT SYSTEMS(TI):

A system is called time invariant if its input – output characteristics do


not change with time

X(t)---- input : Y(t) ---output


X(t-T) ----- delay input by T seconds : Y(t-T) ------ Delayed output by T
seconds

Program:

clc; clear
all; close
all;

% entering two input sequences


x = input( ' Type the samples of signal x(n) ' );
h = input( ' Type the samples of signal h(n) ' );
% original response
y = conv(x,h);
disp( ' Enter a POSITIVE number for delay ' );
d = input( ' Desired delay of the signal is ' );

% delayed input
xd = [zeros(1,d), x];
nxd = 0 : length(xd)-1;
49
Department of ECE BS Lab Manual

%delayed output
yd = conv(xd,h);
nyd = 0:length(yd)-1;
disp(' Original Input Signal x(n) is
'); disp(x);
disp(' Delayed Input Signal xd(n) is
'); disp(xd);
disp(' Original Output Signal y(n) is
'); disp(y);
disp(' Delayed Output Signal yd(n) is ');
disp(yd);
xp = [x , zeros(1,d)];
subplot(2,1,1);
stem(nxd,xp);
grid;
xlabel( ' Time Index n ' );
ylabel( ' x(n) ' );
title( ' Original Input Signal x(n) ' );
subplot(2,1,2);
stem(nxd,xd);
grid;
xlabel( ' Time Index n ' );
ylabel( ' xd(n) ' );
title( ' Delayed Input Signal xd(n) ' );
yp = [y zeros(1,d)];
figure;
subplot(2,1,1);
stem(nyd,yp);
grid;
xlabel( ' Time Index n ' );
ylabel( ' y(n) ' );
title( ' Original Output Signal y(n) '
); subplot(2,1,2);
stem(nyd,yd);
grid;
xlabel( ' Time Index n ' );
ylabel( ' yd(n) ' );
title( ' Delayed Output Signal yd(n) ' );
50
Department of ECE BS Lab Manual

Result: The Time Invariance of a given Discrete System is verified.

Output:

Type the samples of signal x(n) [2 3 4 6]


Type the samples of signal h(n) [1 2 3 8]
Enter a POSITIVE number for delay
Desired delay of the signal is 5
Original Input Signal x(n) is
2 3 4 6

Delayed Input Signal xd(n) is


0 0 0 0 0 2 3 4 6

Original Output Signal y(n) is


2 7 16 39 48 50 48

Delayed Output Signal yd(n) is


0 0 0 0 0 2 7 16 39 48 50 48
51
Department of ECE BS Lab Manual
52
Department of ECE BS Lab Manual
53
Department of ECE BS Lab Manual

Experiment No. -8
UNIT SAMPLE, UNIT STEP AND SINUSOIDAL RESPONSE OF
THE GIVEN LTI SYSTEM AND VERIFYING ITS STABILITY

AIM: Compute the Unit sample, unit step and sinusoidal response of
the given LTI system and verifying its stability

Software Required:
Mat lab software 7.0 and above

Theory:
A discrete time system performs an operation on an input signal based on
predefined criteria to produce a modified output signal. The input signal x(n)
is the system excitation, and y(n) is the system response. The transform
operation is shown as,

If the input to the system is unit impulse i.e. x(n) = δ(n) then the output
of the system is known as impulse response denoted by h(n) where,
h(n) = T[δ(n)]
we know that any arbitrary sequence x(n) can be represented as a weighted
sum of discrete impulses. Now the system response is given by,

For linear system (1) reduces to

%given difference equation y(n)-y(n-1)+.9y(n-2)=x(n);


54
Department of ECE BS Lab Manual

Program:

%given difference equation y(n)-y(n-1)+.9y(n-2)=x(n);


b=[1];
a=[1,-1,.9];
n =0:3:100;

%generating impulse signal


x1=(n==0);
%impulse response
h1=filter(b,a,x1);
subplot(3,1,1);
stem(n,h1);
xlabel('n');
ylabel('h(n)');
title('impulse response');

%generating step signal


x2=(n>0);
% step response
s=filter(b,a,x2);
subplot(3,1,2);
stem(n,s);
xlabel('n');
ylabel('s(n)')
title('step response');
55
Department of ECE BS Lab Manual

%generating sinusoidal signal


t=0:0.1:2*pi;
x3=sin(t);
% sinusoidal response
h2=filter(b,a,x3);
subplot(3,1,3);
stem(h2);
xlabel('n');
ylabel('h(n)');
title('sin response');

% verifing stability
figure; zplane(b,a);

Result: The Unit sample, unit step and sinusoidal response of the given
LTI system is computed and its stability verified.

Hence all the poles lie inside the unit circle, so system is stable.

Output:
56
Department of ECE BS Lab Manual
57
Department of ECE BS Lab Manual
58
Department of ECE BS Lab Manual

Experiment No-9
GIBBS PHENOMENON

AIM: Verify the Gibbs phenomenon.


Software Required:
Matlab software 7.0 and above.
Theory:
The Gibbs phenomenon, the Fourier series of a piecewise continuously
differentiable periodic function behaves at a jump discontinuity.The n the
approximated function shows amounts of ripples at the points of
discontinuity. This is known as the Gibbs Phenomina . 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.

Program:
clc; clear
all; close
all;
t=0:0.1 :( pi*8);
y=sin(t);
subplot(5,1,1);
plot(t,y);
xlabel('k');
ylabel('amplitude');
title('gibbs
phenomenon'); h=2;
%k=3;
for k=3:2:9
y=y+sin(k*t)/k; %fourier series of sin signal
subplot(5,1,h);
plot(t,y);
xlabel('k');
ylabel('amplitude');
h=h+1;
end
Result: Gibbs phenomenon is verified.
59
Department of ECE BS Lab Manual

Output:
60
Department of ECE BS Lab Manual

Experiment No-10

FINDING THE FOURIER TRANSFORM OF A GIVEN SIGNAL


AND PLOTTING ITS MAGNITUDE AND PHASE SPECTRUM

AIM: To find the Fourier Transform of a given signal and plotting


its magnitude and phase spectrum.

Software Required:
Matlab software 7.0 and above.

Theory:

Fourier Transform :

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
2πinx/T
e in the Fourier series of ƒ is given by
By definition Fourier Transform of signal f(t) is defined as

Iverse Fourier Transform of signal F(w) is defined as

Program:
clc; clear
all; close
all;
fs=1000;
N=1024; % length of fft sequence
t=[0:N-1]*(1/fs);
61
Department of ECE BS Lab Manual

% input signal
x=0.8*cos(2*pi*100*t);
subplot(3,1,1); plot(t,x);

axis([0 0.05 -1 1]);


grid;
xlabel('t');
ylabel('amplitude');
title('input signal');
% magnitude spectrum
x1=fft(x);
k=0:N-1;
Xmag=abs(x1);
subplot(3,1,2);
plot(k,Xmag);
grid; xlabel('t');

ylabel('amplitude');
title('magnitude of fft signal')
%phase spectrum
Xphase=angle(x1)*(180/pi);
subplot(3,1,3);
plot(k,Xphase);
grid;
xlabel('t');
ylabel('angle in degrees');
title('phase of fft signal');

Result: Magnitude and phase spectrum of FFT of a given signal is


plotted.
Output:
62
Department of ECE BS Lab Manual
63
Department of ECE BS Lab Manual

Experiment No-11(a)

LAPLACE TRANSFORMS & INVERSE LAPLACE TRANSFORMS

AIM: Finding the Laplace transform & Inverse Laplace transform of some
signals.

Software Required:
Matlab software 7.0 and above.

Theory:

Bilateral Laplace transforms:

The Laplace transform of a signal f(t) can be defined as follows:

Inverse Laplace transform

The inverse Laplace transform is given by the following formula :

Program:

clc; clear
all; close
all;
%representation of symbolic variables
syms f t w s;
%laplace transform of t
f=t;
z=laplace(f);
disp('the laplace transform of f = ');
disp(z);

64
Department of ECE

% laplace transform of sin signal


f1=sin(w*t);
f2=sin(w*(t-1));
v1=laplace(f1);
disp('the laplace transform of f1 = ');
disp(v1);
v2=laplace(f2);
disp('the laplace transform of f2 = ');
disp(v2);
simplify(v2)

%inverse laplace
transform y1=ilaplace(z);
disp('the inverse laplace transform of z =
'); disp(y1);

y2=ilaplace(v1);
disp('the inverse laplace transform of v1 =
'); disp(y2);

y3=ilaplace(v2);
disp('the inverse laplace transform of v2 = ');
disp(y3);

x1=11*s^3+52*s^2+86*s+72;
x2=4*s*(s+2)^2*(s+3);
x3=x1/x2;
y4=ilaplace(x3);
disp('the inverse laplace transform of x3 =
'); disp(y4);
BS Lab Manual
Department of ECE BS Lab Manual

Output:

the laplace transform of f = 1/s^2

the laplace transform of f1 = w/(s^2+w^2)

the laplace transform of f2 = cos(w)*w/(s^2+w^2)-


sin(w)*s/(s^2+w^2)

ans =

-(-cos(w)*w+sin(w)*s)/(s^2+w^2)

the inverse laplace transform of z = t

the inverse laplace transform of v1 = sin(w*t)

the inverse laplace transform of v2 = sin(w*t)*cos(w)-


cos(w*t)*sin(w)

the inverse laplace transform of x3 =


-5/2*t*exp(-2*t)+5/4*exp(-3*t)+3/2
66
Department of ECE BS Lab Manual

Experiment No-11(b)
WAVEFORM SYNTHESIS USING LAPLACE TRANSFORMS

AIM: Perform the waveform synthesis using Laplace transform of a given


signal.

Software Required:
Matlab software 7.0 and above.

Theory:
Consider the square wave of period ‘T’which can be represented with unit
step functions as
f(t)=u(t)-2u(t-T/2)+2u(t-T)-2u(t-3T/2)+………..

Program:
clc; clear
all; close
all; syms
s; T=1;

%representation of laplace transform


F1=1-exp(-T*s/2); F2=s*(1+exp(-
T*s/2));
F=F1/F2;
%inverse laplace
transform f=ilaplace(F);
disp('inverse laplace transform of
F='); disp(f);
%easy plot for 'f'
ezplot(f);
67
Department of ECE BS Lab Manual

Output:
68
Department of ECE BS Lab Manual

Experiment No-12
LOCATING POLES AND ZEROS IN S-PLANE & Z-PLANE

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

Software Required:
Matlab software 7.0 and above.

Theory:

Z-transforms

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)
69
Department of ECE BS Lab Manual

Example:

Program:
clc; clear
all; close
all;
%enter the numerator and denamenator cofficients in square brackets
num=input('enter the numerator cofficients');
den=input('enter the denamenator cofficients');
%find the transfer function using built-in function 'filt'
H=filt(num,den)
%find locations of
zeros z=zero(H);
disp('zeros are at ');
disp(z);
%find residues,pole locations and gain constant of
H(z) [r p k]=residuez(num,den);
disp('poles are at ');
disp(p);
%plot the pole zero map in z-plane
zplane(num,den);
title('pole-zero map of LTI system in z-plane');

% ploe-zero plot in s-plane


H1=tf(num,den) % find transfer function H(s)
[p1,z1]=pzmap(H1); % find the locations of poles and zeros
disp('poles ar at ');disp(p1);
disp('zeros ar at
');disp(z1); figure;
%plot the pole-zero map in s-
plane pzmap(H1);
title('pole-zero map of LTI system in s-plane');

Result : Pole-zero maps are plotted in s-plane and z-plane for the given
transfer function.

70
Department of ECE BS Lab Manual

Output:

enter the numerator cofficients[1 -1 4 3.5]


enter the denamenator cofficients[2 3 -2.5 6]

Transfer function:
1 - z^-1 + 4 z^-2 + 3.5 z^-3
------------------------------
2 + 3 z^-1 - 2.5 z^-2 + 6 z^-3

zeros are at 0.8402


+ 2.1065i 0.8402
- 2.1065i -0.6805

poles are at
-2.4874
0.4937 + 0.9810i
0.4937 - 0.9810i

Transfer function:
s^3 - s^2 + 4 s + 3.5
-------------------------
2 s^3 + 3 s^2 - 2.5 s + 6

poles ar at
-2.4874
0.4937 + 0.9810i
0.4937 - 0.9810i

zeros ar at
0.8402 + 2.1065i
0.8402 -
2.1065i -0.6805
71
Department of ECE BS Lab Manual
72
Department of ECE BS Lab Manual
73
Department of ECE BS Lab Manual

Experiment No-13
GENERATION OF GAUSSIAN NOISE

AIM: Write the program for generation of Gaussian noise and computation of
its mean, mean square value, skew, kurtosis and probability distribution
function.

Software Required:
Matlab software 7.0 and above.

Theory:

Program:

clc; clear
all; close
all;
%generates first set of 2000 samples of Gaussian distributed
random numbers
x1=randn(1,2000);
%generates second set of 2000 samples of Gaussian distributed
random numbers
x2=randn(1,2000);
%plot the joint distribution of both the sets using
dot. plot(x1,x2,'.');
title('scatter plot of gaussian distributed random numbers');
%generates two sets of 2000 samples of uniform distributed
random numbers
x3=rand(1,2000);
x4=rand(1,2000);
figure;
plot(x3,x4,'.');
title('scatter plot of uniform distributed random numbers');
figure;
subplot(2,1,1);
%plot the histogram graph of x2
74
Department of ECE BS Lab Manual

hist(x2);
title(' gaussian distribution');
subplot(2,1,2);
%plot the histogram graph of x4
hist(x4);
title(' uniform distribution');
ymu=mean(x2)
ymsq=sum(x2.^2)/length(x2)
ysigma=std(x2)
yvar=var(x2)
yskew=skewness(x2)
ykurt=kurtosis(x2)

Output:

ymu =

0.0172
ymsq =

0.9528
ysigma =

0.9762
yvar =

0.9530
yskew =

-0.0041

ykurt =

2.9381
75
Department of ECE BS Lab Manual
76
Department of ECE BS Lab Manual
77
Department of ECE BS Lab Manual
78
Department of ECE BS Lab Manual

EXP.NO: 14
SAMPLING THEOREM VERIFICATION

AIM: Verify the sampling theorem.

Software Required:
Matlab software 7.0 and above.

Theory:

Sampling Theorem:
\A bandlimited signal can be reconstructed exactly if it is sampled at a rate
atleast twice the maximum frequency component in it." Figure 1 shows a
signal g(t) that is bandlimited.

Figure 1: Spectrum of bandlimited signal g(t)

The maximum frequency component of g(t) is fm. To recover the signal


g(t) exactly from its samples it has to be sampled at a rate fs ≥ 2fm.
The minimum required sampling rate fs = 2fm is called ' Nyquist rate

Proof: Let g(t) be a bandlimited signal whose bandwidth is


fm (wm = 2πfm).
79
Department of ECE BS Lab Manual

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


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

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

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

To recover the original signal G(w):


1. Filter with a Gate function, H2wm(w) of width
2wm Scale it by T.
80
Department of ECE BS Lab Manual

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

Aliasing ws < 2wm.

Figure 6: Aliasing due to inadequate sampling

Aliasing leads to distortion in recovered signal. This is the


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

Oversampling ws >2wm. This condition avoid aliasing.


81
Department of ECE BS Lab Manual

Figure 7: Oversampled signal-avoids aliasing

Program:

Clc;
Clear all;
Close all;
t=-10:.01:10;
T=4;
fm=1/T;
x=cos(2*pi*fm*t);
subplot(2,2,1);
plot(t,x);
xlabel('time');
ylabel('x(t)'); title('continous
time signal'); grid;

n1=-4:1:4;
fs1=1.6*fm;
fs2=2*fm;
fs3=8*fm;
x1=cos(2*pi*fm/fs1*n1);
subplot(2,2,2);
stem(n1,x1);
xlabel('time');
ylabel('x(n)');
title('discrete time signal with
fs<2fm'); hold on;
subplot(2,2,2);
plot(n1,x1);
grid; n2=-
5:1:5;
82
Department of ECE BS Lab Manual

x2=cos(2*pi*fm/fs2*n2);
subplot(2,2,3);
stem(n2,x2);
xlabel('time');
ylabel('x(n)');
title('discrete time signal with fs=2fm');
hold on;
subplot(2,2,3);
plot(n2,x2)
grid; n3=-
20:1:20;
x3=cos(2*pi*fm/fs3*n3);
subplot(2,2,4);
stem(n3,x3);
xlabel('time');
ylabel('x(n)');
title('discrete time signal with fs>2fm')
hold on;
subplot(2,2,4);
plot(n3,x3)
grid;

Result: Sampling theorem is verified.


83
Department of ECE BS Lab Manual

OUTPUT:
84
Department of ECE BS Lab Manual

EXP.No:15
REMOVAL OF NOISE BY AUTO CORRELATION/CROSS
CORRELATION

AIM: Write the program for Removal of noise by using auto correlation.

Software Required:
Matlab software 7.0 and above.

Theory:

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


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

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

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

Detection of noise by Auto-Correlation:

S(t)=Periodic Signal (Transmitted) , mixed with a noise signal n(t).

Then f(t) is received signal is [s(t ) + n(t) ]

Let Qff(T) =Auto Correlation Function of f(t)


Qss(t) = Auto Correlation Function of S(t)
Qnn(T) = Auto Correlation Function of n(t)

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

T/2
= Lim 1/T ∫ [s(t)+n(t)] [s(t-T)+n(t-T)] dt
T--∞ -T/2
85
Department of ECE BS Lab Manual

=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 aQnn(T) becomes small for
large values of T Therefore for sufficiently large values of T Qff(T) is equal
to Qss(T).

Program:

clc; clear
all; close
all;
t=0:0.2:pi*8;
%input signal
s=sin(t);
subplot(6,1,1);
plot(s); title('signal
s'); xlabel('t');
ylabel('amplitude');
%generating noise
n = randn([1 126]);
%noisy signal
f=s+n;
subplot(6,1,2)
plot(f);

title('signal f=s+n');
xlabel('t');
ylabel('amplitude');
86
Department of ECE BS Lab Manual

%aucorrelation of input
signal as=xcorr(s,s);
subplot(6,1,3);
plot(as);
title('auto correlation of s');
xlabel('t'); ylabel('amplitude');
%aucorrelation of noise
signal an=xcorr(n,n);

subplot(6,1,4)
plot(an);
title('auto correlation of n');
xlabel('t');
ylabel('amplitude');
%aucorrelation of transmitted
signal cff=xcorr(f,f);
subplot(6,1,5)
plot(cff);
title('auto correlation of
f'); xlabel('t');
ylabel('amplitude');

%aucorrelation of received
signal hh=as+an;
subplot(6,1,6)
plot(hh);
title('addition of as+an');
xlabel('t');
ylabel('amplitude');

Result:Removal of noise using autocorrelation is performed.


Output:
87
Department of ECE BS Lab Manual
88
Department of ECE BS Lab Manual

EXP.No:16
EXTRACTION OF PERIODIC SIGNAL MASKED BY NOISE USING
CORRELATION

AIM: Write the program for extraction of periodic signal using correlation.

Software Required:
Matlab software 7.0 and above.

Theory:
A signal is masked by noise can be detected either by correlation techniques
or by filtering.Actually, the two techniques are equivalent. The correlation
technique is a measure of extraction of a given signal in the time domain
whereas filtering achieves exactly the same results in frequency domain.

Program:
clear all;
close
all; clc;
t=0:0.1: pi*4;
%input signal1
s=sin(t);
subplot(7,1,1)
plot(s); title('signal
s'); xlabel('t');
ylabel('amplitude');
%input signal2
c=cos(t);
subplot(7,1,2)
plot(c); title('signal
c'); xlabel('t');
ylabel('amplitude');

%generating noise signal


n = randn([1 126]);
89
Department of ECE BS Lab Manual

%signal+noise
f=s+n;
subplot(7,1,3);
plot(f);
title('signal f=s+n');
xlabel('t');
ylabel('amplitude');

%crosscorrelation of signal1&signal2
asc=xcorr(s,c);
subplot(7,1,4)
plot(asc);
title(' correlation of s and c');
xlabel('t');
ylabel('amplitude');
%crosscorrelation of
noise&signal2 anc=xcorr(n,c);
subplot(7,1,5)
plot(anc);
title(' correlation of n and c');
xlabel('t');
ylabel('amplitude');
%crosscorrelation of f&signal2
cfc=xcorr(f,c);
subplot(7,1,6)
plot(cfc);
title(' correlation of f and c');
xlabel('t');
ylabel('amplitude');
%extracting periodic signal
hh=asc+anc;
subplot(7,1,7)
plot(hh);
title('addition of sc+nc');
xlabel('t');
90
Department of ECE BS Lab Manual

ylabel('amplitude');

Result: Periodic signal is extracted by using correlation.


91
Department of ECE BS Lab Manual

Output:
92
Department of ECE BS Lab Manual

EXP.No:17
VERIFICATION OF WIENER-KHINCHIN RELATION

AIM:Verification of wiener-khinchin relation

Software Required:
Matlab software 7.0 and above.

Theory:
The wiener-khinchin 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:
Sxx(f)=∫rxx(T)e-j2πft dT
Where rxx(T)=E[x(t)x*(t-
T)]

Discrete case:

Sxx(f)=∑rxx[k]e-j2πkf
Where
rxx[k]=E[x(n)x*(n-k)]

Program:

clc; clear
all; close
all;
t=0:0.1:2*pi;
%input signal
x=sin(2*t);
subplot(3,1,1);
plot(x);
xlabel('time');
ylabel('amplitude');
title('input signal');
%autocorrelation of input signal
xu=xcorr(x,x);

93
Department of ECE BS Lab Manual

%fft of autocorrelation
signal y=fft(xu);
subplot(3,1,2);
plot(abs(y));
xlabel('f');
ylabel('amplitude');
title('fft of autocorrelation of input
signal'); %fourier transform of input signal
y1=fft(x);
%finding the power spectral
density y2=(abs(y1)).^2;
subplot(3,1,3);
plot(y2);
xlabel('f');
ylabel('magnitude');
title('PSD of input signal');

Result:

wiener-khinchin relation is verified.


94
Department of ECE BS Lab Manual

Output:
95

You might also like