# Fourier decomposition in Matlab

I am doing a Fourier decomposition of sea level series ( to find out one particular contribution within the sea level height). it should be applied subsequently on shifted (by one hour) windows of 96 hours length. I have already the a, b as the following:

where x is the sea level series (hourly dataset)

As a start I tried to code only the first time window as the following code to simplify the coding because I am just a beginner in Matlab but unfortunately I am getting wrong results as the amplitude is higher than the actual sea level here is my code so far

hour_window = 96 ; T= 19,8 ; f = 1 / T ; % sea_level is a vector of the first 96 values ( as I am doing only the first interval)

for j = 0: hour_window -1 a = sealevel .* cos(2*pifj) ./ cos(2*pifj).^2 ; b= sealevel .* sin(2*pifj) ./ sin(2*pifj).^2 ; end A = sqrt(a.^2 + b^.2) ; phase= atan2(a,b) ;

I would really appreciate any help thanks in advanced

• Can I please ask what are these a,b? Are these specific quantities to the problem you are dealing with or do you see these as corresponding to the standard outputs of the Discrete Fourier Transform? – A_A Feb 21 '19 at 12:34
• Seems like these $a$ and $b$ are the real and imaginary parts (respectively) of a normalized DFT. – anpar Feb 22 '19 at 11:06