Hello Yen Tien,
I understand you would like to simulate a 2 link rigid body system. The best way to achieve this would be to use Simscape Multibody. The links can be created using various joints available and specify constraints, force elements and sensors according to your requirements. The simulations can be observed in the mechanics explorer.
To get started with Simscape Multibody, please refer to the following documentation: https://in.mathworks.com/help/sm/
Hope this information helps out with your implementation !