I have the following matrix:
data = {{0.795718, 0.737, 0.813, 1.27301}, {0.846782, 0.767, 0.86,1.2859},
{0.742211, 0.691, 0.767, 1.27714}, {0.754719, 0.706, 0.783,1.27319},
{0.743044, 0.691, 0.783, 1.26768}, {0.745167, 0.706,0.783, 1.28189},
{0.815733, 0.752, 0.86,1.25376}, {0.551127, 0.553,0.553, 1.2084}};
each row is made up of a list of 4 elements: {x1,x2,x3,y}
. I would like to apply a rule to the matrix that allows me to select, row by row, only one of the first 3 elements, the one that is closest to a certain value, let us say xbest
(eg 0.8 in the example with the data above), let us call this element xwin
. Eventually, I would like have a new matrix with rows of 2 elements only: {xwin,y}
.
Your help is appreciated.