MATLAB: Do I receive the error “[Fatal Error] :-1:-1: Premature end of file” at MATLAB startup

MATLAB

When starting MATLAB, why do I receive the following error?
[Fatal Error] :-1:-1: Premature end of file

Best Answer

This error occurs when the MATLAB preferences or path becomes corrupt. To resolve this issue, clear the MATLAB preferences and reset the path. To do so, following these instructions, depending on your operating system:
Windows:
======
1. Browse to your Application Data folder:
C:\Documents and Settings\<username>\Application Data\ (Windows 2000/XP)
C:\Users\<username>\AppData\Roaming (Vista)
Note: this is a hidden folder on all platforms
2. Navigate to the MathWorks\MATLAB folder in Application Data. Remove the folder that corresponds to the MATLAB version (i.e. R2008a).
NOTE: Do not remove any folder that ends with "_licenses."
3. Once this has been removed, restart MATLAB. This directory will be recreated the next time you start MATLAB.
Linux/Unix/Mac:
======
1. In a terminal window, run the following command:
cd ~/.matlab
2. Once in the .matlab folder, delete the folder for the version of MATLAB you have. For example, if you have R2008a, run the command:
rm -rf R2008a
3. Once cleared, restart MATLAB. The preferences should be recreated.
If the error returns, try resetting MATLAB's path using the instructions below:
1. Generate a new pathdef.m file for MATLAB by running the following commands in MATLAB:
restoredefaultpath
savepath
rehash toolboxcache
Once complete, restart MATLAB to enable the changes. If you still encounter an error after following these steps, please contact the Installation and Licensing team here: