The motion can be restricted by using 'Translational Hard Stop' block from Simscape -> Foundation Library -> Mechanical Library.
The following documentation link provides more information on this block:
Hope this helps.
Regards,
Vaibhav Awale
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!