Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Arrays question regarding intervals
Replies: 3   Last Post: May 23, 2013 12:55 PM

 Messages: [ Previous | Next ]
 Antonache Posts: 2 Registered: 5/23/13
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

Date Subject Author
5/23/13 Antonache
5/23/13 Bruno Luong
5/23/13 Antonache
5/23/13 Bruno Luong