retrieve phase of an extrapolated periodic 1D signal
if you know, in advance, the frequency of the sinusoid, so only the phase (and perhaps the amplitude) is unknown, the simplest noise-immune method i know of to get amplitude and phase is (i'm gonna do this in continuous time and let you translate it to discrete time and eventually to MATLAB):

$$ x(t) = \sin(\omega t + \phi) + n(t) $$

compute

$$ \begin{align}
a &amp; = \int\limits_0^{\frac{2 \pi}{\omega}} x(t) \sin(\omega t) dt \\
&amp; = \int\limits_0^{\frac{2 \pi}{\omega}} \left(\sin(\omega t + \phi) + n(t) \right) \sin(\omega t) dt \\
&amp; = \int\limits_0^{\frac{2 \pi}{\omega}} \sin(\omega t + \phi) \sin(\omega t) dt + \int\limits_0^{\frac{2 \pi}{\omega}} n(t) \sin(\omega t) dt \\
&amp; = \frac{1}{2} \int\limits_0^{\frac{2 \pi}{\omega}} \cos(\phi) dt - \frac{1}{2} \int\limits_0^{\frac{2 \pi}{\omega}} \cos(2\omega t + \phi) dt + \int\limits_0^{\frac{2 \pi}{\omega}} n(t) \sin(\omega t) dt \\
&amp; \approx \frac{1}{2} \int\limits_0^{\frac{2 \pi}{\omega}} \cos(\phi) dt \\
&amp; = \frac{\pi}{\omega} \cos(\phi)  \\
\end{align} $$

and

$$ \begin{align}
b &amp; = \int\limits_0^{\frac{2 \pi}{\omega}} x(t) \cos(\omega t) dt \\
&amp; = \int\limits_0^{\frac{2 \pi}{\omega}} \left(\sin(\omega t + \phi) + n(t) \right) \cos(\omega t) dt \\
&amp; = \int\limits_0^{\frac{2 \pi}{\omega}} \sin(\omega t + \phi) \cos(\omega t) dt + \int\limits_0^{\frac{2 \pi}{\omega}} n(t) \cos(\omega t) dt \\
&amp; = \frac{1}{2} \int\limits_0^{\frac{2 \pi}{\omega}} \sin(\phi) dt + \frac{1}{2} \int\limits_0^{\frac{2 \pi}{\omega}} \sin(2\omega t + \phi) dt + \int\limits_0^{\frac{2 \pi}{\omega}} n(t) \cos(\omega t) dt \\
&amp; \approx \frac{1}{2} \int\limits_0^{\frac{2 \pi}{\omega}} \sin(\phi) dt  \\
&amp; = \frac{\pi}{\omega} \sin(\phi)  \\
\end{align} $$

in both expressions (on the bottom line) we know the middle integral is zero and expect the integral on the right to tend toward zero because $n(t)$ is bipolar and ain't correlated with anything.

i think, then, that you'll find the phase $\phi$ to be:

$$ \phi = \arg\left\{a + jb \right\} $$

which is, if $a&gt;0$

$$ \phi = \arctan\left(\frac{b}{a} \right) $$

otherwise, you might have to add or subtract $\pi$ to that expression.