Added try-catch to the matlab script

Changed the way we find unreachable input positions to use try-catch and
so we don't need to find the reachable workspace.  Function still
returns NaN when there's no solution.