I am working on a signal processing project with two oscillators. The first oscillator has a frequency $f_1$ that is independent, and the second oscillator has a frequency $f_2$ that increases, and will become 'frequency entrained' (i.e., 'synchronized', or 'phase locked') when its near to $f_1$.
The best way to determine if the two oscillators are phase locked is to compare the phases of both signals. The real data is messy and a bit cumbersome, but a minimum working example might be two data sets like this:
phases1 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}
phases2 = {0., 0.5, 1., 1.5, 2., 2.5, 3., 3.5, 4., 4.5, 5., 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 12.5, 14.5, 16.5, 18.5}
There is a spot in the middle where the two lines are parallel. One way to find where they are parallel is to take the derivative of both lists and subtract:
Differences[phases1] - Differences[phases2]
And then use a list manipulation function to locate the zeros. However, for the system I am working with, this isn't good enough because of noise and other issues. Is there a better way to determine when two lists are parallel in mathematica?
Should I use autocorrelation or some other function?
Differences[phases1] - Differences[phases2]
work when filtering the data (for example low-pass-filter to remove some noise) to a sufficient degree? $\endgroup$Differences
and using a Filter on the difference of the signals? $\endgroup$phases1 - phases2
, the parallel segment becomes the constant segment. Detecting constant segments is, perhaps, easier to do. (It's samples 12-17.) But in the face of noise, "Where does the character of the difference trace change from rising to flat and then again from flat to falling?" cannot have a sharp answer. To make confidence claims requires a noise model and a signal model. $\endgroup$