What is "lagDiff" on MATLAB to evaluate the time difference from the cross-correlation ?

3 次查看(过去 30 天)
This is the sample program from MATLAB Documentation for xcorr and I'm troubled with understanding what lagDiff means on it.
I've checked the page which explains lag function on MATLAB, but still it is difficult to understand the meaning of "one time step".
load sensorData
t1 = (0:length(s1)-1)/Fs;
t2 = (0:length(s2)-1)/Fs;
subplot(2,1,1)
plot(t1,s1)
title('s_1')
subplot(2,1,2)
plot(t2,s2)
title('s_2')
xlabel('Time (s)')
[acor,lag] = xcorr(s2,s1);
[~,I] = max(abs(acor));
lagDiff = lag(I)
timeDiff = lagDiff/Fs
figure
plot(lag,acor)
a3 = gca;
a3.XTick = sort([-3000:1000:3000 lagDiff]);

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Calendar 的更多信息

产品


版本

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by