Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
6 views18 pages

DSP Lab Manual

The document outlines a series of experiments related to signal processing, including generating sinusoidal waveforms, calculating Discrete Fourier Transform (DFT), Inverse DFT, frequency response, Fast Fourier Transform (FFT), power spectrum determination, filtering, decimation, interpolation, and sampling rate conversion. Each experiment includes a MATLAB program, input parameters, and results with graphical representations. The experiments demonstrate various signal processing techniques and their implementations using MATLAB.

Uploaded by

Jr Tyson
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)
6 views18 pages

DSP Lab Manual

The document outlines a series of experiments related to signal processing, including generating sinusoidal waveforms, calculating Discrete Fourier Transform (DFT), Inverse DFT, frequency response, Fast Fourier Transform (FFT), power spectrum determination, filtering, decimation, interpolation, and sampling rate conversion. Each experiment includes a MATLAB program, input parameters, and results with graphical representations. The experiments demonstrate various signal processing techniques and their implementations using MATLAB.

Uploaded by

Jr Tyson
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/ 18

EXPERIMENT NO: 1

GENERATE SINUSOIDALWAVEFORM BASED ON


RECURSIVE DIFFERENCE EQUATIONS

PROGRAM:
clc;

clear all;

close all;

a-input('enter the amplitude of the signal ');

f-input(enter the frequency of the signal );


