Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Searching for a vector
Date: Sun, 22 May 2011 17:51:04 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 10
Message-ID: <irbie8$cuj$1@newscl01ah.mathworks.com>
References: <iraoqs$c3v$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1306086664 13267 172.30.248.37 (22 May 2011 17:51:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 22 May 2011 17:51:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:728079

"Kris zenitis" wrote in message <iraoqs$c3v$1@newscl01ah.mathworks.com>...
> How to search for a vector inside a bigger vector and return the indexes of the beggining and the end??
- - - - - - - - -
  Let v1 be the small vector and v2 the large vector.

 n1 = length(v1);
 [~,first] = ismember(v1,hankel(v2(1:n1),v2(n1:end),'rows');
 last = first+n1-1;

Roger Stafford