Robotics toolbox and within that SerialLink Library is a must for this code to run in MATLAB. Preferably 2018 version MATLAB.
Trajectory is obtained by specifying initial and final joint angles and by using SerialLink’s optimal path selection algorithm. This code draws the path taken by the manipulator.