Fit data recorded with different internal clocks
1 回表示 (過去 30 日間)
古いコメントを表示
I have 2 sets of data, A and B, that records a distance which fluctates ~2ft for 600 seconds. The two devices have a differing internal clocks. Data B time drifts slightly forwards and backwards compared to the time in Data A, which I'm using as the reference.
I am looking to finely match the data between the two, and ultimately create a vector to multiply the time in Data B by to bring the data to a better appoximation of Data A. Then I can apply this vector to adjust other data recorded by the device with the time drift.
I've tried peak fitting, and the part I am stuck on is producing a sequential 'best fit'.
My question is, would there a better way to produce the corrective time drift vector than peak fitting?
0 件のコメント
採用された回答
Chad Greene
2021 年 5 月 7 日
編集済み: Chad Greene
2021 年 5 月 7 日
This is an interesting problem. If you can identify a few peaks that occur throughout the 600 s measurement, and those peaks are present in both signals, I think it's actually easy to solve elegantly.
Say in signal A you find five peaks at times
ta_peaks = [51 90 200 306 510];
and you see those same peaks in signal B, but in signal B they appear to occur at
tb_peaks = [49 89 200 307 515];
Start by fitting a relationship between ta and tb:
plot(ta_peaks,tb_peaks,'o')
hold on
xlabel 'time a peaks'
ylabel 'time b peaks'
% Relate time b to time a:
p = polyfit(ta_peaks,tb_peaks,2); % quadratic fit
tb_fit = polyval(p,ta_peaks);
plot(ta_peaks,tb_fit)
Now with the relationship between clock A and clock B, you can use interp1 to interpolate signal B to the timing of signal A's clock.
B_interp = interp1(tb,B,polyval(p,ta));
and now the peaks and overall timing of B_interp should align with the signal A.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で AI for Signals についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!