Fast Fourier Transform function
Afficher commentaires plus anciens
I tried to make a FFT of a sine wave but I didn't get what I expected.
t = 0:0.01:5; % time interval
w = 4*pi; % rad/s , so w = 2*pi*f, f=frequency
x = sin(w*t);
r = fft(x); % fast fourier transform function
R = real(r);
plot(R) % plotted only the real part of r
What I don't understand is that the only frequency should be 2 Hz, since f=w/(2*pi) = (4*pi)/(2*pi) = 2, but I get a total different value.
Can anyone help me understand the result?
Thanks!

Réponse acceptée
Plus de réponses (1)
Mitch Lautigar
le 5 Mai 2022
1 vote
Couple things i'd like to comment on to try and help you. Please see bullets below.
- You're original graph is setup correctly, but i'd recommend the following change to allow for more samples and therefore better end results. "t = 0:0.01:5;" should probably be changed to "t = 0:0.001:5;"
- When you take the FFT, you need to set the axis up correctly. This is a common complexity in signals and systems, but looking at the MATLAB FFT command will help you set it up (https://www.mathworks.com/help/matlab/ref/fft.html).
Try these two tips, and if you are still stuck, let me know.
Catégories
En savoir plus sur Discrete Fourier and Cosine Transforms dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


