Sie sind auf Seite 1von 30

SIGNAL PROCESSING LAB

I M.TECH I Semester-ECE (SSP)

Department of Electronics and Communications Engineering

Paladugu Parvathi Devi College of Engineering and Technology


Surampalli Village, GanvaramMandal, Krishna District, Andhra Pradesh 521 212

Ashok Chakravarthy Pamarthy

PPDCET_ECE_SSP

PALADUGU PARVATHIDEVI COLLEGE OF ENGINEERING AND TECHNOLOGY


Surampalli Village, GanvaramMandal, Krishna District, Andhra Pradesh 521 212

SIGNAL PROCESSING LAB


Note:
A. Minimum of 10 Experiments have to be conducted
B. All Experiments may be Simulated using MATLAB and to be verified theoretically.

1. Basic Operations on Signals, Generation of Various Signals and finding its FFT.
2. Program to verify Decimation and Interpolation of a given Sequences.
3. Program to Convert CD data into DVD data
4. Generation of Dual Tone Multiple Frequency (DTMF) Signals
5. Plot the Periodogram of a Noisy Signal and estimate PSD using Periodogram and
Modified Periodogram methods
6. Estimation of Power Spectrum using Bartlett and Welch methods
7. Parametric methods (Yule-Walker and Burg) of Power Spectrum Estimation
8. Design of LPC filter using Levinson-Durbin Algorithm
9. Computation of Reflection Coefficients using Schur Algorithm
10. To study Finite Length Effects using Simulink
11. Design and verification of Matched filter
12. Adaptive Noise Cancellation using Simulink
13. Design and Simulation of Notch Filter to remove 60Hz Hum/any unwanted
frequency component of given Signal (Speech/ECG)

Ashok Chakravarthy Pamarthy

PPDCET_ECE_SSP

EXPERIMENT NO.1
1.1. To generate Various fundamental discrete time signals

Aim: - To write a MATLAB program to generate various fundamental Signals.


Software used: - MATLAB 7.5
Program:%% Clearing and closing commands
clc
clear all
close all
%% Plotting Various Signals
% program for unit step sequence
n=-5:1:5;
y1=[zeros(1,5) 1 ones(1,5)];
subplot(4,2,1)
stem(n,y1)
xlabel('no of samples');
ylabel('amplitude');
title('unit step sequence');
% program for impulse sequence
n=-5:1:5;
y2=[zeros(1,5) 1 zeros(1,5)];
subplot(4,2,2)
stem(n,y2)
xlabel('no of samples');
ylabel('amplitude');
title('impulse sequence')
% program for ramp sequence
m=0:1:5;
y3=m;
subplot(4,2,3)
stem(m,y3)
xlabel('no of samples')
ylabel('amplitude')
title('ramp sequence')
% program for exponentially increasing

Ashok Chakravarthy Pamarthy

PPDCET_ECE_SSP

t=0:1:5;
a1=.5;
y4=exp(a1*t);
subplot(4,2,4)
stem(t,y4)
xlabel('no of samples')
ylabel('amplitude')
title('exponential increasing sequence')
% program for exponentially decreasing
t=0:1:5;
a2=.2;
y5=exp(-a2*t);
subplot(4,2,5)
stem(t,y5)
xlabel('no of samples')
ylabel('amplitude')
title('exponential decreasing sequence')
% program for sine wave generation
t=0:0.1:2;
y6=sin(2*pi*t);
subplot(4,2,6)
stem(t,y6)
xlabel('no of samples')
ylabel('amplitude')
title('sine wave')
% program for cosine wave generation
t=0:0.1:2;
y7=cos(2*pi*t);
subplot(4,2,7)
stem(t,y7)
xlabel('no of samples')
ylabel('amplitude')
title('cosine wave')

Result: - Hence different basic signals have been generated and plotted using MATLAB

Ashok Chakravarthy Pamarthy

PPDCET_ECE_SSP

Output: -

Ashok Chakravarthy Pamarthy

PPDCET_ECE_SSP

1.2. BASIC OPERATIONS ON SIGNALS


