value in new column if two values if two columns match two others Matlab

Viewed 238

So i have two very long matrices. A sample is given below:

First_Matrix:

A = [...
1 1 1; 
1 1 2; 
1 1 3;
1 2 1; 
1 2 2; 
1 2 3;
1 3 1; 
1 3 2; 
1 3 3];

Second Matrix

B = [...
1 1 916;
1 2 653;
1 3 114];

And I would like a thirds matrix that would combine the first matrix with the third column of the second matrix, based on the values in the first two column of the 2 matrices matching (being the same).

So Ouput_Matrix:

C = [...
1 1 1 916; 
1 1 2 916; 
1 1 3 916; 
1 2 1 653; 
1 2 2 653; 
1 2 3 653;
1 3 1 114; 
1 3 2 114; 
1 3 3 11];

What would be the best way to do this?

Thanks in advance

3 Answers
Related