MATLAB: Find matching values from two unequal size arrays

match

I have two arrays of unequal length. [lat1 lon1 pCO2] say 200000 values in each column [lat2 lon2] say 100000 values in each column
I want to find where both lat2=lat1 and lon2=lon1, then take the pCO2 value from the first array and plug it into the second array as a new column.

Best Answer

>> A1 = [1,2,3;4,5,6;7,8,9]
A1 =
1 2 3
4 5 6
7 8 9
>> A2 = [1,2;0,0;0,0;4,5]
A2 =
1 2
0 0
0 0
4 5
>> [ida,idb] = ismember(A2,A1(:,1:2),'rows');
>> A2(:,3) = NaN;
>> A2(ida,3) = A1(idb(ida),3)
A2 =
1 2 3
0 0 NaN
0 0 NaN
4 5 6