MATLAB: When running SURF or MESH commands, why does MATLAB crash with “MATLAB has encountered an internal error and needs to close”

MATLAB

Why is MATLAB crashing everytime I use graphics functions in MATLAB? After running a script in MATLAB which uses the SURF or MESH command MATLAB crashes with this error "MATLAB has encountered an internal error and needs to close".

Best Answer

This is likely due to an issue between MATLAB and your machine's graphics hardware.
To work around using your machines graphics hardware you can execute the following command in MATLAB:
opengl('software')
This command will tell MATLAB to emulate the OpenGL renderer using software instead of using the graphics hardware on your machine. For more information, see the following:
As of MATLAB 6.0 (R12), OpenGL has become available as an additional rendering method to complement Zbuffer and painters. This method can utilize graphics hardware for accelerated performance when drawing large and complicated graphics. However, hardware is not necessary and many of the benefits of OpenGL can be obtained through software emulation. In the event that the OpenGL renderer has been picked by MATLAB's auto-selector and hardware is available, MATLAB will attempt to utilize it.
When utilizing the OpenGL rendering method, it is possible that an error may occur either in the driver or in our code, in which case MATLAB will crash or error out. When this happens there are several things that you can do to resolve the issue.
Please see the OpenGL description in the figure's 'Renderer' property here:
For additional OpenGL related information, see the following URL:
If the above information does not help, then please note that nvoglv64.DLL is an NVIDIA graphics driver dll. You may have a version of the driver which is incompatible with MATLAB. Updating the driver to a newer version, or rolling back the driver if you recently updated could resolve this issue.
Related Question