I have data = [1 1.2 1.3 1.5 1.8]
data = [1 1.2 1.3 1.5 1.8]
I want to find closest values before and after from data for this point, b = 1.23
b = 1.23
How do I do this?
Here is another method. The vector data need not be sorted and b can be positive or negative.
data
b
[~,I] = min(abs(data-b)); c = data(I);
2.1m questions
2.1m answers
60 comments
57.0k users