I have two matrix with two columns. For example
A = [2 2; 4 3; 6 5; 8 3; 10 2]B = [2 1; 3 2; 5 2; 8 2; 10 1]
I want to find the values from the first column that intersect. I can do this using 'C = intersect(A(:,1),B(:,1)). However, the output that I actaully want is a new matrix which keeps the corresponding values from the 2nd column of matrix A and B, along with the intercept values not just the intercept values which are spat out from the intersect function. So I end up with:
D = [2 8 10; 2 3 2; 1 2 1]
The above is a simplified example but I want to be able to apply it to a dataset with thousands of rows.
Best Answer