Question on usage of fft
1 次查看(过去 30 天)
显示 更早的评论
I have a function F(t) = 1 + 2*sin(pi*t/180);
So it has one harmonic.
If I do
TestFFT = fft(F(t),5); % Asking for 5 harmonics.
The first one should be simply 2 a constant.
I get 5.5232 and this number keeps changing with the number of harmonics I ask for. I am not familiar with all this, hence question. Please help with correct usage of fft command. Thanks.
0 个评论
采纳的回答
Image Analyst
2018-9-17
You need to create a digital representation of the function. For example specify t then create F, then call FFT
t = 1 : 1000; % Whatever...
period = 360; % Whatever you want.
F = 1 + 2 * sin(2 * pi * t / period);
ft = fft(F); % FFT of entire signal.
subplot(1, 2, 1);
plot(real(ft), 'b-', 'LineWidth', 2);
grid on;
title('Real Part', 'FontSize', 20);
subplot(1, 2, 1);
plot(imag(ft), 'b-', 'LineWidth', 2);
grid on;
title('Imaginary Part', 'FontSize', 20);
The 5 you put in is not the number of harmonics like you're thinking about them. It's the number of elements in the transform. If you use 5 that may be too low resolution to even see your signal clearly and way too low to see your harmonics. Use more resolution and look for the spikes in the FFT signal. These will be at multiples of the (1/period) frequency.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!