Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to find if a sequence occurs?
Date: Fri, 13 Feb 2009 07:44:04 +0000 (UTC)
Organization: Erasmus MC
Lines: 20
Message-ID: <gn38c4$ifi$1@fred.mathworks.com>
References: <gn20qd$2ic$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1234511044 18930 172.30.248.35 (13 Feb 2009 07:44:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 13 Feb 2009 07:44:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 870065
Xref: news.mathworks.com comp.soft-sys.matlab:518049

"Diego Zegarra" <diegozbb@gmail.com> wrote in message <gn20qd$2ic$1@fred.mathworks.com>...
< SNIP ... wants to find if two integers occur one after another

Based on your somewhat confusing description of the problem, I could suggest:

% some data
   A = [2 4 3 6 5 4 2 4 3 1 3 1 3 3 4 4 2 2] ;

% a engine
  B = false(max(A)) ; 
  idx = sub2ind(size(B),A(1:end-1),A(2:end)) ;
  B(idx) = true ;

% Do two numbers follow each other?
  n1 = 2 ;
  n2 = 4 ;
  if B(n1,n2), disp('Yes') ; end

hth
Jos