(ADDITION, MULTIPLICATION, FOLDING, SCALING)
Aim: - To write a MATLAB program for various basic operations on given sequences.
Software used: - MATLAB 7.5
Program: %% Clearing and closing commands
clc
clear all
close all
%% Declaring Input sequences
x=[1:1:8];
y=[8:-1:1];
%% Plotting the results of different operations
% Input sequence 1
subplot(3,2,1)
stem(x)
xlabel('no of samples')
ylabel('amplitude')
title('input sequence 1')
% Input sequence 2
subplot(3,2,2)
stem(y)
xlabel('no of samples')
ylabel('amplitude')
title('input sequence 2')
% Addition of sequences
m=x+y;
subplot(3,2,3)
stem(m)
xlabel('no of samples')
ylabel('amplitude')
title('addition of signals')
% Multiplication of sequences
m=x.*y;
subplot(3,2,4)
stem(m)

Ashok Chakravarthy Pamarthy

PPDCET_ECE_SSP

xlabel('no of samples')
ylabel('amplitude')
title('multipilcation of signals')
% Folding of sequences
subplot(3,2,5)
stem(-x,x)
xlabel('no of samples')
ylabel('amplitude')
title('folded sequence')
% Amplitude scaling
subplot(3,2,6)
stem(x,x*2)
xlabel('no of samples')
ylabel('amplitude')
title('amplitude Scaling')
Result: -Hence basic operations signals have been generated and plotted using MATLAB
Output: -

Ashok Chakravarthy Pamarthy

PPDCET_ECE_SSP

1.3. TO FIND OUT THE DFT & IDFT OF A GIVEN SEQUENCE

Aim: - To write a MATLAB program to find out the DFT & IDFT of a given sequence.
Software used: -MATLAB 7.5
Program: %% Clearing and closing commands
clc
clear all
close all
%% Program for DFT
N=8;
x=[1 2 3 4 4 3 2 1];
for k=0:1:N-1;
for n=0:1:N-1;
p=exp(-j*2*pi*n*k/N);
x2(k+1,n+1)=p;
end;
end;
y=x*x2;
disp(y);
stem(x,y);
xlabel('time period')
ylabel('amplitude');
title('DFT of the sequence');

%% Program for IDFT


N=8;
x=[1 2 3 4 4 3 2 1];
for k=0:1:N-1;
for n=0:1:N-1;
p=exp(j*2*pi*n*k/N);
x1(k+1,n+1)=p;
end;
end;
y=(x*x1)/N;
disp(y);

Ashok Chakravarthy Pamarthy

PPDCET_ECE_SSP

stem(x,y);
xlabel('time period');
ylabel('amplitude');
title('IDFT of the sequence');

%% Program for FFT using keyword


N=8;
x=[1 2 3 4 4 3 2 1];
z=fft(x,N);
stem(x,z);
xlabel('time period');
ylabel('amplitude');
title('DFT of the sequence using keyword');

%% Program for IFFT using keyword


N=8;
x=[1 2 3 4 4 3 2 1];
z=ifft(x,N);
stem(x,z);
xlabel('time period');
ylabel('amplitude');
title('IDFT of the sequence using keyword');

Result: - Hence the DFT & IDFT of the given sequence has been found and plotted using
MATLAB

Ashok Chakravarthy Pamarthy

PPDCET_ECE_SSP

Outputs: FFT
Columns 1 through 4
20.0000

-5.8284 - 2.4142i

0.0000 - 0.0000i -0.1716 - 0.4142i

Columns 5 through 8
0 - 0.0000i -0.1716 + 0.4142i -0.0000 - 0.0000i -5.8284 + 2.4142i

Ashok Chakravarthy Pamarthy

10

PPDCET_ECE_SSP

IFFT
Columns 1 through 4
2.5000

-0.7286 + 0.3018i

0.0000 + 0.0000i -0.0214 + 0.0518i

Columns 5 through 8
0 + 0.0000i -0.0214 - 0.0518i -0.0000 + 0.0000i -0.7286 - 0.3018i

Ashok Chakravarthy Pamarthy

11

PPDCET_ECE_SSP

EXPERIMENT NO.2
PROGRAM TO VERIFY INTERPOLATION & DECIMATION OF A GIVEN SEQUENCE
Aim: -To write a MATLAB program to verify INTERPOLATION and DECIMATION of a given
sequence.
Software used: -MATLAB 7.5
Program: %% Clearing and Closing commands
clc
clear all
close all
%% Program for Interpolation
t=0:0.05:2;
x=cos(2*pi*t);
y=interp(x,2);
t2=interp(t,2);
subplot(2,1,1)
stem(t,x)
xlabel('Number of Namples');
ylabel('Amplitude')
title('Input Sequence')
subplot(2,1,2)
stem(t2,y)
xlabel('Number of Samples');
ylabel('Amplitude')
title('Interpolated Sequence')
%% Program for Decimation
t=0:0.05:2;
x=cos(2*pi*t);
y=decimate(x,2);
t1=decimate(t,2);
subplot(2,1,1)
stem(t,x)
xlabel('Number of Samples');
ylabel('Amplitude')
title('Input Sequence')
subplot(2,1,2)

