I have two periodic non-sinusoidal waveforms $WV1$ and $WV2$ (See Figure). I want to extract the fundamental components of these two (i.e. $WV1_{F0}$ and $WV2_{F0}$) and find the peak amplitudes and phase between fundamental components.
Here is a minimal code example generating waveforms. My actual waveforms are generated from a numerical data capture.
s1 =
1.5 Sin[ω0 t] + f31 Sin[3 ω0 t + θ3] + f51 Sin[5 ω0 t + θ5] /.
{ω0 -> 2 π, f31 -> 0.2, θ3 -> π, f51 -> 0.3, θ5 -> 0};
s10 = 1.5 Sin[ω0 t] /. {ω0 -> 2 π};
s2 = Sin[ω0 t + ϕ2] +
f32 Sin[3 ω0 t + θ3] /. {ω0 -> 2 π,
f32 -> 0.4, θ3 -> 0, ϕ2 -> π/3};
s20 = Sin[ω0 t + ϕ2] /. {ω0 -> 2 π,
f32 -> 0.4, θ3 -> 0, ϕ2 -> π/3};
Plot[{s1, s2, s10, s20}, {t, 0, 2 (2 π)/ω0} /. {ω0 -> 2 π},
PlotStyle -> {Red, Blue, {Red, Dashed}, {Blue, Dashed}},
PlotLegends -> {"WV1", "WV2", "WV1F0", "WV2F0" }]
How can I do this using Mathematica?
Solution Based on @yarchik's comment and using the answer to this question:
s1 =
Table[
Sin[ω0 t] + f31 Sin[3 ω0 t + θ3] + Sin[5 ω0 t + θ5] /.
{ω0 -> 2 π, f31 -> 0.2, θ3 -> π, f51 -> 0.3, θ5 -> 0},
{t, -10, 10, 1/1000}];
s2 =
Table[
Sin[ω0 t + ϕ2] + Sin[3 ω0 t + θ3] /. {ω0 -> 2 π,f32 -> 0.4, θ3 -> 0, ϕ2 -> π/3},
{t, -10, 10,1/1000}];
ffts1 = Fourier[s1, FourierParameters -> {-1, 1}];
ffts2 = Fourier[s2, FourierParameters -> {-1, 1}];
max = Max[Abs[ffts1]];
pos = First[First[Position[Abs[ffts1], max]]];
Abs[ffts2[[pos]]]/Abs[ffts1[[pos]]]
Arg[ffts2[[pos]]] - Arg[ffts1[[pos]]]
π/3. (*actual phase difference*)
So, my initial problem was solved.
Please let me know if there is anything wrong with my approach.


