MATLAB: Finding the n’th element satisfying a condition

efficientfind

I have a huge array A (about 30 million elements) and I'm trying to extract the n'th element satisfying a condition A == b. Currently, I' using the following:
x = max(find(A == b,n))
Is there a more efficient way to do this since I need to do this several times in my code?
Thanks.

Best Answer

That looks good to me. The only thing that might make it faster would be to index instead of use max():
idx = find(A==B,n,'first')
idx(end)