Fast Fourier Transform function
显示 更早的评论
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!

采纳的回答
更多回答(1 个)
Mitch Lautigar
2022-5-5
1 个投票
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Discrete Fourier and Cosine Transforms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


