MATLAB: How to identify the approximate value from two different vectors

Hi, I have two different vectors where
A(Ref)=[14.553 14.100 90.4512 90.901]
B= [12.34 14.120 14.440 13.59 90.419 90.850 300.123]
I want to identify the approximate value of the A(Ref) vector from B vector. Can anybody please help me how to identify the A(Ref) values from B vector(approximate/closest)?
Output result should be
ans = [14.120 14.440 90.419 90.850]
from B

Best Answer

I agree with James that your output does not match your description. But see if this does what you want:
ARef = [14.553 14.100 90.4512 90.901];
B = [12.34 14.120 14.440 13.59 90.419 90.850 300.123];
for k = 1 : length(ARef)
[minDistance, indexOfMinDistance] = min(abs(ARef(k) - B));
out(k) = B(indexOfMinDistance);
end
% Show in command window:
out
Result:
out = 14.44 14.12 90.419 90.85