Hi,
Here are a few resources which might be helpful for this purpose.
- https://www.mathworks.com/company/newsletters/articles/teaching-robotic-control-concepts-with-a-robotic-arm-an-arduino-microcontroller-and-simulink.html
- https://www.mathworks.com/videos/developing-multivariable-control-systems-for-robotics-81954.html
- https://www.mathworks.com/help/control/ug/multi-loop-pid-control-of-a-robot-arm.html
- https://www.mathworks.com/matlabcentral/fileexchange/27293-force-position-control-of-a-robot-manipulator-using-pid-controller
- https://www.mathworks.com/matlabcentral/fileexchange/71509-robot-arm?s_tid=FX_rc3_behav
Since you are new to MATLAB, these resources would provide with end to end solution and relvant information starting from basics.
Here is a link to a MATLAB answer which is a bit similar to yours and might provide some insights:
I hope this resolves your issue.