How to synchronize signals with bias

5 visualizaciones (últimos 30 días)
ArchLucs
ArchLucs el 21 de Feb. de 2019
Respondida: Pooja Kumari el 8 de Feb. de 2024
I have to synchronize two signals ('r' and 'e') affected by rumor, they have a relative offset and are not synchronized.
I applied a median moving filter to deal with the narrow high rumor spikes:
r = medfilt1(r, 10, 'includenan', 'truncate');
e = medfilt1(e, 10, 'includenan', 'truncate');
I tried to remove the bias with a workaround (the signals are constant the first 0.5s usually):
fs=1e3;
m_e = mean(e(1:fs/2));
m_r = mean(r(1:fs/2));
o = m_r - m_e;
r = r - o;
Lastly I have to time switching them. I tried the xcorr approach using the finddelay function:
>> d = finddelay(e, r)
d =
0
It doesn't work though. Any idea?

Respuestas (1)

Pooja Kumari
Pooja Kumari el 8 de Feb. de 2024
Hello,
As per my understanding, the finddelay function should not be returning 0 unless your signals 'r' and 'e' are already perfectly synchronized. It appears that the function is not working correctly for your particular signals, you can perform a manual cross-correlation by using the xcorr function to determine the time delay:
[acor, lag] = xcorr(e, r);
[~, I] = max(abs(acor));
time_delay = lag(I);
If time_delay is non-zero, this indicates the amount by which the signals need to be shifted to align them. If it is zero, but the signals are clearly not aligned, there may be an issue with the signals' content or the cross-correlation method may not be suitable.
After applying the bias correction and time alignment, plot the signals to visually inspect the synchronization. Also, calculate the correlation coefficient to quantify the synchronization:
correlation_coefficient = corrcoef(r_aligned, e_aligned);
Refer to the below documentation for more information on xcorr and corrcoef:

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by