In Matlab I'm trying to find the nearest value of time1 to each value of time2 without going over the specific value of time2.

Is there a way to speed this up? It's very slow.
Here is my current code:

time1 = 0:1/44100:1-1/44100;
time2 = 0:1/48000:1-1/48000;

n1(1:size(time2,2)) = 0; %initialize n1 to be the size of the time2 variable
for i = 1:size(time2,2)
for j = 1:size(time1,2)
if time1(j)<=time2(i)
n1(i) = j;