MATLAB: Finding approximate indices in a monotonically increasing array

MATLABnumerical integration

I need to find the indices of an entry in a monotonically increasing array, where the value of this indices is "ref"(as shown below)
I create my increasing array "t" as follow
dt=1/10e9;
N=13600000;
t=((0:N-1)*dt);
ref=1.39459e-05;
I've already tried using the find function but it leads to incorrect results or multiple indices or no answers at all.
can anyone suggest any way I can get this working

Best Answer

You can use Nearest Neighbor search. If you have stats toolbox:
f = knnsearch(t',ref)
f =
139460
>> t(f)
ans =
1.39459e-05
IF you don't have the stats toolbox:
>> tri = delaunayn(t');
f = dsearchn(t',tri,ref)
f =
139460
Because you have so many points you have to be patient since it takes time.