y[t_] := Piecewise[{{7, t < q1[[1]]}, {4, t <= q1[[2]]}}, 1]; x[t_] := Piecewise[{{0, t < q1[[3]]}, {1, t <= q1[[4]]}}, 2]; {{
Or perhaps using BinLists
!:
k = BinLists[dist4, {Join[{Min[dist4[[All, 1]]]}, q1[[1 ;; 2]], {Max[dist4[[All, 1]]]}]}, {Join[{Min[dist4[[All, 2]]]}, q1[[3 ;; 4]], {Max[dist4[[All, 2]]]}]} ]; Flatten[Replace[ Flatten[MapIndexed[{#1, #2} &, k, {2}], 1], {{x__}, t_} :> (Join[{#}, {9 - 3 First@t + Last@t }] & /@ {x}), {1}], 1]
source share