If mat1 and mat2 are the first and second matrices you described, this should do the join you need with indexing functions.
[~, I] = ismember(mat2(:, 2), mat1(:, 1));
Output = [mat2(:, 1) mat1(I, 2:end)]
1
solved Find and replace using Matlab [closed]