MATLAB Spoken Here

The Preferences Directory 3

Posted by Michael Katz,

There are lots of ways a computer program can store user settings. In MATLAB we use a series of different files in a special per-release directory that is in a standard platform-specific place on your disk. In Windows it's usually under the Profiles\user\Application Data directory and on linux under /home/user/. To find out what the directory any given install of MATLAB uses, use the prefdir function:

ans =

C:\WINNT\Profiles\mkatz\Application Data\MathWorks\MATLAB\R2009b

As the directory name indicates, MATLAB creates a separate directory for each release you have installed. When you install MATLAB it looks to see if you have a preferences directory already for that release, if not it goes the latest release you have and copies over the applicable preferences to the new release. Normally this works fine, but in rare cases the installation messes up and you can get your preferences into a weird state. When that kind of thing happens you can just rename the old dir temporarily and try again.

Deleting (or renaming) the preference directory for any given release after it is installed is a big hammer that resets your preferences to the most recent release you have preferences for.

  1. Close MATLAB, after making a note of the prefdir location.
  2. Go to one level above that directory and rename it, e.g. R2009b_OLD
  3. Restart MATLAB

When MATLAB starts and there is no directory for that release, MATLAB will regenerate the preferences directory with default values for everything.

If you don't like the default location for the preferences directory, you can manually specify its location using an environment variable. Instructions to do this are given in this solution.

Finally, the various parts of the preferences are stored in different files in this directory. You can manually, at your own risk, handle upgrading from one release to another. For example you can try migrating shortcuts but not key bindings. Doing this is dangerous though, as we frequently change functionality or how the data is represented on disk. In future posts, I'll highlight some of the more useful preference files.

3 CommentsOldest to Newest

Thank you Mike, this is a precious suggestion. Had I known this “trick” in advance, I could have spared Matlab support service a service request when my editor went nuts and complained bour PARFOR loops in a function which had none!

My matlab crashes when I try to plot my data. It has plotted it successfully just a month or less ago. The command is:


I reinstalled it a few times and it still crashes.

Can you tell me what I can do? It is a student version R2007a.

These postings are the author's and don't necessarily represent the opinions of MathWorks.