Path: news.mathworks.com!newsfeed-00.mathworks.com!news.tele.dk!feed118.news.tele.dk!feed116.news.tele.dk!bofh.vszbr.cz!news.radio.cz!newsreader4.netcologne.de!news.netcologne.de!feeder.erje.net!eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!aioe.org!.POSTED!not-for-mail
From: "willi" <williwie___q@hotmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Using correlation to search for subvector within a binary time series (bitstream)
Date: Tue, 9 Apr 2013 21:37:35 +0200
Organization: Aioe.org NNTP Server
Lines: 27
Message-ID: <kk1qm0$ffh$1@speranza.aioe.org>
References: <kk1fn4$nrr$1@newscl01ah.mathworks.com>
NNTP-Posting-Host: 3TiuTfEy9XGwz0QSXK+PRQ.user.speranza.aioe.org
Mime-Version: 1.0
Content-Type: text/plain;
	format=flowed;
	charset="utf-8";
	reply-type=response
Content-Transfer-Encoding: 7bit
X-Complaints-To: abuse@aioe.org
X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6002.18463
X-Notice: Filtered by postfilter v. 0.8.2
X-Newsreader: Microsoft Windows Mail 6.0.6002.18197
X-Priority: 3
X-MSMail-Priority: Normal
Xref: news.mathworks.com comp.soft-sys.matlab:793100


"Matthew " <mamorena12@gmail.com> wrote in message 
news:kk1fn4$nrr$1@newscl01ah.mathworks.com...
>I understand how the correlation between two time series is found.  I am 
>wondering if it is possible to use a correlation method in order to find a 
>particular sub-vector within a binary time series (e.g., a bitstream).
>
> For example, given a pseudo-random bitstream of length 1,500, say, can one 
> use a correlation technique to see if the vector v = [1 1 1 1 0 1] appears 
> somewhere in the bitstream?
>
> I am aware of Matlab's "find" function and its other built-in functions; I 
> am curious to see if this approach is valid as well.  Thanks!

Try:

v = [1 1 1 1 0 1];
vv = [round(rand(1,250))  v round(rand(1,250-numel(v)))];
xc = xcorr(2*vv-1,2*v-1); % make it a +1/-1-vector
xc = xc(500:end);
plot(xc/numel(v), '.-');grid

This algorithm will also find the inverse pattern.

--
Best rgds