Cropping a vector with on repeating target values
显示 更早的评论
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 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!