MATLAB: Do I get an Undefined function or variable ‘matlabrc'” error and loss of command functionality when I start MATLAB

MATLAB

I receive the following error when starting MATLAB:
??? Undefined function or variable 'matlabrc'.
Afterward, all functions return 'Undefined function or variable' when inputted to the command window.

Best Answer

This error can result from having a MATLABPATH environment variable set. If this variable is set and does not include $matlabroot\toolbox\local (where $matlabroot is the root MATLAB directory), MATLAB will not be able to load up any functions that are not in the path(s) referenced by the variable. This includes all built-in MATLAB functions.
To resolve this error you will need to remove the offending MATLABPATH variable or update it to include the $matlabroot\toolbox\local directory.
To verify that the variable is set on your machine, you can run the following command within the MATLAB command prompt:
!set MATLABPATH
This error may also occur when MATLAB has been installed from bad or incomplete media. If the matlabroot/toolbox/local directory is missing userpath.m or matlabrc.m files, try downloading the software and re-installing using the newly downloaded files.
See the related solutions below for other path or undefined function issues.