To train a transformation matrix that maps vectors from group A to group B in MATLAB, the Procrustes analysis function procrustes can be used. The documentation page explains this with an example.
The following code reproduces your use case and applies the process.
A = rand(30000, 20);
B = rand(30000, 20);
[~, T] = procrustes(A, B);
A_transformed = A * T.T;
This will transform each vector in group A so that it aligns with the corresponding vector in group B.