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!