
Arrays question regarding intervals
Posted:
May 23, 2013 6:17 AM


Hello,
I would like to implement a function (using the function find, if i can, but not needed), that must be fast, and must do the following(i will give an example): if i have x=[1 2 3 4 5 4 6 4 3 5 2 1 9] and y=[3.5 4.5 7], it will find all the consecutive values from x so that y(k) is in the interval (x(i), x(i+1)) or (x(i+1), x(i)). For example, in my problem, for y(1) if will return 0 0 1 1 0 0 0 1 1 1 1 0 because 3.5 is between (3, 4) and (3,4) and (2,5) which is positions 3,4 and 8,9,10,11 from vector x. Or, if i will find y(3) which is 7, it will display (0 0 0 0 0 0 0 0 0 0 0 1 1) because y(3) is in (x(13),x(12)). so i simbolises the i's for which is true what i said before. I could do a function to check every 2 consecutive x'ses from my interval, but if i have to check for 1000 elements from x and 2000 elements from y, this will take a long time. That's why i was thinking i could use find in some way.
Thanks for a future reply!
Yours, Emanuel

