fastFindK

Find k occurances of a value in array. Slightly faster than the usual routs.
85 Downloads
Updated 26 Jan 2015

View License

Example :
>> a = [ 1 4 5 4 4 7 4 4 9 4 ];
>> find(a==4,5)

ans =

2 4 5 7 8

>> fastFindK(4,a,5)

ans =

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 .....

Cite As

Christopher Harris (2024). fastFindK (https://www.mathworks.com/matlabcentral/fileexchange/49162-fastfindk), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2013a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Structures in Help Center and MATLAB Answers
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0