First Element Greater Than

165 Ansichten (letzte 30 Tage)
Alex Lu
Alex Lu am 8 Feb. 2016
Beantwortet: Adam am 8 Feb. 2016
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!

Akzeptierte Antwort

Adam
Adam am 8 Feb. 2016
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.

Weitere Antworten (0)

Kategorien

Mehr zu Shifting and Sorting Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by