From: Jan Simon on 26 Jan 2010 18:42 Dear Luna! > > > I want to find the length of longest consecutive stripe in that > > > column... You can find the indices of changes between the values with: Ind = find(diff(x)) Then you can find the number of elements between the changes with a further DIFF: Len = diff(Ind) Now [Num, MaxInd] = MAX(Len) gives the index and number of the longest sequence. *But* the marginal elements are not correctly considered now! Ind = [0; find(diff(x)); length(x)]; [LongestSeq, MaxInd] = max(diff(Ind)); LongestInd = Ind(MaxInd) + 1; (Please test this before using!) Good luck, Jan
|
Pages: 1 Prev: cross referencing two arrays Next: libactivation exception problem on OS X |