Build in FFT compared to FT Equation

1 view (last 30 days)
cterjesen
cterjesen on 14 Oct 2015
Answered: Walter Roberson on 14 Oct 2015
How can I compare the built in FFT in Matlab to the actual Fourier Transform Equation?
The first graph displays the frequency. Second graph is using the built in FFT in Matlab. Third graph should plot the signal using the Fourier Transform Equation.
fs = 10000; %Sampling Frequency
ts = 1/fs; %Sampling Time
N = 10000; %Length of Signal
n = (0:N-1)*ts; %Time
X = 100; %Frequency of Signal
xsig = sin(2*pi*X*n);
subplot(3,1,1)
plot(n,xsig);
grid on;
axis([0 0.1 -2 +2])
xlabel('Time');
ylabel('Amplitude');
title('Frequency');
subplot(3,1,2)
plot(abs(fft(xsig)))
title('Time');
axis([0 500 0 6000]);
xlabel('Frequency');
ylabel('Magnitude');
for k = 1:N
X(k) = (1/N)*sum(x(n) * exp(-1i*2*pi*(k-1)*(n-1)/N)' );
end
subplot(3,1,2)
plot(abs(X(k))
title('Time');
xlabel('Frequency');
ylabel('Magnitude');

Answers (1)

Walter Roberson
Walter Roberson on 14 Oct 2015
You will need to either compute the transform elsewhere and implement it, or else use the Symbolic Toolbox to calculate the transform, and then substitute specific numeric data into that in order to plot it.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!