You are on page 1of 71

DEPT.OF EC.E., LITS.

KMM

INDEX
S.No.
1
2
3

4
5
6
7
8
9
10
11
12
13
14
15
16
17

NAME OF THE EXPERIMENT


BASIC OPERATIONS ON MATRICES
GENERATION OF STANDARD SIGNALS
BASIC OPERATIONS ON SIGNALS
i)SCALING OPERATIONS ON SIGNALS
ii)COMPUTATION ENERGY AND AVERAGE
POWER OF SIGNAL
FINDING EVEN AND ODD PARTS OF SIGNAL
CONVOLUTION OF TWO SIGNALS
PROGRAM TO COMPUTE AUTO CORRELATION AND CROSS
CORRELATION
COMPUTSTION OF LINEARITY AND TIME INVARIANCE OF LTI
SYSTEM
FREQUENCY RESPONSE OF SYSTEM
GIBB'S PHENOMENON
COMPUTATION OF FOURIER TRANSFORM OF A SIGNSAL
WAVE FORM SYNTHESIS
POLE ZERO PLOT OF Z.T.
GENERATION OF GAUSSION NOISE COMPUTATION OF ITS
MEAN, M.S. VALUE AND ITS SKEW, KURTOSIS AND PSD, PDF
VERIFICATUION OF SAMPLING THEORM
REMOVAL OF NOISE BY AUTO CORRELATION/CROSS
CORRELATION
PROGRAM TO EXTRACT PERIODIC SIGNAL MASKED BY NOISE
USING CORRELATION
VERIFICATION OF WEINER-KHINCHINE RELATION

Pg.No.
1
2
4
6
9
11
13
15
16
20
25
27
28
29
34
37
40
44
47

DEPT.OF EC.E., LITS.KMM

BASIC OPERATIONS ON MATRICES


EXPT. NO: 1

Date:

Aim: To write and execute a MATLAB program to perform basic operations on matrices.
Program code:
clc;
close all;
clear all;
%Defining matrices a and b
a=[1 2 3 4;5 6 7 8;9 8 7 6;5 4 3 2]
b=[9 8 7 6;5 4 3 2;1 2 3 4;5 6 7 8]
a+b
%% addition of two matrices
a-b
%% subtraction of two matrices
c=a*b %% multiplication of two matrices
diag(a) %%diagonal elements of a
diag(b) %%daigonal elements of b
diag(c) %% diagonal elements of c
a(1,2) %% extracting of element 1,2 in a
a(2,3) %% extracting of element 2,3 in a
b(1,2) %% extracting of element 1,2 in b
b(2,3) %% extracting of element 2,3 in b
sum(a(1,:)) %%sum of 1st row elements of a
sum(a(2,:)) %% sum of 2nd row elements of a
sum(a(3,:)) %%sum of 3rd row elements of a
sum(a(4,:)) %% sum of 4th row elements of a
sum(c(1,:)) %%sum of 1st row elements of c
sum(c(2,:)) %% sum of 2nd row elements of c
sum(c(3,:)) %%sum of 3rd row elements of c
sum(c(4,:)) %% sum of 4th row elements of c
1

DEPT.OF EC.E., LITS.KMM

x=a' %%transpose of a

GENERATION OF STANDARD SIGNALS


EXPT. NO: 2

Date:

Aim: To simulate standard signals using MATLAB software.


Program code:
clc; close all; clear all;
tmin = -5; dt = 0.1; tmax = 5; %set of time vector
t = tmin:dt:tmax;
%unit impulse signal
x1 = 1; x2 = 0; ximp = x1.*(t==0) + x2.*(t~=0);
subplot(3,3,1); plot(t,ximp);
xlabel('t');ylabel('x(t)');
title('unit impulse signal');
% unit step signal
xu = x1.*(t>=0) + x2.*(t<0);
subplot(3,3,2); plot(t,xu);
xlabel('t');ylabel('x(t)');
title('unit step signal');
% unit ramp signal
x = t; xr = x.*(t>=0);
subplot(3,3,3); plot(t,xr);
xlabel('t');ylabel('x(t)');
title('unit ramp signal');
% parabolic signal
A = 0.4; x1 = (A*(t.^2))/2;
xp = x1.*(t>=0) + x2.*(t<0);
subplot(3,3,4); plot(t,xp);
xlabel('t');ylabel('x(t)');
title('parabolic signal');
% sinusiodial signal
T = 2; F = 1/T; xs = sin(2*pi*F*t);
subplot(3,3,5); plot(t,xs);
xlabel('t');ylabel('x(t)');
title('sinusoidal signal');
% triangular pulse siganal
2

DEPT.OF EC.E., LITS.KMM

a = 2; x1 = 1 - abs(t)/a;
xt = x1.*(abs(t)<=a) + x2.*(abs(t)>a);
subplot(3,3,6); plot(t,xt);
xlabel('t');ylabel('x(t)'); title('triangular pulse signal');
% signum signal
x1 = 1; x3 = -1;
xsg = x1.*(t>0) + x2.*(t==0) + x3.*(t<0);
subplot(3,3,7); plot(t,xsg);
xlabel('t');ylabel('x(t)'); title('signum signal');
% sinc signal
x = sinc(t); subplot(3,3,8); plot(t,x);
xlabel('t');ylabel('x(t)'); title('sinc signal');
% gaussian signal
xga = exp(-a.*(t.^2));
subplot(3,3,9); plot(t,xga);
xlabel('t');ylabel('x(t)');title('gaussian signal');

OUTPUT OF EXPT:2

DEPT.OF EC.E., LITS.KMM

x(t)

gaussian signal

t
1

0.5
0

5
0

-5

x(t)

sinc signal

t
1

DEPT.OF EC.E., LITS.KMM

-1

5
0

-5

signum signal
EXPT. NO: 3

BASIC OPERATIONS ON SIGNALS


Date:

x(t)