Ashok Chakravarthy Pamarthy

12

PPDCET_ECE_SSP

stem(t1,y)
xlabel('Number of Samples');
ylabel('Amplitude')
title('Decimated Sequence')
Result: - Hence the INTERPOLATION and DECIMATION of a given sequence has been verified
using MATLAB

Ashok Chakravarthy Pamarthy

13

PPDCET_ECE_SSP

Outputs: -

Ashok Chakravarthy Pamarthy

14

PPDCET_ECE_SSP

EXPERIMENT NO.3
PROGRAM TO CONVERT CD DATA TO DVD DATA
Aim: -To write a MATLAB program to convert CD data to DVD data .
Software used: -MATLAB 7.5
Program: %% Clearing and closing commands
clc
clear all
close all
%% Program
[y, Fs, nbits] = wavread('type.wav');
disp('The sampling frequency is:');
Fs
disp('Number of bits per sample:');
nbits
disp('The length of the CD data is:');
length(y)
%%
p=interp(y,2);
Fs1=Fs*2;
disp('The sampling frequency is:');
Fs1
disp('Number of bits per sample:');
nbits
disp('The length of the DVD data is:');
length(p)
wavplay(y,Fs);
pause(2);
wavplay(p,Fs1);

Result:-Hence the data sampled at CD sampling rate is converted into DVD sampling rate has
been verified using MATLAB

Ashok Chakravarthy Pamarthy

15

PPDCET_ECE_SSP

Outputs: The sampling frequency is:


Fs =
11025
Number of bits per sample:
nbits =
8
The length of the CD data is:
ans =
4409
The sampling frequency is:
Fs1 =
22050
Number of bits per sample:
nbits =
8
The length of the DVD data is:
ans =
8818

Ashok Chakravarthy Pamarthy

16

PPDCET_ECE_SSP

EXPERIMENT NO.4
GENERATION OF DTMF (DUAL TONE MULTIPLE FREQUENCY) SIGNALS
Aim: -To write a MATLAB program for generation of DTMF signals.
Software used: -MATLAB 7.5
Program: %% Clearing and closing commands
clc
clear all
close all
%% Program
number=['9177857260','s'];
fs=8192;
T=0.5;
x=2*pi*[697,770,852,941];
y=2*pi*[1209,1336,1477];
t=[0:1/fs:T]';
tx=[sin(x(1)*t),sin(x(2)*t),sin(x(3)*t),sin(x(4)*t)]/2;
ty=[sin(y(1)*t),sin(y(2)*t),sin(y(3)*t)]/2;
for k=1:length(number)

switch number(k)

case'1'
tone=tx(:,1)+ty(:,1);
%

sound(tone);
stem(tone);
xlabel('No of Samples');
ylabel('Amplitude');
title('Dual Tone Multiple Frequency');

case'2'
tone=tx(:,1)+ty(:,2);
%

sound(tone);
stem(tone);
xlabel('No of Samples');
ylabel('Amplitude');

Ashok Chakravarthy Pamarthy

17

PPDCET_ECE_SSP

title('Dual Tone Multiple Frequency');

case'3'
tone=tx(:,1)+ty(:,3);
%

sound(tone);
stem(tone);
xlabel('No of Samples');
ylabel('Amplitude');
title('Dual Tone Multiple Frequency');

case'4'
tone=tx(:,2)+ty(:,1);
%

sound(tone);
stem(tone);
xlabel('No of Samples');
ylabel('Amplitude');
title('Dual Tone Multiple Frequency');

case'5'
tone=tx(:,2)+ty(:,2);
%

sound(tone);
stem(tone);
xlabel('No of Samples');
ylabel('Amplitude');
title('Dual Tone Multiple Frequency');

case'6'
tone=tx(:,2)+ty(:,3);
%

