I'm simulating event positions and times, and histogramming then in the XY plane. I want to find for each event, the time difference to the next event in the same bin. I feel liek this should be a ~4 liner or so...
posXY = rand(nEv,2)
times = rand(nEv,1)
posBin = [2 2];
[hitMatrix, ~] = hist3(posXY, posBin);
then I want to find (for each event, in a given bin--I made four bins!) the time the next event occurs in that position bin. So i thought about sorting the events by their times, and using the indices to pick out the correct events that also occur in the same bin... making a logical and looping over events.. but I can't quite nail the whole sequence down. Do you have any tips?
I appreciate your input, Michael B.