With the above code, this correction should yield you your required output:
You might be able to write this functionality more compactly by using the function find. Also: If you find the lower bound first, and the 'look' array is expected to be sorted, then wont the higher bound be the next element?
2 Comments
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/388-find-position-of-the-values-of-an-array-in-a-second-array#comment_424
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/388-find-position-of-the-values-of-an-array-in-a-second-array#comment_424
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/388-find-position-of-the-values-of-an-array-in-a-second-array#comment_435
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/388-find-position-of-the-values-of-an-array-in-a-second-array#comment_435
Sign in to comment.