0% found this document useful (0 votes)
11 views14 pages

DSP File

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)
11 views14 pages

DSP File

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/ 14

ational Reha

a N bil
isr ita
la M t

io
ta

nU
kun

niv
Dr Sha

ersity
Lucknow, Uttar Pradesh

Digital Signal Processing Lab File

Submitted by Submitted To

Name :- Mr. Vinay Singh


Branch :-
Semester :-
Subject Code :-

Date :- Teacher Signature


INDEX

PROGRAMS Page No. Remark

1.GENERATION, ANALYSIS AND PLOTS


OF DISCRETE TIME SIGNALS.
> Unit Step Signal
> Impulse Signal
> Ramp Signal
> Exponential Signal
> Sin Signal

2. IMPLEMENTATION OF OPERATIONS ON
SEQUENCES (ADDITION, MULTIPLICATION,
FOLDING)
> Addition of two sequences
> Multiplication of two sequences
> Folding operation on sequence

3. PLOT THE RESPONSE FOR DIFFERENTIAL


EQUATION
> Impulse Response
y(n)-0.6y(n-1)+0.08y(n-2)=x(n)
> Unit step Response:
y(n)=0.7y(n-1)+0.12y(n-2)=x(n-1)+x(n-2)
> Pole Zero Plot of
y(n)-0.6y(n-1)+0.08y(n-2)=x(n)

4. LINEAR/CIRCULAR CONVOLUTION OF TWO


SEQUENCES.
> Linear convolution of two sequences
> Circular convolution of two sequences

5. COMPUTATION AND PLOT OF N-POINT DFT


OF A GIVEN SEQUENCE
PROGRAM 1

GENERATION, ANALYSIS AND PLOTS OF DISCRETE


TIME SIGNALS

A.Unit Step Signal:


MATLAB SCRIPT
n=-49:49;
u=[zeros(1,49),ones(1,50)];
stem(n,u)
Result :-

B.Impulse Signal:
MATLAB SCRIPT
n=-49:49;
delta=[zeros(1,49),1,zeros(1,49)];
C.Ramp Signal:
MATLAB SCRIPT
n=0:10;
r=n;
stem(n,r)
Result :-

D.Exponential Signal:
MATLAB SCRIPT
c=1; alpha=0.8; n=-10:10;
x=c*alpha.^n;
stem(n,x)
Result :-
E. Sin Signal:
MATLAB SCRIPT
n=-18:18;
f=1/12;
stem(n,sin(2*pi*f*n))
Result :-
PROGRAM 2

IMPLEMENTATION OF OPERATIONS ON SEQUENCES


(ADDITION, MULTIPLICATION, FOLDING)

A. Addition of two sequences


MATLAB SCRIPT
n=-3:3;y1=[1,3,5,6,7,9,2];y2=[2,4,7,2,9,5,6];
y3=y1+y2;
stem(n,y3)
Result :-

B.Multiplication of two sequences


MATLAB SCRIPT
n=-3:3; y1=[1,3,5,6,7,9,2]; y2=[2,4,7,2,9,5,6];
y3=y1.*y2;
stem(n,y3)
Result :-
C.Folding operation on sequence
MATLAB SCRIPT
n=-3:3;
y1=[1,3,5,6,7,9,2];
y2=fliplr(y1); stem(n,y2)
Result :-
PROGRAM 3

PLOT THE RESPONSE FOR DIFFERENTIAL EQUATION


A. Impulse Response y(n)-0.6y(n-1)+0.08y(n-2)=x(n)
MATLAB SCRIPT
n=0:20;
x=[1,zeros(1,20)];
a=[1]; b=[1 -0.6 0.08];
y=filter(a,b,x); stem(n,y)
Result :-

B. Unit step Response:


y(n)=0.7y(n-1)+0.12y(n-2)=x(n-1)+x(n-2)
with initial condition y(-1) =1,y(-2)=1
MATLAB SCRIPT
n=0:20; x=[ones(1,21)];
a=[0 1 1]; b=[1 -0.7 .12];
y0=[1 1]; ic=filtic(a,b,y0);
y=filter(a,b,x,ic); stem(n,y)
Result :-
C.Pole Zero Plot of y(n)-0.6y(n-1)+0.08y(n-2)=x(n)
MATLAB SCRIPT
a=[1];
b=[1 -0.6 0.08];
zplane(a,b)
Result :-
PROGRAM 4

LINEAR/CIRCULAR CONVOLUTION OF TWO


SEQUENCES.
A. Linear convolution of two sequences
MATLAB SCRIPT
clc;clear all;close all;
x=input('Enter x[n]:');
nx=0:length(x)-1;
h=input('Enter h[n]:');
nh=0:length(h)-1;
z=conv(x,h);
nz=0:length(z)-1;
subplot(3,1,1);
stem(nx,x);
title('Input sequence x[n]');
subplot(3,1,2);
stem(nh,h);
xlabel('Time');ylabel('Amplitude');
title('Impulse response of the system h[n]');
subplot(3,1,3);
stem(nz,z);
xlabel('Time');ylabel('Amplitude');
title('Linear Convolution');
Enter: x[n]:[1 2 3 1];
h[n]:[1 2 1 -1];

Result :-
B. Circular convolution of two sequences
MATLAB SCRIPT
clc;clear all;close all;
x=input('Enter x[n]:');
h=input('Enter h[n]:');
xl=length(x);
hl=length(h);
m=max(xl,hl);
z=ifft(fft(x,m).*fft(h,m));
zl=length(z);
%Plots nx=0:xl-1;
nh=0:hl-1;
nz=0:zl-1;
subplot(3,1,1);
stem(nx,x);
xlabel('Time');ylabel('Amplitud')
title('Input sequence x[n]');
subplot(3,1,2);
stem(nh,h);
xlabel('Time');
ylabel('Amplitude
title('Impulse response of the system h[n]');
subplot(3,1,3);
stem(nz,z);
xlabel('Time');
ylabel('Amplitude)
title('Circular Convolution');
Enter x[n]:[2 1 2 1];
h[n]:[1 2 3 4]

Result :-
PROGRAM 5

COMPUTATION AND PLOT OF N-POINT DFT OF A


GIVEN SEQUENCE

MATLAB SCRIPT

clc;clear all;close all;


x=input('Enter x[n]:');
nx=0:length(x)-1;
N=4;
%Compute DFT
n=0:length(x)-1;
for k=0:N-1
w=exp(-j*2*pi*k*n/N);
dot_prod=x.*w;
X(k+1)=sum(dot_prod);
end
%Plot the input
subplot(3,1,1);
stem(nx,x);
xlabel('Time');ylabel('Input x[n]');
title('Input sequence x[n] ');
title('Computation of DFT ');
%Plot the magnitude spectrum
subplot(3,1,2);
stem(abs(X));
xlabel('Time');ylabel('Amplitude');
title('Magnitude Spectrum');
%Plot the phase spectrum
subplot(3,1,3);
stem(angle(X));
xlabel('Time');ylabel('Angle in radian');
title('Phase Spectrum');
Enter X[n]: [1 2 3 0]
Result :-

You might also like