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!


