MATLAB: Finding the nearest valaue

nearest value

I have two sets of value
s=
38.9906 27.8590 18.6908 25.0184 27.5565 24.7551
21.6141 30.9522 42.2398 52.9675 38.4323 45.0781
39.3954 41.1888 39.0694 22.0141 34.0112 30.1668
S1= 19.0865
36.2719
44.6415
I HAVE to compare 1st value of S1 with first values of s and display them
for example the nearest value in s is
18.6908
42.2398
39.0694
please help

Best Answer

HINT:
abs(bsxfun(@minus,s,S1));