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);
1.4m articles
1.4m replys
5 comments
57.0k users