>> 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 (2021). fastFindK (https://www.mathworks.com/matlabcentral/fileexchange/49162-fastfindk), MATLAB Central File Exchange. Retrieved .
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!