Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Matching Character Phrases...
Date: Thu, 21 Feb 2008 20:32:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 30
Message-ID: <fpkn42$3cg$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1203625922 3472 172.30.248.38 (21 Feb 2008 20:32:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 21 Feb 2008 20:32:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1138100
Xref: news.mathworks.com comp.soft-sys.matlab:453000



Hi

Can anyone help me with figuring out what kind of loop would solve this 
problem?

I have a variable 'text' that is a series of uppercase characters.  It looks 
something like this:

OPASKSGLBOJASLOPASNKMGLBOSDLASJSFLOPASHHASKSMLGLBO...

The user enters a value, and based on this number, the program should look 
for all matching phrases of that length.  For example, if they choose '4' the 
loop should look through 'text' for all phrases of this size that occur more 
than once.  It should also record the distance between the matching phrases 
in another row of the array (or a seperate array if this is easier). The output 
array for the above 'text' should end up looking something like this:

OPAS  [14]
OPAS  [20]
GLBO  [15]
GLBO  [23]
...etc...

Using strmatch doesnt seem to help me for this...

I have a loop that works, but it is very time consuming to run.  I only really 
need to use the first '30' results from the output array so it would be ideal if 
the loop could break when the output array is of length 30 (if it gets up to 30, 
sometimes there will be less), otherwise it should end when there are no 
more matches found.