Lab Task-3 Digital Signal Processing

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

LAB TASK-3

Digital Signal Processing


Description:
 To find the twiddle factor matrix used for computing the DFT.
 Further we have to vectorize the code in MATLAB.
 Finding W^1 and W^H and checking scaling factor.
 Finding (W)*(W^H)
 Finding IDFT
MATLAB CODE:
%%DFT computation
clc; close all;
N=8;
x = [1 2 3 4 5 6 7 8]; %input signal x(n)
%X denotes the DFT answer
%for k=1:N
%X(k)=0;
%for n=1:N
%X(k)=X(k)+x(n)*exp-j*2*pi/N*(n-1)*(k-1)
%end
%end
%alternate method
for k=0:N-1
X(k+1)=0;
for n=0:N-1
X(k+1)=X(k+1)+x(n+1)*exp(-1i*2*pi/N*n*k);
end
end
%%alternate method for DFT computation
D=dftmtx(N);
Y = D*x';
%%Another method for DFT computation
z=fft(x,N);
%%Vectorization
k=0:N-1;
n=0:N-1
Wvec=exp(-1i*2*pi/N*n'*k);
y=ifft(x,N)
INVERSE DFT OUTPUT

DESCRIPTION:
 To find the DFT upto 10 points.
 Input x(n) is given.
 Using Inbuilt command dftmtx

MATLAB CODE:
clc;
clear all;
close all;
n=0:9;
x1=[1 zeros(1,9)];
X1=dftmtx(10)*x1'
x2=[ones(1,10)];
X2=dftmtx(10)*x2'
x3=exp(j*2*pi*n/10);
X3=dftmtx(10)*x3'
x4=cos(2*pi*n/10);
X4=dftmtx(10)*x4'

OUTPUT:

CONCLUSION:
DFT computation is determined up to 10 points and result is verified.
DESCRIPTION:
 Input x(n) and response h(n) are given.
 To verify Linear convolution using inbuilt command conv(x,h)
and circular convolution using inbuilt command cconv(x,h,n)
 L = 6, V = 3

MATLAB CODE:
clc;
clear all;
close all;
x=[1 2 3 4 5 6];
h=[2 1 3 1];
display('Linear convolution=')
conv(x,h)
display('Circular convolution=')
cconv(x,h,6)

OUTPUT:
CONCLUSION:
 Linear convolution and circular convolution has been verified.
 Output sequence consists of L+V
 Cconv = { 27,28,17,25,32 }
 The size of cconv sequence is [1 , 6].

Q3.
Parts C. and D.
MATLAB CODE:
clc;
clear all;
close all;
x=[4 5 6 1 2 3 4 5 6];
h=[2 1 3 1];
display('Linear convolution=')
conv(x,h)
display('Circular convolution=')
cconv(x,h,6)

CONCLUSION:
 Linear convolution and circular convolution of the extended
sequence has been verified.
 There will be only L+V samples in the Output sequence.
 The middle part of the linear convolution sequence will be same
as the circular convolution of part b

You might also like