Aim: To write and execute a MATLAB program to perform basic operations on signals.
Program code:
%matlab program to perform operations on signals such as
%Addition, Multiplication, Scaling, Shifting, Folding,
%computation of energy and average power
% Program to perform addition and multiplication of the following two
% signals 1) xa(t)=1; 0<t<1
xb(t) = t; 0<t<1
%
=2; 1<t<2
= 1; 1<t<2
t
%
=1; 2<t<3
= 3-t; 2<t<3
clc; clear all; close all;
tmin = -1; tmax = 5; dt = 0.1; %setting of time vector
t = tmin:dt:tmax;
x1=1; x2=2; x3=3-t;
xa = x1.*(t>0&t<1) + x2.*(t>=1&t<=2) + x1.*(t>2&t<3);
xb = t.*(t>0&t<1) + x1.*(t>=1&t<=2) +x3.*(t>2&t<3);
xadd = xa + xb; xmul = xa .* xb;
xmin = min([min(xa), min(xb), min(xadd), min(xmul)]);
xmax = max([max(xa), max(xb), max(xadd), max(xmul)]);
%plot of signal xa(t)
subplot(2,3,1); plot(t,xa);
axis([tmin tmax xmin xmax]);
xlabel('t'); ylabel('xa(t)');
title('signal xa(t)');
%plot of signal xb(t)
subplot(2,3,2); plot(t,xb);
axis([tmin tmax xmin xmax]);
xlabel('t'); ylabel('xb(t)');
title('signal xb(t)');
%plot of signal xa(t)+xb(t)
subplot(2,3,3); plot(t,xadd);
axis([tmin tmax xmin xmax]);
5

DEPT.OF EC.E., LITS.KMM

xlabel('t'); ylabel('xadd(t)');
title('sum of xa(t) and xb(t)');

%plot of signal xa(t)


subplot(2,3,4); plot(t,xa);
axis([tmin tmax xmin xmax]);
xlabel('t'); ylabel('xa(t)');
title('signal xa(t)');
%plot of signal xb(t)
subplot(2,3,5); plot(t,xb);
axis([tmin tmax xmin xmax]);
xlabel('t'); ylabel('xb(t)');
title('signal xb(t)');
%plot of signal xa(t)Xxb(t)
subplot(2,3,6); plot(t,xmul);
axis([tmin tmax xmin xmax]);
xlabel('t'); ylabel('xmul(t)');
title('product of xa(t) and xb(t)');
OUTPUT OF EXPT: 3

DEPT.OF EC.E., LITS.KMM

xmul(t)

product of xa(t) and xb(t)

2
7

4
DEPT.OF EC.E., LITS.KMM

signal xb(t)

SCALING OPERATIONS ON SIGNALS

EXPT.NO: 3A

Date:
xb(t)

Aim: To write and execute a MATLAB program to performs scaling operations on signals.
Program code:
% matlab program to perform amplitude scaling, time scaling and time
% shifting on the signal x(t) = 1.0+t; for t= 0 to 2
tmin = -3; tmax = 5; dt = 0.2; %setting of time vector
t = tmin:dt:tmax;
y0 = y(t);
t
y1 = 1.5*y(t);
y2 = 0.5*y(t);
y3 = y(2*t);
3
y4 = y(0.5*t);
y5 = y(t-2);
y6 = y(t+2); %compute the min and max value for y -axis
ymin = min([min(y0), min(y1), min(y2), min(y3), min(y4), min(y5), min(y6)]);
ymax = max([max(y0), max(y1), max(y2), max(y3), max(y4), max(y5), max(y6)]);
%plot of signal y0(t) %original signal
subplot(3,3,1);plot(t,y0);
axis([tmin tmax ymin ymax]);
2

DEPT.OF EC.E., LITS.KMM

xlabel('t');ylabel('y(t)');title('signal x(t)');2
%plot of signal y1(t) %amplified signal
subplot(3,3,2);plot(t,y1);
axis([tmin tmax ymin ymax]); 0
xlabel('t');ylabel('1.5y(t)');title('amplified signal x1(t)');
%plot of signal y2(t) %attenuated signal
subplot(3,3,3);plot(t,y2);
axis([tmin tmax ymin ymax]);
xlabel('t');ylabel('0.5y(t)');
title('attenuted signal x2(t)');
%plot of signal y0(t) %original signal
subplot(3,3,4);plot(t,y0);
axis([tmin tmax ymin ymax]);
xlabel('t');ylabel('y(t)');
title('signal x(t)');

xa(t)

xa(t) %compressed signal


%plot of signal y3(t)
subplot(3,3,5);plot(t,y3);
axis([tmin tmax ymin ymax]);
xlabel('t');ylabel('y(2*t)');title('time compressed signal');
subplot(3,3,6);plot(t,y4);
axis([tmin tmax ymin ymax]);
xlabel('t');ylabel('y(0.5*t)');
title('time expanded signal');
%plot of signal y0(t) %original signal
subplot(3,3,7);plot(t,y0);
axis([tmin tmax ymin ymax]);
xlabel('t');ylabel('y(t)'); title('signal x(t)');
%plot of signal y5(t) % delayed signal
subplot(3,3,8);plot(t,y5);
axis([tmin tmax ymin ymax]);
xlabel('t');ylabel('y(t-2)');
title('delayed signal');
%plot of signal y6(t) %sdvanced signal
subplot(3,3,9);plot(t,y6);
axis([tmin tmax ymin ymax]);
9

DEPT.OF EC.E., LITS.KMM

xlabel('t');ylabel('y(t+2)');title('advanced signal');

OUTPUT OF EXPT: 3A

10

DEPT.OF EC.E., LITS.KMM

y(t+2)

advanced signal

4
t

2
0
-2

y(t-2)

delayed signal

2
0

4
2

11

-2
DEPT.OF EC.E., LITS.KMM

y(t)

signal x(t)

