n – point dft and idftuserspages.uob.edu.bh/mangoud/mohab/courses_files/dsp7_2_msc.pdf · table...

12
N – Point DFT and IDFT Verifying : Examples 5.1 and 5.2

Upload: lekiet

Post on 13-May-2018

221 views

Category:

Documents


2 download

TRANSCRIPT

N – Point DFT and IDFT

Verifying : Examples 5.1 and 5.2

1

L point circular conv.linear

IDFTDFT

Ge[k] ● He[k] yL[n]IDFT

% Program 5_4% Linear Convolution Via the DFT% Read in the two sequences

>> Program_5_4Type in the first sequence = [1 2 0 1]Type in the second sequence = [2 2 1 1]% Read in the two sequences

x = input('Type in the first sequence = ');h = input('Type in the second sequence = ');% Determine the length of the result of

l ti 6Result of DFT-based linear convolution

Type in the second sequence = [2 2 1 1]

convolutionL = length(x)+length(h)-1;% Compute the DFTs by zero-paddingXE = fft(x,L); HE = fft(h,L); 2

4

6

Am

plitu

de

XE fft(x,L); HE fft(h,L);% Determine the IDFT of the producty1 = ifft(XE.*HE);% Plot the sequence generated by DFT b d l ti d

0 1 2 3 4 5 60

2

Time index n

A

15x 10-15 Error sequence

DFT-based convolution and% the error from direct linear convolutionn = 0:L-1;subplot(2,1,1) 0.5

1

1.5

Am

plitu

de Results from the finite precision arithmatic of fft

subp o ( , , )stem(n,y1)xlabel('Time index n');ylabel('Amplitude');title('Result of DFT-based linear convolution')2 ( h)

0 1 2 3 4 5 60

Time index n

y2 = conv(x,h);error = y1-y2;subplot(2,1,2)stem(n,error)( , )xlabel('Time index n');ylabel('Amplitude')title('Error sequence')