This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Folder containing preferences, history, and layout files


folder = prefdir
folder = prefdir(1)


prefdir returns the folder that contains

  • Preferences for MATLAB® and related products (matlab.prf)

  • Command history file (History.xml)

  • MATLAB shortcuts (shortcuts_2.xml)

  • MATLAB desktop layout files (MATLABDesktop.xml and Your_Saved_LayoutMATLABLayout.xml)

  • Other related files

folder = prefdir assigns to folder the name of the folder containing preferences and related files.

folder = prefdir(1) creates a folder for preferences and related files if one does not exist. If the folder does exist, the name is assigned to folder.


View the location of the preferences folder:


Make the preferences folder become the current folder:


% Then, view the files for customizing MathWorks® products:

On Windows® platforms, go directly to the preferences folder in Microsoft® Windows Explorer



  • You must have write access to the preferences folder. Otherwise, MATLAB generates an error in the Command Window when you try to change preferences. This can happen if the folder is hidden, for example: myname/.matlab/R2009a.

Introduced before R2006a

Was this topic helpful?