0
$\begingroup$

I would like to calculate the phase between two signals like

f= Table[Sin[x-0.8],{x,-100,100,0.1}]
g= Table[Sin[x],{x,-100,100,0.1}]

For doing that I use the ArcCos[Correlation[f, g]], that instruction gives the phase between two functions but is independent of the sign of the phase. There is some way to consider the sign of the phase?

Thanks

$\endgroup$
2
  • $\begingroup$ No, they use the same function. $\endgroup$
    – F.Mark
    May 31, 2020 at 13:56
  • 1
    $\begingroup$ @F.Mark I don’t understand what you mean. The question linked by Marius seems to fit your problem exactly! Can you explain why that solution would not work here? $\endgroup$
    – MarcoB
    May 31, 2020 at 16:09

1 Answer 1

1
$\begingroup$

A phase of 45.6991 degrees? Followed Mariusz's advice, the graph shows different. (19? degrees)

f = Table[Sin[x - 0.8], {x, -100, 100, 0.1}];
g = Table[Sin[x], {x, -100, 100, 0.1}];

ffts1B = Fourier[f, FourierParameters -> {-1, 1}];
ffts2B = Fourier[g, FourierParameters -> {-1, 1}];
maxB = Max[Abs[ffts1B]];
posB = First[First[Position[Abs[ffts1B], maxB]]];
Arg[ffts1B[[posB]]] - Arg[ffts2B[[posB]]]

%/Pi*180
(* Out 45.6991 *)
aplt = ListLinePlot[{f, g}, PlotRange -> {{0, 100.0}, {-1.1, 1.1}}]

graphic of plot from original data

Seeing your Trig.

Sin[x-0.8] - Sin[x-0.0]
In:= 0.2*Pi/2/Pi*180
(* Out= 18. *)

My guess at the answer? 18 degrees.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.