MATLAB: Compare values in array1 with array2 and store a new value in a new array if match found

arrayscompare arrayscompare two arrays and return a new array

I have a problem of comparing two arrays on Matlab scripting and below I have explained.
%Array1 has one column
Array1=[1.56357468109619
1.61046126078761
1.81562025010618
1.68554263182706
2.01705143067582
2.20087755213663
1.90411420706440
1.86094752726691
1.92177045043986
1.78486562784988
1.85660250759791
1.53693897473804
2.01744530015071
1.90897780937155]
%Array2 has two columns
Array2=
2.02888000000000 600;
1.80918000000000 500;
1.65728000000000 400;
1.52849000000000 300;
1.35517000000000 200;
1.13304000000000 100;
1.00398000000000 0
I want to compare each value of the single column in Array1 with the values in column 1 of Array2. If the value of Array1 matches or fits within a range or within a given limit range with a value in column1 of Array2, I wish to create a new array (Array3) with the corresponding value in Column2 of Array2.
Example: 1st value in column1 of Array1 = 1.61046126078761 Since this value is closest to 3rd value of column1 in Array2, I want to assign the first value in Array3 as 400. Likewise I want to check all the values in Array1 and assign the values and create the new Array3
Would be great if someone could help me out! Thanks in advance!
Best wishes Sarala

Best Answer

>> D = abs(bsxfun(@minus,Array1,Array2(:,1).'));
>> [~,X] = min(D,[],2);
>> Array3 = Array2(X,2)
Array3 =
300
400
500
400
600
600
500
500