COMPUTATION ENERGY
AND AVERAGE
t
POWER OF SIGNAL
EXPT NO:3B
Date:
Aim: To write and execute a MATLAB program to compute energy and average power of
signal.
Program code:
%matlab program to find folded signal and to compute power and energy of a signal
%folding of a signal
tmin = -3; tmax = 5; dt = 0.2; %setting of time vector
x = y(t);
x_fold = y(-t);
ymin = min([min(x),min(x_fold)]);
ymax = max([max(x),max(x_fold)]);
%plot of signal
subplot(2,1,1);plot(t,x);
axis([tmin tmax ymin ymax]);
xlabel('t');ylabel('y(t)');
title('signal x(t)');
%plot of folded signal
subplot(2,1,2);plot(t,x_fold);
xlabel('t');ylabel('y(-t)');
axis([tmin tmax ymin ymax]);
12

DEPT.OF EC.E., LITS.KMM

title('folded version signal x(t)');


%program to compute the energy and average power of the signal
%x(t)=10sin(10*pi*t)
tmax = 10; dt = .01; T0 = 10; %setting of time vector
t = -tmax:dt:tmax;
x = 10*sin(10*pi*t);
xsq = x.^2;
E = trapz(t,xsq); % computation of energy
P = E /(2*T0);
% computation of power
disp([' Energy, E = ',num2str(E),'Joules']); %printing of energy value
disp([' power, P = ',num2str(P),'Watts']); %printing of power value

OUTPUT OF EXPT:3B

13

DEPT.OF EC.E., LITS.KMM

y(-t)

folded version signal x(t)

14

2.5

DEPT.OF EC.E., LITS.KMM

Energy E = 1000J, Power P = 50W.

1.5

0.5

FINDING EVEN AND ODD PARTS OF SIGNAL


EXPT NO: 4

Date:

Aim: To write and execute a MATLAB program to find0 even &odd parts of signal.
Program code:
tmin = -3; tmax = 3;
dt = 0.1;
t = tmin:dt:tmax;
-2
x1 = exp(2*t);
x2 = exp(-2*t);
if (x2==x1)
disp('The given signal is even signal');
else if (x2 ==(-x1))
disp('The given signal is an odd signal');
else
disp('The given signal is neighter odd nor even signa');
end
15

DEPT.OF EC.E., LITS.KMM

y(t)

end
xe = (x1+x2)/2;
xo = (x1+x2)/2;
ymin = min([min(x1), min(x2), min(xe), min(xo)]);
ymax = max([max(x1), max(x2), max(xe), max(xo)]);
subplot(2,2,1);
plot(t,x1);
axis([tmin tmax ymin ymax]);
signal x(t)
xlabel('t');ylabel('x1(t)');
title('signal x(t)'); subplot(2,2,2);plot(t,x2);
axis([tmin tmax ymin ymax]);
xlabel('t');
ylabel('x2(t)');
title('signal x(-t)');
subplot(2,2,3);
3
plot(t,xe);
axis([tmin
tmax ymin ymax]);
2.5
xlabel('t');
ylabel('xe(t)');
2
title('even part of signal x(t)');
subplot(2,2,4);
1.5
1

plot(t,xo);0.5
axis([tmin tmax ymin ymax]);
0
-2
0
2
xlabel('t');ylabel('xo(t)');
t
title('odd part of signal x(t)');

OUTPUT OF EXPT: 4

16

DEPT.OF EC.E., LITS.KMM

CONVOLUTION OF TWO SIGNALLS


EXPT. NO: 5

Date:

Aim: To write and execute a MATLAB program for computation of convolution of two
signals.
Program code:
17

DEPT.OF EC.E., LITS.KMM

%x1(t)=exp(-0.7t); 0<=t<=T and x2(t)=1; 0<=t<=T


T = 2;
tmin = 0; tmax = 2*T; dt = 0.01;
t = tmin:dt:tmax;
x1 = exp(-0.7*t).*(t>=0 & t<T);
x2 = 1.*(t>=0 & t<T);
x3 = conv(x1,x2)
n3 = length(x3);
t1 = 0:1:n3-1;
subplot(2,2,1);plot(t,x1);
xlabel('t');ylabel('x1(t)');
title('signal x1(t)');
subplot(2,2,2);plot(t,x2);
xlabel('t');ylabel('x2(t)');
title('signal x2(t)');
subplot(2,2,3:4);plot(t1,x3);
xlabel('t');ylabel('x3(t)');
title('convolved signal of x1(t)&x2(t)');
%deconvolution to get original
x1d = deconv(x3,x2);
x2d = deconv(x3,x1);
ymin = min([min(x1d), min(x2d)]);
ymax = max([max(x1d), max(x2d)]);
figure;subplot(2,1,1);plot(t,x1d);
axis([tmin tmax ymin ymax]);
xlabel('t');ylabel('x1(t)');
title('extracted signal,x1(t)');
subplot(2,1,2);plot(t,x2d);
axis([tmin tmax ymin ymax]);
xlabel('t');ylabel('x2(t)');
title('extracted signal,x2(t)');

OUTPUT OF EXPT: 5

18

DEPT.OF EC.E., LITS.KMM

x3(t)

convolved signal of x1(t)&x2(t)

19

DEPT.OF EC.E., LITS.KMM

extracted signal,x2(t)

extracted signal,x1(t)

x2(t)

x1(t)

1
0.5

0.5
0

0.5

0.5

1.5

1.5

2
t
2
t

2.5

2.5

3.5

3.5

PROGRAM TO COMPUTE AUTO CORRELATION AND CROSS CORRELATION


EXPT. NO: 6

Date:
20

DEPT.OF EC.E., LITS.KMM

Aim: To write a program for computation of auto correlation and cross correlation between

signals.
Program code:
clc; clear all; close all;
t = -2:0.01:2; x1 = sin(2*pi*t);
subplot(2,2,1);plot(t,x1); xlabel('t');ylabel('x1(t)');
title('signal x1(t)'); x2 = exp(t);
subplot(2,2,2);plot(t,x2); xlabel('t');ylabel('x2(t)');
title('signal x2(t)'); x3 = exp(-t);
%computation of cross correlation
R13 = conv(x1,x3); n13 = length(R13);
t13 = 0:1:n13-1;
subplot(2,2,3);plot(t13,R13); xlabel('t');ylabel('R13(t)');
title('cross correlation of x1,x2');
%computation of auto correlation
R23 = conv(x2,x3); n23 = length(R23);
t23 = 0:1:n23-1;
subplot(2,2,4);plot(t23,R23); xlabel('t');ylabel('R23(t)');
title('auto correlation of x2');
OUTPUT OF EXPT:6

