| MATLAB Function Reference | ![]() |
Directory containing preferences, history, and layout files
prefdir
d = prefdir
d = prefdir(1)
prefdir returns the directory that contains
Preferences for MATLAB® and related products (matlab.prf)
Command history file (history.m)
MATLAB shortcuts (shortcuts.xml)
MATLAB desktop layout files (MATLABDesktop.xml and Your_Saved_LayoutMATLABLayout.xml)
Other related files
The directory might be in a hidden folder, for example, myname/.matlab/R2008a. How to access hidden folders depends on your platform:
On Microsoft® Windows® platforms, in any folder window, select Tools > Folder Options. Click the View tab, and under Advanced settings, select Show hidden files and folders. Then you should be able to see the folder returned by prefdir.
On Apple® Macintosh® platforms, in the Finder, select Go -> Go to Folder. In the resulting dialog box, type the path returned by prefdir and press Enter.
d = prefdir assigns to d the name of the directory containing preferences and related files.
d = prefdir(1) creates a directory for preferences and related files if one does not exist. If the directory does exist, the name is assigned to d.
The preferences directory MATLAB uses depends on the release. The preference directory naming and preference migration practice used from R13 through R14SP2 was changed starting in R14SP3 to address backwards compatibility problems. The differences are relevant primarily if you run multiple versions of MATLAB, and especially if one version is prior to R14SP3:
For R2008a back through and including R2006a, and R14SP3, MATLAB uses the name of the release for the preference directory. For example, it uses R2008a, R2007b, ... through R14SP3. When you install R2008a, MATLAB migrates the files in the R2007b preferences directory to the R2008a preferences directory. While running R2008a through R14SP3, any changes made to files in those preferences directories (R2008a through R14SP3) are used only in their respective versions. As an example, commands you run in R2008a will not appear in the Command History when you run R2007b, and so on. The converse is also true.
The R14 through R14SP2 releases all share the R14 preferences directory. While running R14SP1, for example, any changes made to files in the preferences directory, R14, are used when you run R14SP2 and R14. As another example, commands you run in R14 appear in the Command History when you run R14SP2, and the converse is also true. The preferences are not used when you run R14SP3 or later versions because those versions each use their own preferences directories.
All R13 releases use the R13 preferences directory. While running R13SP1, for example, any changes made to files in the preferences directory, R13, are used when you run R13. As an example, commands you run in R13 will appear in the Command History when you run R13SP1, and the converse is true. The preferences are not used when you run any R14 or later releases because R14 and later releases use different preferences directories, and the converse is true.
Upon startup, MATLAB 7.6 (R2008a) looks for and if found, uses the R2008a preferences directory. If not found, MATLAB creates an R2008a preferences directory. This happens when the R2008a preferences directory is deleted. MATLAB then looks for the R2007b preferences directory, and if found, migrates the R2007b preferences to the R2008a preferences. If it does not find the R2007b preferences directory, it uses the default preferences for R2008a. This process also applies when starting MATLAB 7.5 through 7.1.
If you want to use default preferences for R2008a, and do not want MATLAB to migrate preferences from R2007b, the R2008a preferences directory must exist but be empty when you start MATLAB. If you want to maintain some of your R2008a preferences, but restore the defaults for others, in the R2008a preferences directory, delete the files for which you want the defaults to be restored. One file you might want to maintain is history.m—for more information about the file, see Viewing Statements in the Command History Window in the MATLAB Desktop Tools and Development Environment documentation.
Run
prefdir
MATLAB returns
ans = C:\WINNT\Profiles\my_user_name\MATHWORKS\Application Data\MathWorks\MATLAB\R2008a
Running dir for the directory shows these files and others for MathWorks™ products:
. history.m .. matlab.prf cwdhistory.m MATLABDesktop.xml shortcuts.xml MATLAB EditorDesktop.xml
In MATLAB, run cd(prefdir) to change to that directory.
On Windows platforms, go directly to the preferences directory in Microsoft Windows Explorer by running winopen(prefdir).
Fonts, Colors, and Other Preferences in the MATLAB Desktop Tools and Development Environment documentation
![]() | ppval | preferences | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |