No BSD License  

Highlights from
CONTIGUOUS -- Start and stop indices for contiguous runs

Be the first to rate this file! 7 Downloads (last 30 days) File Size: 2.02 KB File ID: #5658

CONTIGUOUS -- Start and stop indices for contiguous runs

by David Fass

 

09 Aug 2004 (Updated 12 Aug 2004)

RUNS = CONTIGUOUS(A,NUM) returns the start and stop indices for contiguous runs of the elements NUM

| Watch this File

File Information
Description

RUNS = CONTIGUOUS(A,NUM) returns the start and stop indices for contiguous runs of the elements NUM within vector A. A and NUM can be vectors of integers or characters. Output RUNS is a 2-column cell array where the ith row of the first column contains the ith value from vector NUM and the ith row of the second column contains a matrix of start and stop indices for runs of the ith value from vector NUM. These matrices have the following form:
  
   [startRun1 stopRun1]
   [startRun2 stopRun2]
   [ ... ... ]
   [startRunN stopRunN]

Example: Find the runs of '0' and '2' in vector A, where A = [0 0 0 1 1 2 2 2 0 2 2 1 0 0];
    
   runs = contiguous(A,[0 2])
   runs =
           [0] [3x2 double]
           [2] [2x2 double]

The start/stop indices for the runs of '0' are given by runs{1,2}:

           1 3
           9 9
          13 14

RUNS = CONTIGUOUS(A) with only one input returns the start and stop indices for runs of all unique elements contained in A.

CONTIGUOUS is intended for use with vectors of integers or characters, and is probably not appropriate for floating point values. You decide.

MATLAB release MATLAB 6.5 (R13)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Updates
12 Aug 2004

added keywords

Tag Activity for this File
Tag Applied By Date/Time
contiguous David Fass 22 Oct 2008 07:29:30
run David Fass 22 Oct 2008 07:29:30
runs David Fass 22 Oct 2008 07:29:30
length David Fass 22 Oct 2008 07:29:30
run length David Fass 22 Oct 2008 07:29:30
runlength David Fass 22 Oct 2008 07:29:30
length Stuart Rosen 13 Dec 2010 11:51:00
run length Stuart Rosen 13 Dec 2010 11:51:01

Contact us at files@mathworks.com