Find the latest indexes in a vector, without for loop.
1 view (last 30 days)
Show older comments
Let's say I have the following vector:
x = [1 2 3 4 3 4 5 6 7 8 5 6 7 8 9 10];
Is there a way, WITHOUT a for loop, to find the indexes of the each of the latest value (ie: the last "5" is at x(11)) so the resulting vector is the following:
y = [1 2 5 6 11 12 13 14 15 16];
Now I can do that with a for loop, just curious to know if there's a more elegant and/or efficient way. I couldn't figure it out.
Cheers,
0 Comments
Accepted Answer
More Answers (0)
See Also
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!