Cropping a vector with on repeating target values
Show older comments
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.
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!