# Quick way to find the point where a vector changes from increasing to decreasing.

조회 수: 18 (최근 30일)
Reuben 2012년 12월 15일
Hi I have a vector that goes something like this, [10,9,7,5,3,2,1,2,3,5,7]. You notice in this vector there is the point with value 1 at which the next successive value grows instead of shrinks. My question is about finding this point. I know I could just loop through with a for loop watching for when the difference between point n and n+1 changes sign but wonder if there is a better method. Thanks

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

### 채택된 답변

Matt Fig 2012년 12월 15일
편집: Matt Fig 2012년 12월 15일
D = [10,9,7,5,3,2,1,2,3,5,7];
V = [0 diff(D)>0] % Indicates sign of difference
S = find(V,1,'first') % First index where V is +
##### 댓글 수: 1이전 댓글 -1개 표시이전 댓글 -1개 숨기기
Reuben 2012년 12월 15일
Nice, Thanks.

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

### 카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!

Translated by