MATLAB: Finding the index of a matrix corresponding to a particular column of another matrix

index finding

I have two matrices like, A= [4 12 ; 2 6] and B = [9 4 8 12 ; 2 2 4 6] I want get the relevant index of B corresponding to the 1st column in matrix A. (i.e- first column of A is 4 and 2. And the index corresponding to that in matrix A is index 2 )

Best Answer

You can try this:
A= [4 12 ; 2 6];
B = [9 4 8 12 ; 2 2 4 6];
selected_col=1;
col_in_B=find(all(A(:,selected_col)==B,1));