필터 지우기
필터 지우기

Finding first of n consecutively rising data points

조회 수: 1 (최근 30일)
Etienne O'Brien
Etienne O'Brien 2012년 1월 2일
Hi,
My data look like:
0,2,3,4,3,2,*1*,2,8,9,10,11,12,13, 2, 1, etc
I want to find the index of the value (i) which is the first of n data points which consecutively increase in value. In this example, from the 7th data point (i) onwards there are 8 (n) data points of increasing value(the last being 13). Thank you.
  댓글 수: 1
the cyclist
the cyclist 2012년 1월 2일
I think you need to be more specific. For example, do you want i=1 and n=3, because of the sequence 0,2,3 (the first three elements). Do you want ALL the increasing sequences, or just the longest, etc.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2012년 1월 2일
strfind(diff(data) > 0, ones(1,n))
And yes, I know that strfind is usually used for character data, but it turns out that it can be used for numeric searches as well.
  댓글 수: 2
Andrei Bobrov
Andrei Bobrov 2012년 1월 2일
Hi Walter! Small corrected:
strfind(diff(data) > 0, ones(1,n-1))
Etienne O'Brien
Etienne O'Brien 2012년 1월 2일
Thanks everyone,
This is just what I was looking for.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by