This function calculates numerically the closest point to a mesh surface from the given point. In my example a point [x, y, z] outside of an ellipsoidal area [X, Y, Z] is given to calculate the closest point to the surface and also calculate a distance value for classification algorithm if one uses gaussian distribution for classifying things.
Ingo Hermann (2020). PointOnSurface(X, Y, Z, x, y, z, accuracy) (https://www.mathworks.com/matlabcentral/fileexchange/65599-pointonsurface-x-y-z-x-y-z-accuracy), MATLAB Central File Exchange. Retrieved .