sound(tone);
stem(tone);
xlabel('No of Samples');
ylabel('Amplitude');
title('Dual Tone Multiple Frequency');

case'7'
tone=tx(:,3)+ty(:,1);

Ashok Chakravarthy Pamarthy

18

PPDCET_ECE_SSP

sound(tone);
stem(tone);
xlabel('No of Samples');
ylabel('Amplitude');
title('Dual Tone Multiple Frequency');

case'8'
tone=tx(:,3)+ty(:,2);
%

sound(tone);
stem(tone);
xlabel('No of Samples');
ylabel('Amplitude');
title('Dual Tone Multiple Frequency');

case'9'
tone=tx(:,3)+ty(:,3);
%

sound(tone);
stem(tone);
xlabel('No of Samples');
ylabel('Amplitude');
title('Dual Tone Multiple Frequency');

case'*'
tone=tx(:,4)+ty(:,1);
%

sound(tone);
stem(tone);
xlabel('No of Samples');
ylabel('Amplitude');
title('Dual Tone Multiple Frequency');

case'0'
tone=tx(:,4)+ty(:,2);
%

sound(tone);
stem(tone);
xlabel('No of Samples');
ylabel('Amplitude');

Ashok Chakravarthy Pamarthy

19

PPDCET_ECE_SSP

title('Dual Tone Multiple Frequency');

case'#'
tone=tx(:,4)+ty(:,3);
%

sound(tone);
stem(tone);
xlabel('No of Samples');
ylabel('Amplitude');
title('Dual Tone Multiple Frequency');

otherwise

disp('invalid number');
end;

pause(0.75);
end;

Result: -Hence the above DTMF signals has been generated and plotted using MATLAB
Output: -

Ashok Chakravarthy Pamarthy

20

PPDCET_ECE_SSP

EXPERIMENT NO.5
ESTIMATE THE PSD OF A NOISY SIGNAL USING PERIODOGRAM AND MODIFIED
PERIODOGRAM
Aim: -To write a MATLAB program to find out PSD using PERIODOGRAM and MODIFIED
PERIODOGRAM.
Software used: -MATLAB 7.5
Program: %% Clearing and closing commands
clc
clear all
close all
%% Declaring inputs
f1=1000;
f2=2000;
fs=4000;
%% Program for PERIODOGRAM
t=0:1/fs:1;
x=2*sin(2*pi*f1*t)+3*sin(2*pi*f2*t)+rand(size(t));
pxx1=abs(fft(x).^2);
pxx2=abs(fft(xcorr(x),length(t)));
subplot(2,1,1)
plot(t*fs,10*log10(pxx1));
xlabel('Frequency in Hertz:')
ylabel('Power in db:')
title('PSD using SQUARE MAGNITUDE METHOD')
subplot(2,1,2)
plot(t*fs,10*log10(pxx2));
xlabel('Frequency in Hertz:')
ylabel('Power in db:')
title('PSD using AUTOCORRELATION METHOD')

Program for MODIFIED PERIODOGRAM:


N=4;
n=0:1/fs:1;
x=sin(2*pi*f1*n)+sin(2*pi*f2*n)+rand(size(n));
y=abs(fft(x).^2);

Ashok Chakravarthy Pamarthy

21

PPDCET_ECE_SSP

subplot(2,1,1)
plot(n*fs,10*log10(y))
xlabel('Frequency in Hertz:')
ylabel('Magnitude in db:')
title('PSD using SQUARE MAGNITUDE METHOD');
w=hanning(N);
u=0;
for i=1:N;
u=u+(w(i).^2);
end
for i=1:N;
y1=[abs(fft(x).^2)*w(i).^2]/(u*N);
end
subplot(2,1,2)
plot(n*fs,10*log10(y1))
xlabel('Frequency in Hertz:')
ylabel('Magnitude in db:')
title('PSD using HANNING WINDOW');

Result: -Hence the estimation of PSD using PERIODOGRAM and MODIFIED PERIODOGRAM
has been verified using MATLAB

Ashok Chakravarthy Pamarthy

22

PPDCET_ECE_SSP

Outputs: - Periodogram

Modified Periodogram

Ashok Chakravarthy Pamarthy

23

PPDCET_ECE_SSP

