I'm wondering if you can be of some help to me. I currently have two waveforms,waveform1 and waveform2 that I'm reading from my oscilloscope into Matlab. I want to find the times in waveform2 that a match for waveform1 occurs. I want a 'correlation spike' to occur in my resultant waveform every time Matlab finds a match for waveform1 in waveform2.However at the moment this is not occuring. Does the xcorr function not achieve this functionality?Thanks for any help Regards Djt So far my code is as follows %%%%%%%%%%%%%%%%%%%%%%% Firstly open the figure files open waveform1.fig open waveform2.fig Then read the x and y data fields from each figure... figure(1) x1=get(findobj(gca,'type','line'),'xdata'); y1=get(findobj(gca,'type','line'),'ydata'); figure(2) x2=get(findobj(gca,'type','line'),'xdata'); y2=get(findobj(gca,'type','line'),'ydata'); finally you can correlate the two Y data sets... cordat=xcorr(y1,y2) Plot(cordat)
cross correlation
Started by ●January 21, 2008
Reply by ●January 22, 20082008-01-22
On Jan 21, 9:53 am, "djt740" <djt...@hotmail.com> wrote:> I'm wondering if you can be of some help to me. > I currently have two waveforms,waveform1 and waveform2 that I'm reading > from my oscilloscope into Matlab. I want to find the times in waveform2 > that a match for waveform1 occurs. I want a 'correlation spike' to occur > in my resultant waveform every time Matlab finds a match for waveform1 in > waveform2.However at the moment this is not occuring. Does the xcorr > function not achieve this functionality?Thanks for any help > Regards > Djt > So far my code is as follows > %%%%%%%%%%%%%%%%%%%%%%% > Firstly open the figure files > > open waveform1.fig > open waveform2.fig > > Then read the x and y data fields from each figure... > > figure(1) > x1=get(findobj(gca,'type','line'),'xdata'); > y1=get(findobj(gca,'type','line'),'ydata'); > figure(2) > x2=get(findobj(gca,'type','line'),'xdata'); > y2=get(findobj(gca,'type','line'),'ydata'); > > finally you can correlate the two Y data sets... > > cordat=xcorr(y1,y2) > Plot(cordat)I don't see anything obviously wrong with your code, just keep in mind that the peaks produced by cross correlation can be relatively broad, so maybe you are looking for a spike, what you want is the lump. Chris Chris
Reply by ●January 22, 20082008-01-22
On 21 Jan, 15:53, "djt740" <djt...@hotmail.com> wrote:> I'm wondering if you can be of some help to me. > I currently have two waveforms,waveform1 and waveform2 that I'm reading > from my oscilloscope into Matlab. I want to find the times in waveform2 > that a match for waveform1 occurs. I want a 'correlation spike' to occur > in my resultant waveform every time Matlab finds a match for waveform1 in > waveform2.However at the moment this is not occuring. Does the xcorr > function not achieve this functionality?Thanks for any help > Regards > Djt > So far my code is as follows > %%%%%%%%%%%%%%%%%%%%%%% > Firstly open the figure files > > open waveform1.fig > open waveform2.figWhy do you load .fig files? Why not load raw data? Rune
Reply by ●January 22, 20082008-01-22
>On Jan 21, 9:53 am, "djt740" <djt...@hotmail.com> wrote: >> I'm wondering if you can be of some help to me. >> I currently have two waveforms,waveform1 and waveform2 that I'mreading>> from my oscilloscope into Matlab. I want to find the times inwaveform2>> that a match for waveform1 occurs. I want a 'correlation spike' tooccur>> in my resultant waveform every time Matlab finds a match for waveform1in>> waveform2.However at the moment this is not occuring. Does the xcorr >> function not achieve this functionality?Thanks for any help >> Regards >> Djt >> So far my code is as follows >> %%%%%%%%%%%%%%%%%%%%%%% >> Firstly open the figure files >> >> open waveform1.fig >> open waveform2.fig >> >> Then read the x and y data fields from each figure... >> >> figure(1) >> x1=get(findobj(gca,'type','line'),'xdata'); >> y1=get(findobj(gca,'type','line'),'ydata'); >> figure(2) >> x2=get(findobj(gca,'type','line'),'xdata'); >> y2=get(findobj(gca,'type','line'),'ydata'); >> >> finally you can correlate the two Y data sets... >> >> cordat=xcorr(y1,y2) >> Plot(cordat) > >I don't see anything obviously wrong with your code, just keep in mind >that the peaks produced by cross correlation can be relatively broad, >so maybe you are looking for a spike, what you want is the lump. > >Chris >ChrisHi Chris, What to you mean by 'the lump'?At the moment when I plot the xcorr result I get a continuous waveform of varying amplitude.I was expecting a spike to occur only when it finds a match in waveform2 for waveform one Thanks for your help Djt>
Reply by ●January 22, 20082008-01-22
On Jan 22, 9:35�am, "djt740" <djt...@hotmail.com> wrote:> >On Jan 21, 9:53 am, "djt740" <djt...@hotmail.com> wrote: > >> I'm wondering if you can be of some help to me. > >> I currently have two waveforms,waveform1 and waveform2 that I'm > reading > >> from my oscilloscope into Matlab. I want to find the times in > waveform2 > >> that a match for waveform1 occurs. I want a 'correlation spike' to > occur > >> in my resultant waveform every time Matlab finds a match for waveform1 > in > >> waveform2.However at the moment this is not occuring. Does the xcorr > >> function not achieve this functionality?Thanks for any help > >> Regards > >> Djt > >> So far my code is as follows > >> %%%%%%%%%%%%%%%%%%%%%%% > >> Firstly open the figure files > > >> open waveform1.fig > >> open waveform2.fig > > >> Then read the x and y data fields from each figure... > > >> figure(1) > >> x1=get(findobj(gca,'type','line'),'xdata'); > >> y1=get(findobj(gca,'type','line'),'ydata'); > >> figure(2) > >> x2=get(findobj(gca,'type','line'),'xdata'); > >> y2=get(findobj(gca,'type','line'),'ydata'); > > >> finally you can correlate the two Y data sets... > > >> cordat=xcorr(y1,y2) > >> Plot(cordat) > > >I don't see anything obviously wrong with your code, just keep in mind > >that the peaks produced by cross correlation can be relatively broad, > >so maybe you are looking for a spike, what you want is the lump. > > >Chris > >Chris > > Hi Chris, > What to you mean by 'the lump'?At the moment when I plot the xcorr result > I get a continuous waveform of varying amplitude.I was expecting a spike > to occur only when it finds a match in waveform2 for waveform one > Thanks for your help > Djt > > > > - Hide quoted text - > > - Show quoted text -- Hide quoted text - > > - Show quoted text -I suspect your data is sinusoidal. Find the correlation of sin(wt) and cos(wt), also autocorrelation of sin(wt), and cos(wt). Look at what you get. That might answer your question. Maurice Givens Wright College, Chicago