I have two signals, the first is a reference signal from which I selected a segment.

I'm trying to find which segment of the other signal is the most similar to this selected segment.

I'd be glad to have some ideas.


closed as too broad by Marcus Müller, MBaz, Peter K. Nov 13 '16 at 18:32

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    $\begingroup$ Welcome to DSP.SE! What have you tried? What doesn't work about it? $\endgroup$ – Peter K. Apr 6 '16 at 13:46
  • $\begingroup$ I guess you want find cross correlation. Read about it and come back if you have problem, but only after trying something from your side. $\endgroup$ – user3219492 Apr 6 '16 at 14:39

You could use correlation between the two signals or a matched filter in which you set the filter coefficients as the samples from the selected segment inverted in time. In matlab it would be something like

coef = knownSegment (end:-1:1,:);

minSize = length(other_signal) + length(knownSegment) - 1;
N = 2^nextpow2(minSize);
OUT = ifft(fft(other_signal,N).*fft(coef,N));

Then you find the maximum value of variable OUT and at that point in time the two signals are most similar

  • $\begingroup$ wouldn't be possible to use the function xcorr instead of the ifft? $\endgroup$ – Behind The Sciences Apr 7 '16 at 6:07
  • $\begingroup$ yes, xcorr is equivalent you would have to perform xcorr(other_signal,knownSegment), notice that here you don't have to invert any signal as xcorr automatically does that for you. I didn't suggest xcorr before because it's a built-in matlab function $\endgroup$ – VMMF Apr 7 '16 at 15:56

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