How to identify the approximate value from two different vectors?
Show older comments
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
2 Comments
James Tursa
on 10 Sep 2015
How did you get your result? If I was looking for the closest match in B to the first value in A (14.553) I would have guessed your result would be 14.440. But you list 14.120. Is this a typo? Same comment for the 2nd element.
dpb
on 10 Sep 2015
Perhaps the output is sorted in ascending order, James. That'd select the values for the first two but rearrange them.
Accepted Answer
More Answers (1)
dpb
on 10 Sep 2015
Assuming the above comment is true...
>> interp1(B,B,A,'nearest')
ans =
14.4400 14.1200 90.4190 90.8500
2 Comments
D Bhuiyan
on 10 Sep 2015
Image Analyst
on 10 Sep 2015
Again, for the second element, how is 14.5534 (second element of A) closer to 14.1201 (from B vector and also your output), than is 14.4404 (also from B vector)???
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!