I am not quite able to understand why do you think the two signals are similar. From what I see in your figure, the orange signal has an extra heavy bump around x=125. What is your expected shift needed to align the two signals?
Align and subtract similar signals
2 次查看(过去 30 天)
显示 更早的评论
I have two signals (T0 and T1) and want to subtract them from each other:
This code using cross-correlation works for me nearly every time, except in this example:
% find cross-correlation
[acor,lag] = xcorr(T1,T0);
[~,I] = max(abs(acor));
lagDiff = lag(I);
% shift T0 to T1
T0_shifted = circshift(T0,lagDiff);
% stretch T0, so that it meets the height of T1
T0_shifted = T0_shifted * max(T1)/max(T0_shifted);
The signal is shifted to the wrong position, because xcorr() returns a maximum at an unwanted position:
Are there any ways to 'tweak' xcorr() or any alternative methods for aligning graphs?
回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!