First Element Greater Than

조회 수: 161 (최근 30일)
Alex Lu
Alex Lu 2016년 2월 8일
답변: Adam 2016년 2월 8일
I have a 720 x 1 vector that I would like to modify to include all entries up to and including the first element greater than 100. So if the vector is
[0, 4, 8, 19, 101, 120]
the modified vector would be
[0, 4, 8, 19, 101].
How I would accomplish this? Thanks!

채택된 답변

Adam
Adam 2016년 2월 8일
a = [0, 4, 8, 19, 101, 120];
b = a( 1:find( a > 100, 1 ) );
This assumes the data is sorted which your example seems to imply.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by