Professional Documents
Culture Documents
KMM
INDEX
S.No.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Pg.No.
1
2
4
6
9
11
13
15
16
20
25
27
28
29
34
37
40
44
47
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
x=a' %%transpose of a
Date:
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
x(t)
gaussian signal
t
1
0.5
0
5
0
-5
x(t)
sinc signal
t
1
-1
5
0
-5
signum signal
EXPT. NO: 3
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
xlabel('t'); ylabel('xadd(t)');
title('sum of xa(t) and xb(t)');
xmul(t)
2
7
4
DEPT.OF EC.E., LITS.KMM
signal xb(t)
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
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)
xlabel('t');ylabel('y(t+2)');title('advanced signal');
OUTPUT OF EXPT: 3A
10
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
OUTPUT OF EXPT:3B
13
y(-t)
14
2.5
1.5
0.5
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
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
Date:
Aim: To write and execute a MATLAB program for computation of convolution of two
signals.
Program code:
17
OUTPUT OF EXPT: 5
18
x3(t)
19
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
Date:
20
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
R23(t)
auto correlation of x2
t
3000
2000
1000
0
800
600
400
200
22
cross correlation of x1,x2
R13(t)
EXPT. NO:7
Date:
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
input signal x2 is
4
64 142 144
99
64 142 144
99
13
28
27
18
13
28
27
18
26
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
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
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
-0.5
0
Real Part
0.5
30
Amplitude
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
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
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
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
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:
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
No of harmonics = 40
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
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
Date:
38
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
EXPT .NO:11
Date:
0.5
-0.5
-1
-6
-4
-2
0
t
40
Date:
0 - 0.7000i
zeros are at
0.8944
0 - 0.7000i
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
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
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
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
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
47
-3
-2
-1
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
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
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
51
t)
t) + cos(2
52
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
Fs = 2Fmax
54
1.5
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
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
2
1.5
Amplitude
-1.5
-2
-0.4
-0.3
-0.2
-0.1
0
0.1
Time Sample (n)
0.2
0.3
0.4
57
58
(l)
(l)
Autocorrelation Signal R
100
80
59
40
20
0
-20
-40
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
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
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
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)' )
63
x(n)
-1
-2
-3
10
20
30
40
n
50
60
70
80
64
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
r(n)
-1
-2
-3
10
20
30
40
n
50
60
70
80
66
3
x(n)
r(n)
2
-1
-2
-3
10
20
30
40
50
60
70
80
Date:
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
120
100
Power
80
60
40
20
0
0
10
20
30
40
50
60
Frequency f
70
80
90
100
68
3.5
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