time lag where the phase of the signals is not consistent
I have two time series where I have used xcorr to calculate the lag between two signals. However, I am sure that the time lag will not be consistently over the course of the time series. Is there a way to do a moving window time lag or another way to compute how this lag varies through time?
t = TO(:,1);
O1 = TO(:,2);
S1 = TO(:,3);
r = corr(O1,S1)
dt = mean(diff(t));
O1 = O1 – mean(O1);
S1 = S1 – mean(S1);
[c, lags] = xcorr(S1, O1);
lags = lags*dt;
[~, id]= max(abs(c))
ans = lags(id)
figure(1)
plot(lags,c)I have two time series where I have used xcorr to calculate the lag between two signals. However, I am sure that the time lag will not be consistently over the course of the time series. Is there a way to do a moving window time lag or another way to compute how this lag varies through time?
t = TO(:,1);
O1 = TO(:,2);
S1 = TO(:,3);
r = corr(O1,S1)
dt = mean(diff(t));
O1 = O1 – mean(O1);
S1 = S1 – mean(S1);
[c, lags] = xcorr(S1, O1);
lags = lags*dt;
[~, id]= max(abs(c))
ans = lags(id)
figure(1)
plot(lags,c) I have two time series where I have used xcorr to calculate the lag between two signals. However, I am sure that the time lag will not be consistently over the course of the time series. Is there a way to do a moving window time lag or another way to compute how this lag varies through time?
t = TO(:,1);
O1 = TO(:,2);
S1 = TO(:,3);
r = corr(O1,S1)
dt = mean(diff(t));
O1 = O1 – mean(O1);
S1 = S1 – mean(S1);
[c, lags] = xcorr(S1, O1);
lags = lags*dt;
[~, id]= max(abs(c))
ans = lags(id)
figure(1)
plot(lags,c) xcorr, lag, timeseries MATLAB Answers — New Questions