P. 1
Mathematics of the Discrete Fourier Transform

Mathematics of the Discrete Fourier Transform

4.88

|Views: 1,530|Likes:
Published by Ugras SEVGEN

More info:

Published by: Ugras SEVGEN on Feb 14, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

02/22/2013

pdf

text

original

Below is the Matlab for Fig. 7.3:

% Parameters (sampling rate = 1)

N = 16;

% DFT length

k = N/4;

% bin where DFT filter is centered

wk = 2*pi*k/N;

% normalized radian center-frequency for DFT_k()

wStep = 2*pi/N;

w = [0:wStep:2*pi - wStep]; % DFT frequency grid

interp = 10;

N2 = interp*N;

% Denser grid showing "arbitrary" frequencies

w2Step = 2*pi/N2;

w2 = [0:w2Step:2*pi - w2Step]; % Extra dense frequency grid

X = (1 - exp(j*(w2-wk)*N)) ./ (1 - exp(j*(w2-wk)));

% slightly offset to avoid divide by zero at wk

X(1+k*interp) = N; % Fix divide-by-zero point (overwrite "NaN")

% Plot spectral magnitude

clf;

magX = abs(X);

magXd = magX(1:interp:N2); % DFT frequencies only

subplot(2,1,1);

plot(w2,magX,’-’); hold on; grid;

plot(w,magXd,’*’);

% Show DFT sample points

title(’DFT Amplitude Response at k=N/4’);

xlabel(’Normalized Radian Frequency (radians per sample)’);

ylabel(’Magnitude (Linear)’);

text(-1,20,’a)’);

% Same thing on a dB scale

magXdb = 20*log10(magX);

% Spectral magnitude in dB

% Since the zeros go to minus infinity, clip at -60 dB:

magXdb = max(magXdb,-60*ones(1,N2));

magXddb = magXdb(1:interp:N2); % DFT frequencies only

subplot(2,1,2);

hold off; plot(w2,magXdb,’-’); hold on; plot(w,magXddb,’*’); grid;

DRAFT of “Mathematics of the Discrete Fourier Transform (DFT),” by J.O.
Smith, CCRMA, Stanford, Winter 2002. The latest draft and linked HTML
version are available on-line at http://www-ccrma.stanford.edu/~jos/mdft/.

Page 142

7.4. MATLAB EXAMPLES

xlabel(’Normalized Radian Frequency (radians per sample)’);

ylabel(’Magnitude (dB)’);

text(-1,40,’b)’);

print -deps ’../eps/dftfilter.eps’;

hold off;

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->