Question on usage of fft

1 Ansicht (letzte 30 Tage)
Pappu Murthy
Pappu Murthy am 17 Sep. 2018
Kommentiert: Pappu Murthy am 17 Sep. 2018
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.

Akzeptierte Antwort

Image Analyst
Image Analyst am 17 Sep. 2018
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.
  1 Kommentar
Pappu Murthy
Pappu Murthy am 17 Sep. 2018
I understand now. Thanks much for patiently explaining. I accept your answer.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Fourier Analysis and Filtering finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by