MATLAB: Going back to original matrix

going from a nx2 matrix to an nx1 vectormatrix formatmatrix manipulation

Hello,
I have a matrix that is 3×2 A= [1 1; 1 2; 2 2];
I also have a vector B that is nx1 (assume n equals to 27) this vector has three possible values 1, 2, 3.
When I apply Z= A(B,:) I get a matrix nx2 where the number one in vector B was changed for 1 1, the number 2 by 1 2 and the number 3 by 2 2.
Then I have a matrix L that is in the same format as Z i.e. is an nx2 matrix with values 1 1, 1 2 or 2 2 for each row.
Is there anyway to transform this matrix L into the same form as vector B? i.e. change 1 1 for 1, 1 2 for 2 and 2 2 for 3?
The matrix A is an specific case of a general formula as is the vector B. Thus, I need a way to have the format of B when I have a matrix in the format of A without hard coding it for instance with a conditional specifiying that 1 1 equals 1; 1 2 equals 2 and 2 2 equals 3
Thank you very much

Best Answer

[~,B] = ismember(L,A,'rows')