0% found this document useful (0 votes)
8 views3 pages

Discrete Fourier Transform Implementation

The document outlines a sample implementation of the discrete Fourier transform (DFT) for a sequence of complex numbers. It includes the definition of DFT, a MATLAB code snippet to compute the DFT of a sine wave, and plots for both the original signal and its magnitude spectrum. The implementation demonstrates how to manually compute the DFT and visualize the results.

Uploaded by

José Romo
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)
8 views3 pages

Discrete Fourier Transform Implementation

The document outlines a sample implementation of the discrete Fourier transform (DFT) for a sequence of complex numbers. It includes the definition of DFT, a MATLAB code snippet to compute the DFT of a sine wave, and plots for both the original signal and its magnitude spectrum. The implementation demonstrates how to manually compute the DFT and visualize the results.

Uploaded by

José Romo
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

Sample DFT Implementation

Definiton

The discrete Fourier transform transforms a sequence of N complex numbers

into another sequence of complex numbers, , which is defined by:

(Eq.1)

The transform is sometimes denoted by the symbol , as in or or

bufferSize = 140; % Number of samples


fs = bufferSize; % Sampling frequency (samples per second)

t = linspace(0, 1, bufferSize); % Time vector spanning 1 second


f = 10;
x = sin(2*pi*f*t); % Generate sine wave

% Compute DFT manually


X = zeros(1, bufferSize);
for k = 1:bufferSize
for l = 1:bufferSize
X(k) = X(k) + x(l) * exp(-1i * 2 * pi * (k-1) * (l-1) / bufferSize);
end
end

% Compute frequency axis (first half of spectrum)


freqs = (0:bufferSize/2-1) * (fs / bufferSize);

% Plot original signal


figure;
plot(t, x);
title('Original Signal');
xlabel('Time (s)');
ylabel('Amplitude');

1
% Plot properly scaled magnitude spectrum
figure;
plot(freqs, abs(X(1:bufferSize/2)));
title('Magnitude Spectrum');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
grid on;

2
3

You might also like