21

DEPT.OF EC.E., LITS.KMM

R23(t)

auto correlation of x2

t
3000

2000
1000
0

800
600
400
200

22
cross correlation of x1,x2

R13(t)

DEPT.OF EC.E., LITS.KMM

COMPUTSTION OF LINEARITY AND TIME INVARIANCE OF LTI


SYSTEM

EXPT. NO:7

Date:

Aim: To write a program for computation


of linearity and time invariance of LTI system.
t
Program code:
clc; clear all; close all;
x1 = input('type the samples of x1');
x2 = input('type the samples of x2');
if (length(x1)~=length(x2))
disp('Error: length of x1 and x2 are diffrent');
return;
end
h = input('type the samples of h');
N = length(x1) + length(x2)-1;
disp('the length of the out put signal will be');
disp(N);
%linearity check
a1 = input('the scale factor a1 is ');
a2 = input('the scale factor a2 is ');
x = a1*x1 + a2*x2;
y01 = conv(x,h);
y1 = conv(x1,h);
y1s = a1*y1;
y2 = conv(x2,h);
y2s = a2*y2;
y02 = y1s + y2s;
disp('input signal x1 is ');disp(x1);
disp('input signal x2 is ');disp(x2);
disp('output sequence y01 is ');disp(y01);
disp('output sequence y02 is ');disp(y02);
if (y01 == y02)
disp('y01=y02.Hence the LTI system is LINEAR');
end
% time invariance check
x = input('type the samples of signal x(n)');
h = input( ' Type the samples of signal h(n) ' );
23

DEPT.OF EC.E., LITS.KMM

y = conv(x,h);
disp( ' Enter a POSITIVE number for delay ' );
d = input( ' Desired delay of the signal is ' );
xd = [zeros(1,d), x];
nxd = 0 : length(xd)-1;
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)];
figure
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) ' );
OUTPUT OF EXPT7
type the samples of x1[1 2 3]
type the samples of x2[4 5 6]
type the samples of h[1 2 3]
the length of the out put signal will 5
24

DEPT.OF EC.E., LITS.KMM

the scale factor a1 is 3


the scale factor a2 is 4
input signal x1 is
1

input signal x2 is
4

output sequence y01 is


19

64 142 144

99

output sequence y02 is


19

64 142 144

99

y01=y02.Hence the LTI system is LINEAR


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

Delayed Input Signal xd(n) is


0

Original Output Signal y(n) is


4

13

28

27

18

Delayed Output Signal yd(n) is


25

DEPT.OF EC.E., LITS.KMM

13

28

27

18

26

DEPT.OF EC.E., LITS.KMM

Delayed Input Signal xd(n)

Original Input Signal x(n)

xd(n)

x(n)

1
0
0

2
1
0
0

0.5
0.5

1
1

1.5
2
2.5
Time Index n
1.5
2
2.5
3
Time Index n

3.5
3.5

4
4

27

DEPT.OF EC.E., LITS.KMM

FREQUENCY RESPONSE OF SYSTEM

yd(n)

y(n)

