How to align two sampled arbitrary waves NOT by their peaks?
12 views (last 30 days)
Hello Matlab community! Thank you all in advance for the invaluable information.
So, really it's a two part problem. I have two time-varying signals which should be identical in frequency (though there may be some variance across the entire signal). These signals are not perfect and are not always sampled at ideal rates, which means their peaks aren't always visible. The signals have 100+ periods. I want to do two things:
- Find the phase difference between the two waves (I guess this needs to be an average?)
- Phase-shift (or time-shift) one of the waves so that it is aligned with the second, unchanged wave
- Note: The alignment needs to be as precise as possible
I first started off by using 'resample' to resample the waves in an effort to do peak finding and align them that way, but when I zoom in on the waves, it appears that the peaks are shaped correctly (too slow a sampling rate I suppose). I THINK what I need to do is some kind of signal-wide fit, but I'm unsure what to do here.
This is the best solution I've found so far: http://www.mathworks.com/support/solutions/en/data/1-3M6NCT/index.html?product=SG&solution=1-3M6NCT
But after implementing that there's still a constant tiny offset throughout the signal. This seems to be due to the peaks artificially occurring at wrong times due to lack of sampling rate. Example:
Blue is target wave, red is wave to be moved, and magenta is the shifted red wave
Is there anything I could do to make the fit better at the cost of more processing?