I have large vector (~10,000 entries) which contains values ranging from 70 to 0.
An abridged version could look like:
V = [70 10 5 3 2 1 0 0 0 1 2 3 5 10]
I would like to create a new vector that only contains the values preceeding V = 1 (in example, [70 10 5 3 2]). I do not want this new vector to include the values following V = 1 (even when V begins increasing above 0).
Currently, I have simplified this vector using:
index = V > 1
Which yields:
index =
1×14 logical array
1 1 1 1 1 0 0 0 0 0 1 1 1 1
I am not sure if this is a good first step, but I am at a dead end now. I am not sure how to select the first set of ones, knowing that in practice there will not always be the same number of values that I would like to extract.
Any help would be appreciated, and I would be happy to provide more information about my application/constraints.

 채택된 답변

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

릴리스

R2017a

질문:

2019년 2월 2일

답변:

2019년 2월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by