MATLAB: Assigning new matrix values from another matrix’s rows

MATLABmatrix arraymatrix manipulation

Hello All.
I'm wondering if you can help with a simple task.
I have a n*3 matrix with 'triplets' of bits that can be reoccuring within this matrix, e.g.
triplets=[0 1 1; 1 0 1;…];
I'd like to create a new matrix that is n*2 in size based on what the triplet is, e.g. whenever there is a (0 1 1) it should give a pair of values in the new matrix, e.g. (2 2) and (1 0 1) should give (2 0) and so on. So the new matrix should look like
pairs= [2 2; 2 0;…].
Basically I'd like to create a look-up table based on the triplets.
Thank you for your help!

Best Answer

I would just convert the bits into a single integer index,
index=triplets*[4;2;1];
and then perform lookup into an appropriately prepared Nx2 matrix, T.
T(index,:)