Hello,
here...
http://www.dsprelated.com/showarticle/26.php
.. and here ...
http://www.elisanet.fi/mnentwig/webroot/fit_signal/index.html
I have some code that probably does exactly what you want, with subsample
accuracy.
For someone who wants to use it as a "black box" (without understanding
the gory details), one could explain as follows:
It finds the timing offset and scaling coefficient between two cyclic
signals, that gives the best match in a least squares sense (the "energy"
of the residual sum((sig1-sig2_scaled_and_shifted)^2) is minimized.
Hope that's useful. There is BTW crosscorrelation inside, implemented via
FFT.
-mn
Reply by stanp●November 23, 20072007-11-23
On Nov 21, 1:41 pm, "john1985" <murray_1...@hotmail.com> wrote:
> Hi,
> i'm relatively new to dsp and matlab.I currently have 2 waveforms read
> into Matlab from my oscilloscope,for example waveform A and waveform B. I
> want to to perform a search for a similiar match of waveform A in waveform
> B. I believe its poossible to do this using the xcorr function in matlab
> but I'm having difficulties in getting this to work. I want to plot my
> results so that a "correlation spike" indicates the place in waveform B
> where a match occurs.Any suggestions please?
> Thanks
> John
There are spikes and then there are spikes. Periodic signals (of the
same period) will give you a periodic cross correlation. Try using
xcorr on your reference signal to get an idea of what you can expect
to see.
Reply by Darol Klawetter●November 21, 20072007-11-21
On Nov 21, 12:41 pm, "john1985" <murray_1...@hotmail.com> wrote:
> Hi,
> i'm relatively new to dsp and matlab.I currently have 2 waveforms read
> into Matlab from my oscilloscope,for example waveform A and waveform B. I
> want to to perform a search for a similiar match of waveform A in waveform
> B. I believe its poossible to do this using the xcorr function in matlab
> but I'm having difficulties in getting this to work. I want to plot my
> results so that a "correlation spike" indicates the place in waveform B
> where a match occurs.Any suggestions please?
> Thanks
> John
The xcorr function is straightforward. Here is a Matlab m-file code
snippet:
load waveform.mat; %load waveform
load crossWave.mat; %loads pattern to cross correlate against
into "crossWave"
corr = xcorr(waveform, crossWave); % cross correlates waveform
to crossWave
figure;
plot(waveform);
hold on;
plot(corr((length(waveform) - length(crossWave))
+1:length(corr)),'r');
hold off;
title('Correlation Detect');
Reply by john1985●November 21, 20072007-11-21
Hi,
i'm relatively new to dsp and matlab.I currently have 2 waveforms read
into Matlab from my oscilloscope,for example waveform A and waveform B. I
want to to perform a search for a similiar match of waveform A in waveform
B. I believe its poossible to do this using the xcorr function in matlab
but I'm having difficulties in getting this to work. I want to plot my
results so that a "correlation spike" indicates the place in waveform B
where a match occurs.Any suggestions please?
Thanks
John