0
$\begingroup$

I have two signals from two different sensors. I cropped the area i am interested in from both sensor signals. The problem is that the signals start at different time instants. I am searching for a way to align the signals just like below. It is technically just moving the blue signal to align with orange one. I tried using cross correlation but it gave a weird result. Any help please.

first image: this is the result of cross correlation of two signals Second image :after applying code on cross correlation to align this is the result of cross correlation of two signalsafter applying code on cross correlation to align cross correlation result

$\endgroup$
4
  • 2
    $\begingroup$ What exactly was weird about your cross correlation results ? $\endgroup$
    – Hilmar
    Dec 3, 2019 at 14:22
  • $\begingroup$ Try removing the mean from both samples prior to doing the cross correlation $\endgroup$ Dec 3, 2019 at 14:25
  • $\begingroup$ I use 'lag=np.argmax(signal.correlate(x,y))' where x and y are the signals. This function typically calculates the index at which maximum cross correlation occurs. The index from what I understood is considered to be the time lag. So if I shift the signal Y by 'lag' it should be aligned with x. However the value 'lag' I get from the function is more than the length of the signal. x length 10880 y length 11035 lag i get is 11770. $\endgroup$ Dec 3, 2019 at 14:41
  • $\begingroup$ I've deleted my answer as I misunderstood the plots. I thought the blue and orange signals were the same but delayed, but they are actually different signals altogether! $\endgroup$
    – Engineer
    Dec 4, 2019 at 19:53

2 Answers 2

1
$\begingroup$

If the signals themselves are entirely different and you just want to align based on the envelope, then in that case, take the envelope by low pass filtering the absolute value, scale each by its rms value, and adjust the delay while subtracting the two scaled envelopes and evaluate the least squared error (sum the square of the errors between the waveforms sample by sample), when this sum is at the minimum you have optimally aligned the two.

$\endgroup$
0
$\begingroup$

I thought you might have to smooth, sort or create an envelope of your signal, which might help. But then i found this. This should help you.

Or if you wish to use MATLAB, you can use this command.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.