EXPERIMENT NO.6
ESTIMATION OF POWER SPECTRUM USING BARTLETT AND WELCH METHODS
Aim: -To write a MATLAB program to estimate power spectrum using BARTLETT and WELCH
method.
Software used: -MATLAB 7.5
Program: %% Clearing and Closing commands
clc
clear all
close all
%% Declaring Inputs
fs=2000;
f1=200;
f2=400;
M=128;
Program for BARTLETT METHOD:
t=0:1/fs:1;
x=2*sin(2*pi*f1*t)+2*sin(2*pi*f2*t)+rand(size(t));
L=length(x);
K=L/M;
y1=[];
for i=1:M:L-M
y2=abs(fft(x(i:i+M)).^2);
y1=[y1;y2];
end
y3=sum(y1);
w1=y3/K;
w12=10*log(w1);
fs1=(fs/K)+2;
t1=((1:fs1)/fs1);
plot(t1,w12)
xlabel('Normalized Frequency')
ylabel('PSD')
title('BARTLETT METHOD of Power Spectral Estimation');

Ashok Chakravarthy Pamarthy

24

PPDCET_ECE_SSP

Program for WELCH METHOD:


t=0:1/fs:1;
x=2*sin(2*pi*f1*t)+2*sin(2*pi*f2*t)+rand(size(t));
L=length(x);
K=L/M;
w=hann(M+1);
m=0;
su=[];
for i=1:M/2:L-M+1
g=w'.*x(i:M+i);
w2=abs(fft(g).^2);
su=[su;w2];
end
su1=sum(su);
f=sum(w.^2);
w1=su1/f;
w12=10*log(w1);
fs1=(fs/K)+2;
t1=((1:fs1)/fs1);
plot(t1,w12)
xlabel('Normalized Frequency')
ylabel('PSD')
title('WELCH METHOD of Power Spectral Estimation');

Result: -Hence the estimation of PSD using BARTLETT and WELCH method has been verified
using MATLAB

Ashok Chakravarthy Pamarthy

25

PPDCET_ECE_SSP

Outputs: - Bartlett Method

Welch Method

Ashok Chakravarthy Pamarthy

26

PPDCET_ECE_SSP

EXPERIMENT NO.7
ESTIMATION OF POWER SPECTRUM USING PARAMETRIC METHODS
(YULE-WALKER & BURG)
Aim:-To write a MATLAB program to estimate power spectrum using Power Spectrum using
YULE-WALKER and BURG method.
Software used: -MATLAB 7.5
Program: %% Clearing and Closing commands
clc
clear all
close all
Program for BURG method:
a=[1 -2.2137 2.9408 -2.1697 0.9609];
randn('state',1);
x=filter(1,a,randn(256,1));
pburg(x,4);
xlabel('Normalized Frequency');
ylabel('Power Sectrum in db');
title('BURG method of Power Spectrum Estimation');

Program for YULE WALKER method:


a=[1 -2.2137 2.9408 -2.1697 0.9609];
randn('state',1);
x=filter(1,a,randn(256,1));
pyulear(x,4);
xlabel('Normalized Frequency');
ylabel('Power Spectrum in db');
title('YULE-WALKER method of Power Spectrum Estimation');

Result: -Hence the estimation of PSD using YULE-WALKER and BURG method has been
verified using MATLAB

Ashok Chakravarthy Pamarthy

27

PPDCET_ECE_SSP

Output: - Burg Method

Yule Walker Method

Ashok Chakravarthy Pamarthy

28

PPDCET_ECE_SSP

EXPERIMENT NO.8
DESIGN OF LPC FILTER USING LEVINSON-DURBIN ALGORITHM
Aim: -To write a MATLAB program to Design of LPC filter using LEVINSON-DURBIN Algorithm.
Software used: -MATLAB 7.5
Program: %% Clearing and Closing commands
clc
clear all
close all
%% Program
t=0:1023;
fs=1000;
x=sin(2*pi*50/fs*t)+sin(2*pi*120/fs*t);
y=x+rand(size(t));
p=10;
[a,g]=lpc(y,p);
a;
stem(a)
xlabel('Sequence ');
ylabel('Amplitude');
title('LPC filter coefficients');

Result: -Hence the Design of LPC filter using LEVINSON-DURBIN Algorithm has been verified
using MATLAB

Ashok Chakravarthy Pamarthy

29

PPDCET_ECE_SSP

Output: -

Ashok Chakravarthy Pamarthy

30

PPDCET_ECE_SSP

Das könnte Ihnen auch gefallen