>> a = [ 1 4 5 4 4 7 4 4 9 4 ];
2 4 5 7 8
I had a situation in which I was looking for indices many many times. Unfortunately, I could not get around the problem via logical arrays or anything of that sort (there was quite a bit of code which I would have to change otherwise). So I did what any rational programmer would do, that is I wasted a good few precious minuets and one or two unnecessary keystrokes to write this lame code.
I recommend just using logical arrays .....
Christopher Harris (2022). fastFindK (https://www.mathworks.com/matlabcentral/fileexchange/49162-fastfindk), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!