I have a periodic signal on a given grid, say :
t = 1:30;
omega = 2*pi/18.431;
phi = -pi+2*pi*rand(1); % a random phase [-pi,pi]
x = sin(omega*t+phi); % the signal
x = x+0.5*rand(1,length(x)); % add some noise
Now I want to retrieve the phase phi
. There are a few approaches to that, for example, to fit this to a sin
, but that takes way too long if I need to do it 1e6 times (unless there's a way to parallelize it?). Another is to use fft
. The problem is that my grid is not good enough to pick exactly that frequency, hence the phase associated with it (and I cant change that). How can I manage to get that phase by other means? (and how can I estimate the error in that phase retrieval? I expect traces too noisy to be well estimated and I'd like to know the phase error in that case)