Harmonic analysis of time series
4 views (last 30 days)
Show older comments
Hi all,
I want to make harmonic analysis for my time series data to see first (diurnal) and second harmonic (semi diurnal variation). I simply tried the following code:
xxx = 0:1:23;
asc = Hour';
dec = xxx';
%FFT
d = fft(dec);
m = length(dec);
M = 3;
a0 = d(1)/m;
an = 2*real(d(2:M))/m;
bn = -2*imag(d(2:M))/m;
n = 1:length(an);
y1 = a0 + 0*cos(2*pi*1*x/23)+0*sin(2*pi*1*x/23);
y2 = a0 + an(1)*cos(2*pi*n(1)*x/23)+bn(1)*sin(2*pi*n(1)*x/23);
y3 = a0 + an(2)*cos(2*pi*n(2)*x/23)+bn(2)*sin(2*pi*n(2)*x/23);
y4 = a0 + an*cos(2*pi*n'*x/23) ...
+ bn*sin(2*pi*n'*x/23);
It seems ok, howewer in Statistical Methods in the Atmospheric Sciences book, the author use another method:
I want to make harmonic analysis using this equation and compare with the above code. Are there any body having experience with this question in Matlab?
Thank you for sharing.
Edward
0 Comments
Answers (0)
See Also
Categories
Find more on Oceanography and Hydrology in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!