EXPT. NO: 8
Date:
Aim: to write a program for finding frequency response of system.
Program code:
clc; clear all; close all; num = input ('type the numerator vector ');
Delayed Output Signal yd(n)
den = input ('type the denominator vector '); N = input ('number of frequency points ');
w = 0 : pi / N : pi; H = freqz (num, den, w) ;figure;
subplot( 2 , 1 , 1 ); plot( w/pi , real(H) );
Signal y(n)
xlabel( ' \omega / \pi' );Original
ylabel('Output
Amplitude
')
title ( 'Real part' );subplot( 2 , 1 , 2 ); plot( w/pi , imag(H) );
xlabel( ' \omega / \pi' );ylabel(' Amplitude ' );
title ( 'Imaginary part' );figure; subplot( 2 , 1 , 1 );
plot( w/pi30, abs(H) ); xlabel(' \omega / \pi');
ylabel(' Magnitude'); title ('Magnitude Spectrum');
subplot(
30 2 , 1 , 2 ); plot( w/pi , angle(H) );
20
xlabel(' \omega / \pi'); ylabel(' Phase(radians) ');
title ('Phase
Spectrum');
20
10
%unit sample response
num 10
= input ('type the numerator vector ');
0 ('type the denominator vector ');
den = input
0
1
2
3
4
5
6
N=input ('type the desired length of
theIndex
output
Time
n sequence N ');
0
n = 0 : 0N-1; imp1= [ 1 zeros(1,
N-1)3 ];
2
4
5
6
Time
Index
n
h = filter ( num, den, imp );
%disp('The impulse response of LTI system is'); disp(h);
figure,stem(n,h); xlabel ('time index n');
ylabel ('h(n)'); title ('Impulse Response of LTI system');
%unit step response
num = input ('type the numerator vector ');
den = input ('type the denominator vector ');
N = input('type the desired length of the output sequence N ');
n = 0:1:N-1; u = ones (1, N); s = filter ( num, den, u );
%disp('The step response of LTI system is'); disp(s);
figure,stem(n,s); xlabel ('time index n');
ylabel ('s(n)'); title ('Step Response of LTI system');
%stability and physical realizability
28

DEPT.OF EC.E., LITS.KMM

num = input (' type the numerator vector '); den = input (' type the denominator vector ');
[z,p,k] = tf2zp(num,den); disp ('Gain constant is '); disp(k);
disp (' Zeros are at '); disp(z)
disp ('radius of Zeros ') ; radzero = abs(z)
disp ('Poles are at '); disp(p)
disp ('radius of Poles ') ; radpole = abs(p)
if max(radpole) >= 1
disp (' ALL the POLES do not lie within the Unit Circle ');
disp(Oooooops..The given LTI system is NOT a stable system ');
else
disp (' ALL the POLES lie WITHIN the Unit Circle ');
disp('The given LTI system is a REALIZABLE and STABLE system');
end;
figure;zplane(num,den);title('Pole-Zero Map of the LTI system');
OUTPUT OF EXPT8
pe the numerator vector [1], type the denominator vector [1 -0.8],number of frequency points 50
type the numerator vector [1], type the denominator vector [1 -0.8]
type the desired length of the output sequence N 50, type the numerator vector [1]
type the denominator vector [1 -0.8], type the desired length of the output sequence N 50
type the numerator vector [1], type the denominator vector [1 -0.8]
Gain constant is 1, Zeros are at, radius of Zeros, radzero =, Empty matrix: 0-by-1
Poles are at, 0.8000, radius of Poles, radpole = 0.8000
ALL the POLES lie WITHIN the Unit Circle
The given LTI system is a REALIZABLE and STABLE system

29

DEPT.OF EC.E., LITS.KMM

Pole-Zero Map of the LTI system


1
0.8
0.6
0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
-1
-1

-0.5

0
Real Part

0.5

30

Amplitude

DEPT.OF EC.E., LITS.KMM

Real part

6
4
2

Amplitude

0
0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

0.7

0.8

0.9

/
Imaginary part

0
-1
-2
-3
0

0.1

0.2

0.3

0.4

0.5

0.6

31

DEPT.OF EC.E., LITS.KMM

Magnitude Spectrum

6
4
Mag
nitud
e2
0
0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

0.7

0.8

0.9

/
Phase Spectrum

0
Phas
e(ra
dian
-0.5
s)

-1
0

0.1

0.2

0.3

0.4

0.5

0.6

32

DEPT.OF EC.E., LITS.KMM

Impulse Response of LTI system

1
0.9
0.8
0.7

h(n)

0.6
0.5
0.4
0.3
0.2
0.1
0
0

10

15

20
25
30
time index n

35

40

45

50

33

DEPT.OF EC.E., LITS.KMM

Step Response of LTI system

5
4.5
4
3.5

s(n)

3
2.5
2
1.5
1
0.5
0
0

10

15

20
25
30
time index n

35

40

45

50

34

DEPT.OF EC.E., LITS.KMM

Pole-Zero Map of the LTI system


1
0.8
0.6

Imag
inary
Part

0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
-1
-1

-0.5

0
Real Part

0.5

GIBB'S PHENOMENON
EXPT. NO: 9

Date:

Aim: To write a program to illustrate Gibbs phenomenon.


Program code:
clc; clear all; close all;
N = input('type the total no of harmonics ');
t = 0:0.001:1; y = square( 2 * pi * t ); plot( t , y , 'r' , 'linewidth' , 2 )
axis( [ 0 1 -1.5 1.5 ] )
hold;
sq = zeros( size(t) );
for n = 1 : 2 : N
sq = sq + (4 / (pi * n) * sin( 2 * pi * n * t));
end;
plot( t , sq ); grid;
xlabel( 't' ); ylabel( 'sq(t)' );
35

DEPT.OF EC.E., LITS.KMM

title('Synthesized Square Wave Using Fourier Series');


OUTPUT OF EXPT9
No of harmonics = 20

Synthesized Square Wave Using Fourier Series

1.5

sq(t)

0.5

-0.5

-1

-1.5
0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

t
36

DEPT.OF EC.E., LITS.KMM

No of harmonics = 40

Synthesized Square Wave Using Fourier Series

1.5

sq(t)

0.5

-0.5

-1

-1.5
0

0.1

0.2

0.3

0.4

0.5
t

0.6

0.7

0.8

0.9

No of harmonics = 100

37

DEPT.OF EC.E., LITS.KMM

Synthesized Square Wave Using Fourier Series

1.5

sq(t)

0.5

-0.5

-1

-1.5
0

0.1

0.2

0.3

0.4

0.5
t

0.6

0.7

0.8

0.9

COMPUTATION OF FOURIER TRANSFORM OF A SIGNSAL


EXPT .NO: 10

Date:
38

DEPT.OF EC.E., LITS.KMM

Aim: To write a program for computation of Fourier transform of a signal.


Program code:
clc; close all; clear all;
syms t omega
x = 2; expw = exp(-j*omega*t);
z = int(x*expw,omega,-2,2);
z = simplify(z);
figure(1);
subplot(2,1,1);ezplot('2',[-2 2]);
subplot(2,1,2);ezplot(z);
OUTPUT OF EXPT: 10
.

3
2.5
2
1.5
1
-2

-1.5

-1

-0.5

0
x

0.5

1.5

4/tsin(2 t)
8
6
4
2
0
-2
-6

-4

-2

WAVE FORM SYNTHESIS


39

DEPT.OF EC.E., LITS.KMM

EXPT .NO:11

Date:

Aim: to write a program to synthesize a waveform using Laplace transforms.


Program code:
clc; clear all; close all;
syms s ; T = 1; F1 = 1 - exp(-T*s/2);
F2 = s * (1 + exp(-T*s/2));
F = F1/F2;
f=ilaplace(F);
pretty(simplify(f));
ezplot(f);
%syms s complex;
%x = 2/(s*(s+1)*(s+2));
%disp('inverse lapalce transform x is ');
%x = ilaplace(x);
%simplify(x)
OUTPUT OF EXPT11
(-1)floor
(2t)
1

0.5

-0.5

-1
-6

-4

-2

0
t

40

DEPT.OF EC.E., LITS.KMM

POLE ZERO PLOT OF Z.T


EXPT. NO 12

Date:

Aim: To write a program to draw Z-transform pole-zero plot of a system.


Program code:
clc; clear all; close all;
num = input ( 'type the numerator polynomial vector ' );
den = input( ' type the denominator polynomial vector ' );
H = tf( num , den )
[ p , z ] = pzmap( H );
disp (' zeros are at '); disp( z )
disp ('poles are at '); disp( p )
subplot(2,1,1);pzmap( H )
[ r, p, k ] = residue( num , den );
disp ('PFE coefficients '); disp( r );
disp ('Gain constant is '); disp( k );
if max(real(p)) >= 1
disp (' All poles DO NOT LIE in the Left Half of S-Plane ');
disp (' Oooooops..The given LTI system is NOT a stable system ');
Else
disp (' ALL the POLES lie in the Left Half of S-Plane ');
disp (' The given LTI system is a STABLE system ');
end;
subplot(2,1,2); t = 0 : 0.1 : 5; h = impulse( H , t );
plot( t , h )
xlabel('t'); ylabel('h(t)');
title ( ' Impulse Response of the LTI system ' );
%program to plot pole zero plot of z.t
clc; clear all; close all;
num = input (' type the numerator vector ');
den = input (' type the denominator vector ');
H = filt(num , den)
z = zero(H);
disp (' zeros are at '); disp(z)
disp ('radius of Zeros ') ; radzero = abs(z)
[r,p,k] = residuez(num,den);
disp ('poles are at '); disp(p)
disp ('radius of poles ') ; radpole = abs(p)
41

DEPT.OF EC.E., LITS.KMM

disp ('PFE coefficients '); disp(r);


disp ('Gain constant is '); disp(k);
figure;
zplane(num,den)
title ( ' Pole-Zero Map of the LTI system in Z-Plane' );
if max(radpole) >= 1
disp (' ALL the POLES do not lie within the Unit Circle ');
disp (' Oooooops..The given LTI system is NOT a stable system ');
end;
OUTPUT OF EXPT: 12
type the numerator polynomial vector [1 0.8 0.8],
type the denominator polynomial vector [1 0 0.49]
Transfer function:
s^2 + 0.8 s + 0.8
----------------s^2 + 0.49
zeros are at

-0.4000 + 0.8000i , -0.4000 - 0.8000i

poles are at : 0 + 0.7000i,

0 - 0.7000i

PFE coefficients : 0.4000 - 0.2214i , 0.4000 + 0.2214i


Gain constant is

type the numerator vector [1 0.8 0.8]


type the denominator vector [1 0 0.49]
Transfer function:
1 + 0.8 z^-1 + 0.8 z^-2
----------------------1 + 0.49 z^-2
Sampling time: unspecified
42

DEPT.OF EC.E., LITS.KMM

zeros are at

: -0.4000 + 0.8000i , -0.4000 - 0.8000i

radius of Zeros ,radzero = 0.8944,

poles are at : 0 + 0.7000i ,


radius of poles

0.8944

0 - 0.7000i

radpole = 0.7000, 0.7000

PFE coefficients : -0.3163 - 0.5714i, -0.3163 + 0.5714i


Gain constant is : 1.6327
ALL the POLES lie WITHIN the Unit Circle
The given LTI system is a REALIZABLE and STABLE system
Pole-Zero Map
Ima
gina
ry
Axis

0.8
0.6
0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
-0.4

-0.35

-0.3

-0.25

-0.2

-0.15

-0.1

-0.05

Real Axis
Impulse Response of the LTI system

43

DEPT.OF EC.E., LITS.KMM

1
0.8
0.6
0.4

h(t)

0.2
0
-0.2
-0.4
-0.6
-0.8
-1

0.5

1.5

2.5
t

3.5

4.5

44

DEPT.OF EC.E., LITS.KMM

Pole-Zero Map of the LTI system in Z-Plane


1
0.8

Ima
gina
ry
Part

0.6
0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
-1
-1

-0.5

0.5

Real Part

45

DEPT.OF EC.E., LITS.KMM

Impulse Response

1
0.8
Amp
litud
e

0.6
0.4
0.2
0
-0.2
-0.4
0

10

15

20

25

n (samples)

46

DEPT.OF EC.E., LITS.KMM

GENERATION OF GAUSSION NOISE COMPUTATION OF ITS MEAN,


M.S. VALUE AND ITS SKEW, KURTOSIS AND PSD, PDF.
EXPT. NO: 13

Date:

Aim: To write a program for simulation of Gaussian noise and to compute mean, meansqure,
skew, kurtosis, psd, and pdf of Gaussian noise.
Program code:
clc; clear all; close all; x1 = randn(1,5000);
x2 = randn(1,5000);
figure; plot( x1 , x2 , ' . ' )
title('Scatter Plot of Gaussian Distributed Random Numbers');
x1 = rand(1,5000); x2 = rand(1,5000);
figure; plot( x1 , x2 , ' . ' );
title('Scatter Plot of Uniform Distributed Random Numbers');
x3 = rand(1,100000); figure; subplot(2,1,1); hist(x3)
title('Uniform Distribution');
y = randn(1,100000);
subplot(2,1,2); hist(y)
title('Gaussian Distribution')
ymu = mean(y)
ymsq = sum(y .^ 2 ) / length(y)
ysigma = std(y)
yvar = var(y)
yskew = skewness(y)
ykurt = kurtosis(y)
OUTPUT OF EXPT 13:
ymu = 0.0038 ,ymsq = 1.0043, ysigma =
3.0212

1.0022 ,yvar =1.0043, yskew = -0.0178 ykurt =

47

DEPT.OF EC.E., LITS.KMM

Scatter Plot of Gaussian Distributed Random Numbers


4
3
2
1
0
-1
-2
-3
-4
-4

-3

-2

-1

Scatter Plot of Uniform Distributed Random Numbers

1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

48

DEPT.OF EC.E., LITS.KMM

Uniform Distribution
15000
10000
5000
0
0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

Gaussian Distribution

x 10

3
2
1
0
-5

-4

-3

-2

-1

49

DEPT.OF EC.E., LITS.KMM

VERIFICATION OF SAMPLING THEORM


EXPT. NO: 14
Aim: To write a program to verify sampling theorem.

Date:

Program code:
clc; clear all; close all;
t = -5 : 0.0001 : 5;
F1 = 3; F2 = 23;
x = cos(2*pi*F1*t) + cos(2*pi*F2*t);
figure(1); plot( t , x );
axis ( [-0.4 0.4 -2 2 ] );
xlabel('Time t (sec)'), ylabel('x(t)');
title ('Continuous time signal: x(t) = cos(2\piF_1t) + cos(2\piF_2t)');
% Case 1
Fs1 = 1.4 * F2; ts1 = 1 / Fs1;
n1 = -0.4 : ts1 : 0.4;
xs1 = cos(2*pi*F1*n1) + cos(2*pi*F2*n1);
figure(2); stem( n1 , xs1 )
hold on; plot( t , x , 'r:' );
axis ( [-0.4 0.4 -2 2 ] ); hold off
xlabel('Time Sample (n)'), ylabel('Amplitude');
title ('Discrete Time Signal');
legend( ' Fs < 2Fmax ' );
% Case 2
Fs2 = 2 * F2; ts2 = 1/Fs2;
n2 = -0.4 : ts2 : 0.4;
xs2 = cos(2*pi*F1*n2) + cos(2*pi*F2*n2);
figure(3);stem( n2 , xs2 )
hold on; plot( t , x , 'r:' );
axis ( [-0.4 0.4 -2 2 ] ); hold off
xlabel('Time Sample (n)'), ylabel('Amplitude');
title ('Discrete Time Signal');
legend( ' Fs = 2Fmax ' );
% Case 3
Fs3 = 7 * F2; ts3 = 1/Fs3; n3 = -0.4 : ts3 : 0.4;
xs3 = cos(2*pi*F1*n3) + cos(2*pi*F2*n3);
figure(4); stem( n3 , xs3 );
50

DEPT.OF EC.E., LITS.KMM

hold on; plot( t , x , 'r: ' );


axis ( [-0.4 0.4 -2 2 ] ); hold off
xlabel('Time Sample (n)'), ylabel('Amplitude');
title ('Discrete Time Signal'); legend( ' Fs > 2Fmax ' );
OUTPUT OF EXPT 14

51

DEPT.OF EC.E., LITS.KMM

t)

t) + cos(2
52

DEPT.OF EC.E., LITS.KMM

Continuous time signal: x(t) = cos(2

Fs < 2Fmax
2
1.5
1

x(t)

0.5
0
-0.5
-1
-1.5

53
-2
-0.4

-0.3

-0.2

-0.1

0.1

Time t (sec)

0.2

0.3

0.4

DEPT.OF EC.E., LITS.KMM

Fs = 2Fmax

Discrete Time Signal

54

1.5

DEPT.OF EC.E., LITS.KMM

Amplitude

1
0.5
0
-0.5
-1
-1.5
-2
-0.4

-0.3

-0.2

-0.1
0
0.1
Time Sample (n)

0.2

0.3

0.4

Fs > 2Fmax

55

Discrete Time Signal

DEPT.OF EC.E., LITS.KMM

REMOVAL OF NOISE BY AUTO CORRELATION/CROSS


CORRELATION

Amplitude

EXP.T NO:
Date:
2 15
Aim: To write a program to remove noise from a signal by auto/cross correlation.
1.5
Program
code:
clc; clear all; close all;
N = 100; n1 = 0 : N-1; dsnr = input('type desired SNR in dB');
x = sqrt(2) * sin( (pi / 5 ) * n );
0.5stem( n , x ); grid
figure(1);
axis( [ 0 50 -1.5 1.5 ] )
xlabel( ' n0' ); ylabel( 'x(n)' ); title( 'Sinusoidal Signal x(n)' )
px = var(x) an = sqrt( px * ( 10 ^ ( -1 * dsnr / 10 ) ) );
-0.5 * ( rand( 1 , N ) - 0.5 );
w = sqrt(12)
w = w * an; pn = var(w) disp( 'The calculated SNR ' );
SNRdb =-110 * log10(px / pn)
figure(3); stem( n , w ); grid
axis( [ 0-1.550 min(w) max(w) ] )
xlabel( ' n ' ); ylabel( ' w(n) ' ) ;
-2
title( ' Random
Noise Signal w(n) ' );
-0.4
-0.3
-0.2
-0.1
0
0.1
0.2
0.3
0.4
y = x + w; figure(6); subplot(2,1,1);
stem( n , y );grid
Time Sample (n)
axis( [ 0 50 min(y) max(y) ] )
xlabel( ' n ' ); ylabel( 'y(n)= x(n) + w(n)' );
title( 'Sinusoidal Signal Corrupted with Random Noise' )
[ ryy , lag ] = xcorr( y , y , 'unbiased' );
subplot(2,1,2); stem( lag , ryy ); grid
axis( [ 0 50 -1.5 1.5 ] )
xlabel( 'Lag Index l' ); ylabel( 'R_y_y(l)' );
title( 'Autocorrelation Signal R_y_y(l)' )
[ rxx , lag ] = xcorr( x , x ); figure(2);stem( lag , rxx ); grid
axis( [ -20 20 min(rxx) max(rxx) ] )
xlabel( 'Lag Index l' ); ylabel( 'R_x_x(l)' );
title( 'Autocorrelation Signal R_x_x(l)' )
[ rxw , lag ] = xcorr( x , w );
figure(5);stem( lag , rxw ); grid
axis( [ -20 20 min(rxw) max(rxw) ] )
xlabel( 'Lag Index l' ); ylabel( 'R_x_w(l)' );
title( 'Cross Correlation Between x(n) and w(n) ' )
Discrete
[ rww , lag ] = xcorr( w
, w ); Time Signal
56

DEPT.OF EC.E., LITS.KMM

2
1.5

Amplitude

figure(4); 1stem( lag , rww ); grid


axis( [ -20 20 min(rww) max(rww) ] )
xlabel('Lag
0.5 Index l' ); ylabel( 'R_w_w(l)' );
title( 'Autocorrelation Signal R_w_w(l)' );
OUTPUT OF
0 EXPT15:
type desired SNR in dB30
px =1.0101
-0.5;pn = 8.6937e-004
The calculated SNR
SNRdb = 30.6516
-1

-1.5
-2
-0.4

-0.3

-0.2

-0.1
0
0.1
Time Sample (n)

0.2

0.3

0.4

57

DEPT.OF EC.E., LITS.KMM

58

DEPT.OF EC.E., LITS.KMM

(l)

(l)

Autocorrelation Signal R

100
80

59

Sinusoidal Signal x(n)

40

DEPT.OF EC.E., LITS.KMM

20

0
-20
-40

Random Noise Signal w(n)

0.05
-60
1.5
0.04
-80
0.03
1
-20
0.02

-15

-10

-5

0
Lag Index l

10

15

20

w(n)
x(n)

0.010.5
0

-0.01

-0.02
-0.5
-0.03
-0.04

-1

-0.05
0
-1.5
0

10
5

10

15
15

20
20

25
n25

30
30

35

40

35

45

40

45

50
50

n
Autocorrelation Signal Rw w (l)
0.08
0.07
0.06

Rw w (l)

0.05
0.04
0.03
0.02
0.01
0
-0.01
-20

-15

-10

-5

0
Lag Index l

10

15

20

60

DEPT.OF EC.E., LITS.KMM

Cross Correlation Between x(n) and w(n)


0.25
0.2
0.15
0.1

Rxw (l)

0.05
0
-0.05
-0.1
-0.15
-0.2
-0.25
-20

-15

-10

-5

0
Lag Index l

10

15

20

y(n)= x(n) + w(n)

Sinusoidal Signal Corrupted with Random Noise


1
0.5
0
-0.5
-1
0

10

15

20

25
30
35
n
Autocorrelation Signal Ryy (l)

10

15

20

40

45

50

40

45

50

Ryy (l)

1
0
-1
25
30
Lag Index l

35

61

DEPT.OF EC.E., LITS.KMM

PROGRAM TO EXTRACT PERIODIC SIGNAL MASKED BY NOISE


USING CORRELATION
EXPT .NO 16
Date:
Aim: To write a program to extract a period signal masked by noise using correlation.
Program code:
clc; clear all; close all; M = 256; n = 0 : M-1;
x = cos(16*pi*n/M) + sin(32*pi*n/M);
snr = input( ' Type the desired SNR ' );
px = var(x)
w = sqrt(12) * (rand( 1 , M ) - 0.5); an = sqrt(px * (10 ^ ( (-1 * snr) / 10) ))
w = w .* an; pn = var(w)
SNRdb = 10 * log10(px / pn)
y = x + w; N = M / 8;
L = floor( M / N ); d = zeros( 1 , M );
for i = 1 : M
if rem(i-1,N) == 0
d(i) = 1;
62

DEPT.OF EC.E., LITS.KMM

end;
end;
Cyd = ifft( fft(y,M) .* fft(d,M)) / M;
r = Cyd * ( M / L ); figure(1);
plot( n , x , 'b' ); axis( [ 1 80 -3 3 ] )
xlabel( 'n' ); ylabel( 'x(n)' ); title( ' Periodic Signal x(n) ' )
figure(2);
subplot(2,1,1); plot( n , y , 'r' );
grid; axis( [ 1 96 -3 3 ] ); xlabel( 'n' ); ylabel( 'y(n)' );
title( ' Noisy Signal y(n) ' )
subplot(2,1,2); stem( n , d ); grid; axis( [ 1 96 -0.5 1.5 ] );
xlabel( 'n' ); ylabel( 'd(n)' );
title( ' Impulse Train d(n) ' )
figure(3); plot( n , r , 'k' ); axis( [ 1 80 -3 3 ] )
xlabel( 'n' ); ylabel( 'r(n)' );
title('Extracted Periodic Signal r(n)')
figure(4); plot( n , x , 'b' ); hold on;
axis( [ 1 80 -3 3 ] )
plot( n , r , 'r:' ); hold off; axis( [ 1 80 -3 3 ] )
legend( 'x(n)' , 'r(n)' )

OUTPUT OF EXPT 16:


Type the desired SNR 30 px = 1.0039 an = 0.0317
pn = 9.3657e-004 SNRdb = 30.3016
Periodic Signal x(n)

63

DEPT.OF EC.E., LITS.KMM

x(n)

-1

-2

-3

10

20

30

40
n

50

60

70

80

64

DEPT.OF EC.E., LITS.KMM

Impulse Train d(n)

Noisy Signal y(n)

y(n)

1.5

d(n)

0.5

2
0
-2

0
-0.5

10
10

20

20
30

30
40

40

50
n
50
60
n

60
70

70
80

80

90

90

65

DEPT.OF EC.E., LITS.KMM

Extracted Periodic Signal r(n)

r(n)

-1

-2

-3

10

20

30

40
n

50

60

70

80

66

DEPT.OF EC.E., LITS.KMM

3
x(n)
r(n)
2

-1

-2

-3

10

20

30

40

50

60

70

80

VERIFICATION OF WEINER-KHINCHINE RELATION


EXPT. NO: 17

Date:

Aim: To write a program to verify weiner-khinchine relation.


Program code:
clc;
clear all;
close all;
Fs = 100; t = 0:1/Fs:10;
x = sin(2*pi*15*t) + sin(2*pi*30*t);
N = 512;
X = fft( x , N ); f = Fs * (0 : N-1) / N;
Power = X .* conj(X) / N; figure(1)
plot( f , Power);
title('Power Spectrum through Fourier Transform')
xlabel('Frequency f'); ylabel('Power');
67

DEPT.OF EC.E., LITS.KMM

figure(2)
rxx = xcorr( x , x );
Sxx = fft(rxx,512); plot(f, abs(Sxx))
title('Fourier Transform of Autocorrelation');
xlabel('Frequency f'); ylabel('abs(Sxx)');

OUTPUT OF EXPT:17

Power Spectrum through Fourier Transform

120

100

Power

80

60

40

20

0
0

10

20

30

40
50
60
Frequency f

70

80

90

100

68

DEPT.OF EC.E., LITS.KMM

3.5

Fourier Transform of Autocorrelation

x 10

abs(Sxx)

2.5

1.5

0.5

0
0

10

20

30

40
50
60
Frequency( f)

70

80

90

100

69

You might also like