https://jp.mathworks.com/help/nav/ref/shortenpath.html
shortenpath - Shorten path by removing redundant nodes - MATLAB
This MATLAB function shortens the path between a start pose and goal pose by removing redundant nodes along the path.
shortenpathremovingredundantnodes