I need to align two signals that have a time shift to be able to take the differential of them

15 views (last 30 days)
I have a reference signal (blue) and a signal (red) that I have to subtract from each other (figure 1). The issue is that there is a slight time shift. I have to align the signals to be able to get the proper differential signal. I currently have a method to shift the signals using "circshift" but my issue is identifying where the peaks are so I know how much time to shift the signal by. I tried using "max", and "findpeaks" to identify the peaks to align the signal shapes but I have to take the differential of thousands of pairs of (blue) and (red) signals which each have different peak heights and the maximum peaks can be different. The one constant attribute of these signals is that they all have a general 6 cycle sinusoidal shape. I am hoping there is a function that can capture the general shape of the 6 cycle sinusoidal shape in the (blue) and (red) robustly so I know the time difference (or phase shift) I need to plug into "circshift" fuction.

Answers (2)

Jan
Jan on 12 Jul 2017
What aboput using Matlab's xcorr function to determine the shift automatically?

Star Strider
Star Strider on 12 Jul 2017
I would use the alignsignals (link) function. There are related functions in the links at the end of the page.

Products

Community Treasure Hunt

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

Start Hunting!