0
$\begingroup$

let's say that I have a set of data

EchoHannatoS1={{-0.010000000000005116`,0.`},{0.010000000000005116`,-0.0016729662767088105`},{0.030000000000001137`,-0.00624162900299196`},{0.04999999999999716`,-0.012853512800774878`},{0.06999999999999318`,-0.021545951369554405`},{0.09000000000000341`,-0.031181593750000076`},{0.10999999999999943`,-0.040817236130445744`},{0.12999999999999545`,-0.05189135257766407`},{0.15000000000000568`,-0.05912155849700829`},{0.1700000000000017`,-0.0637636364488487`},{0.18999999999999773`,-0.06536318750000025`},{0.20999999999999375`,-0.06136318750000025`},{0.23000000000000398`,-0.055363187500000244`},{0.25`,-0.04836318750000013`},{0.269999999999996`,-0.04336318750000023`},{0.29000000000000625`,-0.03936318750000023`},{0.3100000000000023`,-0.03936318750000023`},{0.3299999999999983`,-0.03936318750000023`},{0.3499999999999943`,-0.04336318750000023`},{0.37000000000000455`,-0.04736318750000024`},{0.39000000000000057`,-0.05336318750000024`},{0.4099999999999966`,-0.057363187500000246`},{0.4300000000000068`,-0.05936318750000025`},{0.45000000000000284`,-0.05936318750000025`},{0.46999999999999886`,-0.05936318750000025`},{0.4899999999999949`,-0.057363187500000246`},{0.5100000000000051`,-0.05436318750000013`},{0.5300000000000011`,-0.05036318750000013`},{0.5499999999999972`,-0.04736318750000024`},{0.5699999999999932`,-0.045363187500000235`},{0.5900000000000034`,-0.04336318750000023`},{0.6099999999999994`,-0.04136318750000023`},{0.6299999999999955`,-0.03836318750000012`},{0.6500000000000057`,-0.034363187500000114`},{0.6700000000000017`,-0.03136318750000022`},{0.6899999999999977`,-0.026363187500000107`},{0.7099999999999937`,-0.023363187500000215`},{0.730000000000004`,-0.0203631875000001`},{0.75`,-0.0183631875000001`},{0.769999999999996`,-0.0183631875000001`},{0.7900000000000063`,-0.0183631875000001`},{0.8100000000000023`,-0.019363187500000212`},{0.8299999999999983`,-0.023363187500000215`},{0.8499999999999943`,-0.02836318750000011`},{0.8700000000000045`,-0.034363187500000114`},{0.8900000000000006`,-0.04236318750000012`},{0.9099999999999966`,-0.05036318750000013`},{0.9300000000000068`,-0.057363187500000246`},{0.9500000000000028`,-0.06436318750000014`},{0.9699999999999989`,-0.06636318750000014`},{0.9899999999999949`,-0.06636318750000014`},{1.0100000000000051`,-0.06636318750000014`},{1.0300000000000011`,-0.06236318750000014`},{1.0499999999999972`,-0.057363187500000246`},{1.0699999999999932`,-0.05136318750000024`},{1.0900000000000034`,-0.045363187500000235`},{1.1099999999999994`,-0.04036318750000012`},{1.1299999999999955`,-0.036363187500000116`},{1.1500000000000057`,-0.035363187500000226`},{1.1700000000000017`,-0.035363187500000226`},{1.1899999999999977`,-0.035363187500000226`},{1.2099999999999937`,-0.03836318750000012`},{1.230000000000004`,-0.04436318750000012`},{1.25`,-0.05136318750000024`},{1.269999999999996`,-0.058363187500000135`},{1.2900000000000063`,-0.06436318750000014`},{1.3100000000000023`,-0.06736318750000025`},{1.3299999999999983`,-0.06736318750000025`},{1.3499999999999943`,-0.06736318750000025`},{1.3700000000000045`,-0.06636318750000014`},{1.3900000000000006`,-0.05936318750000025`},{1.4099999999999966`,-0.05136318750000024`},{1.4300000000000068`,-0.04336318750000023`},{1.4500000000000028`,-0.03736318750000023`},{1.4699999999999989`,-0.03136318750000022`},{1.4899999999999949`,-0.02936318750000022`},{1.5100000000000051`,-0.02736318750000022`},{1.5300000000000011`,-0.02736318750000022`},{1.5499999999999972`,-0.02736318750000022`},{1.5699999999999932`,-0.026363187500000107`},{1.5900000000000034`,-0.024363187500000105`},{1.6099999999999994`,-0.022363187500000103`},{1.6299999999999955`,-0.019363187500000212`},{1.6500000000000057`,-0.019363187500000212`},{1.6700000000000017`,-0.019363187500000212`},{1.6899999999999977`,-0.022363187500000103`},{1.7099999999999937`,-0.024363187500000105`},{1.730000000000004`,-0.02736318750000022`},{1.75`,-0.02736318750000022`},{1.769999999999996`,-0.02736318750000022`},{1.7900000000000063`,-0.023363187500000215`},{1.8100000000000023`,-0.0183631875000001`},{1.8299999999999983`,-0.010363187500000315`},{1.8499999999999943`,-0.005363187500000199`},{1.8700000000000045`,-0.0023631875000003078`},{1.8900000000000006`,-0.0023631875000003078`},{1.9099999999999966`,-0.0023631875000003078`},{1.9300000000000068`,-0.0033631875000001976`},{1.9500000000000028`,-0.006363187500000311`},{1.9699999999999989`,-0.010363187500000315`},{1.9899999999999949`,-0.014363187500000318`},{2.010000000000005`,-0.01736318750000021`},{2.030000000000001`,-0.01736318750000021`},{2.049999999999997`,-0.01736318750000021`},{2.069999999999993`,-0.014363187500000318`},{2.0900000000000034`,-0.009363187500000203`},{2.1099999999999994`,-0.0033631875000001976`},{2.1299999999999955`,0.0026368124999998077`},{2.1500000000000057`,0.007636812499999701`},{2.1700000000000017`,0.007636812499999701`},{2.1899999999999977`,0.007636812499999701`},{2.2099999999999937`,0.007636812499999701`},{2.230000000000004`,0.0046368124999998095`},{2.25`,0.0006368124999998059`},{2.269999999999996`,-0.0033631875000001976`},{2.2900000000000063`,-0.006363187500000311`},{2.3100000000000023`,-0.009363187500000203`},{2.3299999999999983`,-0.009363187500000203`},{2.3499999999999943`,-0.009363187500000203`},{2.3700000000000045`,-0.009363187500000203`},{2.3900000000000006`,-0.007363187500000201`},{2.4099999999999966`,-0.006363187500000311`},{2.430000000000007`,-0.005363187500000199`},{2.450000000000003`,-0.005363187500000199`},{2.469999999999999`,-0.005363187500000199`},{2.489999999999995`,-0.006363187500000311`},{2.510000000000005`,-0.008363187500000313`},{2.530000000000001`,-0.013363187500000206`},{2.549999999999997`,-0.01736318750000021`},{2.569999999999993`,-0.021363187500000214`},{2.5900000000000034`,-0.021363187500000214`},{2.6099999999999994`,-0.021363187500000214`},{2.6299999999999955`,-0.019363187500000212`},{2.6500000000000057`,-0.015363187500000208`},{2.6700000000000017`,-0.009363187500000203`},{2.6899999999999977`,-0.005363187500000199`},{2.7099999999999937`,-0.0023631875000003078`},{2.730000000000004`,-0.0013631875000001958`},{2.75`,-0.0013631875000001958`},{2.769999999999996`,-0.0013631875000001958`},{2.7900000000000063`,-0.0033631875000001976`},{2.8100000000000023`,-0.0033631875000001976`},{2.8299999999999983`,-0.0033631875000001976`},{2.8499999999999943`,-0.0033631875000001976`},{2.8700000000000045`,-0.0033631875000001976`},{2.8900000000000006`,-0.0033631875000001976`},{2.9099999999999966`,-0.0033631875000001976`},{2.930000000000007`,-0.0033631875000001976`},{2.950000000000003`,-0.0023631875000003078`},{2.969999999999999`,0.0016368124999996958`},{2.989999999999995`,0.006636812499999811`},{3.010000000000005`,0.012636812499999817`},{3.030000000000001`,0.015636812499999708`},{3.049999999999997`,0.018636812499999822`},{3.069999999999993`,0.018636812499999822`},{3.0900000000000034`,0.018636812499999822`},{3.1099999999999994`,0.01663681249999982`},{3.1299999999999955`,0.01663681249999982`},{3.1500000000000057`,0.01663681249999982`},{3.1700000000000017`,0.01763681249999971`},{3.1899999999999977`,0.020636812499999824`},{3.2099999999999937`,0.025636812499999717`},{3.230000000000004`,0.02963681249999972`},{3.25`,0.035636812499999726`},{3.269999999999996`,0.04063681249999984`},{3.2900000000000063`,0.044636812499999845`},{3.3100000000000023`,0.04663681249999985`},{3.3299999999999983`,0.04663681249999985`},{3.3499999999999943`,0.04663681249999985`},{3.3700000000000045`,0.04263681249999984`},{3.3900000000000006`,0.03763681249999973`},{3.4099999999999966`,0.032636812499999834`},{3.430000000000007`,0.02663681249999983`},{3.450000000000003`,0.019636812499999712`},{3.469999999999999`,0.014636812499999818`},{3.489999999999995`,0.007636812499999701`},{3.510000000000005`,0.0046368124999998095`},{3.530000000000001`,0.0016368124999996958`},{3.549999999999997`,0.0016368124999996958`},{3.569999999999993`,0.0016368124999996958`},{3.5900000000000034`,0.0026368124999998077`},{3.6099999999999994`,0.0036368124999996976`},{3.6299999999999955`,0.005636812499999699`},{3.6500000000000057`,0.005636812499999699`},{3.6700000000000017`,0.005636812499999699`},{3.6899999999999977`,0.005636812499999699`},{3.7099999999999937`,0.006636812499999811`},{3.730000000000004`,0.009636812499999703`},{3.75`,0.013636812499999706`},{3.769999999999996`,0.018636812499999822`},{3.7900000000000063`,0.022636812499999825`},{3.8100000000000023`,0.02763681249999972`},{3.8299999999999983`,0.02963681249999972`},{3.8499999999999943`,0.03163681249999972`},{3.8700000000000045`,0.03163681249999972`},{3.8900000000000006`,0.03163681249999972`},{3.9099999999999966`,0.032636812499999834`},{3.930000000000007`,0.033636812499999724`},{3.950000000000003`,0.03663681249999984`},{3.969999999999999`,0.04163681249999973`},{3.989999999999995`,0.045636812499999735`},{4.010000000000005`,0.05063681249999985`},{4.030000000000001`,0.05363681249999974`},{4.049999999999997`,0.057636812499999746`},{4.069999999999993`,0.05963681249999975`},{4.090000000000003`,0.06063681249999986`},{4.109999999999999`,0.06163681249999975`},{4.1299999999999955`,0.06163681249999975`},{4.150000000000006`,0.06163681249999975`},{4.170000000000002`,0.06163681249999975`},{4.189999999999998`,0.05963681249999975`},{4.209999999999994`,0.056636812499999856`},{4.230000000000004`,0.054636812499999854`},{4.25`,0.05063681249999985`},{4.269999999999996`,0.04863681249999985`},{4.290000000000006`,0.04863681249999985`},{4.310000000000002`,0.04863681249999985`},{4.329999999999998`,0.04863681249999985`},{4.349999999999994`,0.05163681249999974`},{4.3700000000000045`,0.055636812499999744`},{4.390000000000001`,0.06163681249999975`},{4.409999999999997`,0.06563681249999975`},{4.430000000000007`,0.07063681249999987`},{4.450000000000003`,0.07563681249999976`},{4.469999999999999`,0.07763681249999976`},{4.489999999999995`,0.07763681249999976`},{4.510000000000005`,0.07763681249999976`},{4.530000000000001`,0.07763681249999976`},{4.549999999999997`,0.07463681249999987`},{4.569999999999993`,0.07163681249999976`},{4.590000000000003`,0.06863681249999987`},{4.609999999999999`,0.06663681249999986`},{4.6299999999999955`,0.06363681249999975`},{4.650000000000006`,0.06163681249999975`},{4.670000000000002`,0.05963681249999975`},{4.689999999999998`,0.05963681249999975`},{4.709999999999994`,0.05963681249999975`},{4.730000000000004`,0.06063681249999986`},{4.75`,0.06163681249999975`},{4.769999999999996`,0.06363681249999975`},{4.790000000000006`,0.0620795088521887`},{4.810000000000002`,0.059369054634550764`},{4.829999999999998`,0.053696366699785406`},{4.849999999999994`,0.04688690249267567`},{4.8700000000000045`,0.03781840624999988`},{4.890000000000001`,0.027168350527011807`},{4.909999999999997`,0.01682594903416704`},{4.930000000000007`,0.007795621910449408`},{4.950000000000003`,0.0019977950011546724`},{4.969999999999999`,0.`}};

