Hi
I'm trying to apply fft() to the spectrum analysis of a financial time series with 2608 (10 years) data with daily frequency... Can anyone suggest me how can I calculate freq and Pyy vectors from fft()?
Regards Marco

 Réponse acceptée

Wayne King
Wayne King le 29 Juin 2012
Modifié(e) : Wayne King le 29 Juin 2012

0 votes

Below is an example.
t = 0:2607;
% just an example
% put a sine wave with a period of 120 days and add noise
x = cos(2*pi/120*t)+randn(size(t));
xdft = fft(x);
% because the length is even take the first N/2+1 points
xdft = xdft(1:length(x)/2+1);
Pyy = 1/length(x)*abs(xdft).^2;
% create frequency vector
df = 1/2608;
% frequencies in cycles/day
freq = 0:df:1/2;
plot(freq,10*log10(Pyy));
xlabel('cycles/day'); ylabel('dB/cycle/day');
% find maximum value
[maxval,index] = max(abs(xdft));
% frequency corresponding to maximum value
freq(index)

3 commentaires

Marco
Marco le 29 Juin 2012
Hi Wayne King, thanks a lot for your help
bye, Marco
Virgil Stokes
Virgil Stokes le 7 Fév 2019
How can you be certain that aliasing has not occurred?
Bjorn Gustavsson
Bjorn Gustavsson le 7 Fév 2019
...and why run an fft on financial data - that most certainly isn't even remotely stationary.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Fourier Analysis and Filtering 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!

Translated by