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 th
if the data is sorted you can use find:
i_lower = find(data <= b,1,'last'); i_higher = find(data >= b,1,'first'); lower_than_b = data(i_lower) higher_than_b = data(i_higher)