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: Finding position in array
Replies: 10   Last Post: Jun 6, 2014 6:42 PM

 Messages: [ Previous | Next ]
 Helveticus Posts: 12 Registered: 11/3/13
Finding position in array
Posted: Jun 5, 2014 7:04 PM

Hi

I have an array of real numbers, let's say e.g.

a = [1.23, 3.5, 6, 23.54, 44.234, 60.8];

The array is sorted in ascending order.

Now I have a new value, let's say 8.54 and I want to find the position in the array a. The position would be after element 6 and before element 23.54. I.e. I should somehow retrieve the index position 3 (corresponding to 6) or 4 (corresponding to 23.54).

How can I do that efficiently in Matlab? I tried out the find method but it doesn't work.

Date Subject Author
6/5/14 Helveticus
6/6/14 dpb
6/6/14 Helveticus
6/6/14 dpb
6/6/14 Bruno Luong
6/6/14 dpb
6/6/14 Bruno Luong
6/6/14 dpb
6/6/14 Bruno Luong
6/6/14 dpb
6/6/14 Bruno Luong