The Math Forum

Search All of the Math Forum:

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

Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 2
Registered: 5/23/13
Arrays question regarding intervals
Posted: May 23, 2013 6:17 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


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

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.