N=input('enter the number of cycles );
IFinput('enter the initial condition y(-1) );

T=1/f;
t-0:1/100*T:N*T:

x=a*sin(2*pi* f*);

y-zeros(1,length(t));

for

i=1:1:length(x)

y(i)=x(i)+l;

lFy();
end;
subplot(2,1,1);

plot(t,x);

xlabel('timet);

ylabel('amplitude');

title('sine signal );
subplot(2,1,2);

plot(t,y);

xlabel('timet);

ylabel('amplitude');

title(' sine signal generated byrecursive equation');

INPUT
enter the amplitudeof the signal 5
of the signal 200
enter the frequency
enter the number of cycles 5
enter the intial condition y(-1) 0
RESULT

4Figure 1
File Edit View Insert Tools Desktop Window Help

sine signal

0
amplitude
0 0.005 0.01 0.015 0.02 0.025
timet
sinusoidal signal generated
200 by recursive equation

150

100
amplitude
50

0 0.005 0.01 0.016 0.02 0.025


timet
EXPERIMENT NO: 2
DFT OF GIVEN DISCRETE TIME SIGNAL
PROGRAM:
%DFT function
clc;

clear all;
close all;

x=input('enter the values of input sequence);


N=input('enterthe npo int dft values');

IFlength(x);

if(N<I)
error('N should be>-);
end;
x1=[x zeros(1,(N-I))]

for k=0:1:N-1;

for n=0:l:N-1;

p-exp(-j*2*pi*n*k/N)
x2(n+1,ktl)-p;
end;
end;

y-(x1*x2);

psd-abs(y.*y)/N;
disp(the inputsequence is:);

disp(xl);
disp('the twiddle factor matrix is:);

disp(x2);
disp('the dft of x(n) is');

disp(y):

magnitude=abs(y);

phase-angle(y);
subplot(2,1,1);

stem(magnitude);
xlabel('frequency');
ylabel('magnitude');

title('magnitude plot);

subplot(2,1,2);
stem(phase);

xlabel(frequency');

ylabel('phase');
title(phase plot');
INPUT:
Enter the sequence:|1 1 2 3]
Enter the value ofN:4

The DFT of the given sequence is


7.0000 -1.0000 + 2.0000i -1.0000 - 0.0000i -1.0000 2.00001

-
The corresponding magnitude vector
is

7.0000 2.2361 1.0000 2.2361

The corresponding phase vector is

0 116.5651 -180.0000 -116.565 1

RESULT:

Figure 1
File Edit View Insert Tools Desktop Window Help

Magnitude
magnitude
-0.5 05 1.5 2 2.5 35 4

Phase spectrum
100
phase
-100

-1 -0.5 0.5 1 1.5 2 2.5 3.5 4

k
EXPERIMENT NO: 3
IDFT OF GIVEN DISCRETE TIME SIGNAL
PROGRAM:
%1DFT function

cle:

clear all:

close all;

x=input('enter the values of input sequence');

N=input(enter the npo int dft values');

I=length(x);

if(N<I)

error(N should be >=):


end;

x1=[x zeros(1,(N-I)]
for k=0:1:N-1:

for n=0:1:N-1:

p-exp(j*2*pi*n*k/N)
x2(n+1,k+l)-p:
end:
end:

y-(1/N)*(x1 *x2);
disp('the input sequence is:');

disp(xl);

disp('the twiddle factor matrix is:');

disp(x2);

disp('the idft of x(n) is');

disp(y);

magnitude=abs(y);
phase=angle(y):
subplot(2,1,1):
stem(magnitude):

xlabel(frequency);
ylabel('magnitude);
title('magnitude plot);

subplot(2,1,2);
stem(phase):
xlabel('frequency');

ylabel(phase):
title('phase plot);

INPUT:
Enter the sequence:[7.0000 -1.0000 + 2.0000i -1.0000 - 0.0000i -1.0000 - 2.000011

Enter the value ofN:4


The DFT ofthe given sequenceis 1.0000 1.0000 + 0.0000i 2.0000 - 0.0000i3.0000 -0.0000i
The correspondingmagnitude vector is 1 1 23
The corresponding phase vector is 1.0e-014 * 00.3836 -0.1754 -0.8607

RESULT:

Figure 1

File Edit View Insert Tools Desktop Window Help

Magnitude
magnitude
0
1 -0.5 0,5 1 1.5 2.5 3.5

X 10 Phase spectrun

2
phase
-1 -05 0,5 1.5 25 3.5
EXPERIMENT NO: 4
FREQUENCY RESPONSEOF A GIVEN SYSTEM
PROGRAM:
cle:

clear all:

close all:

w-pi:0.01:pi:
num-input('enter the numerator coefficient'):
den-input('enter the denominator coeficient'):

h-freqz(num,den, w);

magnitude-abs(h):
phase-angle(h);
subplot(2. 1,1):

plot(w,magnitude);
xlabel(frequency');:

ylabel('magnitude');

title('magnitude plot ':


subplot(2,1,2);
plot(w.phase):

xlabel(frequency');
ylabel('angle');

title('phase plot');

INPUT:
enter the numeratorcocfficient[1 34 5]
enter the denominator coefficient|3 -2 -67|

RESULT:
4Figure
1
Edit View Insert Tocls Desktop Window
File
Help
Maimze

magnitude plot
magnitude
4 -3 -2 -1 2
frequency
phase plot

2
engie
-2 -1 0 3
frequency
EXPERIMENT NO:5
IMPLEMENTATION OF FFT FOR A GIVEN SEQUENCE
PROGRAM:
cle;

clear all;

close all;

xinput(enter the values of input


sequence );
N=input(enter the npoint fft values');
-length(x);
if(N<I)

error('N should be >-l);


end:

xI=[x,zeros(1,(N-I)]
y-fit(x1,N)

magnitude-abs(y);
phase-angle(y);
disp('the input sequence x(n)
is');
disp(xl);

disp(the fft ofxl is y);


disp(y):

subplot(2,1,l);

stem(magnitude):grid;
xlabel('frequency');

ylabel('magnitude');
tit le ('magnitude plot');

subplot(2,1,2);

stem(phase):grid;
xlabel(frequency');
ylabel('phase');

title('phase plot');

FFT INPUTS
enter the values of input
sequence [1 2345 6 7 8]
enter the npoint fi values8

the input sequence x(n) is 1 2345 678


the fft ofxl is y
Columns through 6 1

36.0000+ 0.0000i -4.0000 +9.6569i -4.0000 + 4.00001 -4.0000 +1.6569i -4.0000 +0.00001
4.0000 - 1.6569i
Columns 7 through 8
-4.0000- 4.00001 -4.0000-9.6569i
RESULT:

A Figure1

File Edit View Insert Tools Descop Windon Help

magnitudeplot
40

30

20
magnitude
10

2 4 5 7
1
frequenc

phase plot

2
phase
2
6 7
1 2
frequency
EXPERIMENT NO:6
DETERMINATION OF POWER SPECTRUM OF A SIGNAL
PROGRAM:
cle:

close all:
clear all:

x=input(enter the scquence'):


N=length(X):
n=0:1:N-1;
y=xcorr(x,x):

subplot(3, 1,1):

stem(n,x):

xlabel(' n-y label('Amplitude--->);


title('input seq):
subplot(3,1,2):

N=length(y):
n-0:1:N-1;

stem(n.y):

xlabel('n-.)y label('Amplitude--.);
title('autocorr seq for input'):
disp('autocorr seq for input');

disp(y)

P-fft(y,N):
subplot(3,1,3);
stem(n, P):

xlabel('K---)ylabel('Amplitude--->);
title('psd of input');
disp(the psd function:);

disp(P)

INPUT:
enter the values of input sequence [1 2 3 4 567 8]
enter the npoint fi values&
the input sequence x(n)is
12345678
the psd ofxl is
162.0000 13.6569 4.0000 2.3431 2.0000 2.3431 4.0000 13.6569
RESULT:

Figure 1

File Edit View Insert Tools Desktop Window Help

40 magnitude plot

20

1 2 3 4 5 6 7 8
frequency

200 power spectrum of x(n)

100

1 2 3 4 5 6 7 8
EXPERIMENT NO: 7
THROUGH
GENERATION OF SINUSOIDALSIGNAL
FILTERING

PROGRAM:

close all;

clear all;

clc;

b-[1]:
a-[1,-1,0.9]:

n=[-20:120];
t-0:0.1:2*pi;

x=sin(t);

s=filter(b,a,x);

stem(t,s);

title('sinuso idalresponse');
xlabel('n');

ylabel('s(n));

RESULT:

sinusoidal response

1.5

05

(u) n

-0.5

2
EXPERIMENT NO: 8
IMPLEMENTATION OF DECIMATION PROCESS
PROGRAM:
%illustration of down sampling(decimation)
clear all;

N=50;
n=0:1:N-l;

X=sin(2*pi*n/20)+sin(2*pi*n/15):
M=2;
xl=x(1:M:N);
nl=1:1:N/M;
subplot(2,1,1);
stem(n,x);
xlabel('n');

ylabel('x'):

tit le('input signal');

subplot(2,1,2);
stem(n]-l,xl);
xlabel('n"):

ylabel('xl);

title('Down sampled sequence');

RESULT:

AFipure 1

Desktop Window Help


View Insert Tools
File
Edit
input signal

40 50
15 25
10
n

Down sampled sequence

20
15
10
EXPERIMENT NO: 9
IMPLEMENTATION OF INTERPOLATION PR0CESS
PROGRAM:
%illustration of up sampling(interpolation)

clear all;

N10:
n 0:l:N-1:

N=sin(2*pi"n/10)+sin(2*pi*n/5);
L-3:
NI-zeros(1.L*N)I
nl=1:1:L*N:

j-:LLN:
xI(-x:
subplot(2, 1, );
stem(n.x);

xlabel('n'):

ylabel('x';

tit le('input signal');

subplot(2, 1,2);

stem(nl,xl ):
xlabel('n'):

ylabel('x I):
title('up sample sequence'):

RESULT:

Figure 1

Edit View Insert Tools


File
Desktop Window Help

input signal

4 5 6

up sarnple sequence

ohooooooloeoooosoogeo
-14

10 16 20 25
EXPERIMENT NO: 10
ImplementationofVD
PROGRAM:
% Sampling Rate Converters
1lustration of
clf:clear all: Sampling Rate
cle: Alteration by a
Ratio of Two Integers
L=
M=input('Up-sampling
input factor =):
('Down-sampling factor
n=0:29; =):
X=
y= sin(2*pi*0.43*n) + sin(2*pi*0.31*n);
resample(x,L,M);
subplot(2,1,1);
stem(n,x(1:30)):
axis([0 29 -2.2 2.2]);
title(Input
Sequence');
xlabel(Time index n');

ylabel('Amplitude');
subplot(2,1,2);
m =0:(30*L/M)-1;
stem(m.y(1:30*L/M);
axis([0(30*L/M)-1 -2.2
2.21);
title('Output Sequence');

xlabel(Time index n');

ylabel('Amplitude');

INPUT:
Up-sampling factor =5
Down-sampling factor =2
RESULT:

Figure1
File Edit View Insert
Tools
Desktop
Window Helo

Input
Sequence

D
Anplitude
5 10
16
20
Tirne index n
Output Sequence
Amplitude
10 20 40 50 60 70
Time index n
EXPERIMENT NO: 11

IMPULSE RESPONSE OF FIRST ORDERSYSTEM


PROGRAM:
clc;

close all:

clear all:

n=0:10:

%impulse response of first order


system
b-(2 0 0];
a-[1 -0.9 0];

y-dimpulse(b,a,length(n));
subplot(2, 1,1);

stem(n,y);
xlabel('n---);

ylabel('amplitude');
tit le('impulse
response of first order system');

RESULT:

impulse response of first order


2@ T system

1.5

05

1 2
7 8
n---> 10
EXPERIMENT NO: 12
IMPULSE RESPONSE OF SECOND ORDERSYSTEM
PROGRAM:
clc;

close all:

clear all;

n=0:10;

oimpulse response of second order system


b-[1 0 0];
a-[1 0.6 0.8]:;

yl=dimpulse(b,a,length(n);
subplot(2, 1,2);

stem(n,yl);

xlabel('n---);
ylabel('amplitude');

title('impulse response of second order system');

RESULT:

impulse response of second order system


1@

0.5
amplitude
-0.5
t
-1

2 3 4 5 6 7
1
8 10
n---->

You might also like