and i want to use the NFourierTrigSeries to analyse that data and create a variance density spectrum

<< FourierSeries` 
\[CapitalDelta]x = 0.02;
Length1 = 5;
Echos1 = Interpolation[EchoHannatoS1];
Plot[{Echos1[x]}, {x, 0, Length1 - \[CapitalDelta]x}]
Profilecyclic1[x_] = Piecewise[{{Echos1[x], 0 < x < Length1 - \[CapitalDelta]x}}, 0];
Plot[Profilecyclic1[x], {x, 0 - 1, Length1 + 1}]
CyclicFunction1 = Interpolation[Table[{x, Profilecyclic1[x]}, {x, 0, Length1, 0.02}], PeriodicInterpolation -> True]; 
f0 =  1/Length1 ;(* fundamental frequency *)
fc =  1/\[CapitalDelta]x;  (* max frequency *)
M = IntegerPart[ fc/(2 f0)] ;  (* order of the Fourier series *)
FourierFunction1[x_] = 
NFourierTrigSeries[CyclicFunction1[x], x, M, FourierParameters -> {1, 2 \[Pi] f0}];
Plot[FourierFunction1[x], {x, 0, Length1}]
A0 = FourierFunction1[x][[2, 1]] ;(* Mean value of the fourier function *)
AllCoefficients = Reap[For[i = 1, i < (M + 1), i++, Sow[i]; Sow[f0 i]; 
   Sow[Coefficient[FourierFunction1[x], Cos[ 2 \[Pi] f0 i  x]]]; 
   Sow[Coefficient[FourierFunction1[x], Sin[ 2 \[Pi] f0 i  x]]]; 
   Sow[\[Sqrt]((Coefficient[FourierFunction1[x], 
         Sin[ 2 \[Pi] f0 i  x]])^2 + (Coefficient[
         FourierFunction1[x], Cos[2 \[Pi] f0 i  x]])^2)]];] [[2,1]]~Partition~5;
(* i'm creating a table with the values of i, f0i ,Ai, Bi,ai *)
MatrixForm[Prepend[AllCoefficients, {"i", "fi", "Ai", "Bi", "ai"}]];
Dimensions[AllCoefficients];
fi = AllCoefficients[[All, 2]];
Ai = AllCoefficients[[All, 3]];
Bi = AllCoefficients[[All, 4]] ;
ai = AllCoefficients[[All, 5]];
(* verify the Parseval's theorem --> the result has to be approximately 0 *)
ParsevalValue = (f0* 
NIntegrate[(FourierFunction1[x])^2, {x, 0, Length1}]) - ( 1/ 
2*(Sum[ai[[i]]^2, {i, 1, M}]))
checkfunction1[x_] =Sum[Ai[[i]]*(Cos[2 \[Pi] f0 i x]), {i, 1, M}] + Sum[Bi[[i]]*(Sin[2 \[Pi] f0 i x]), {i, 1, M}];
Plot[checkfunction1[x], {x, 0, Length1}]
Spectrum = Transpose@{fi,  (ai^2)/( 2 f0)};
ListLinePlot[{Spectrum}, PlotRange -> All]
S = Interpolation[Spectrum];
LogLogPlot[{S[f]}, {f, f0, M f0}, PlotLegends -> "Expressions",  AxesLabel -> {"f", "S(f)"}, PlotRange -> {10^(-15), 10^(-3)}]

The results seem to be correct. I have all that i need for my analysis. However, if I Plot the fourier coefficients I get these results

ListPlot[Ai, PlotRange -> All, Filling -> Axis]
ListPlot[Bi, PlotRange -> All, Filling -> Axis]

and I can not understand why the coefficients Ai and Bi have lost their symmetric and anti-symmetric properties.

Can anybody point out the error that i have done? maybe something about the Assumption of the FourierTrigSeries or about the FourierParameters?

I'm asking these questions cause i need that the Fourier coefficients have symmetric properties in order to continue my analysis.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.