This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.


Root folder


mr = matlabroot


matlabroot returns the name of the folder where the MATLAB® software is installed. Use matlabroot to create a path to MATLAB and toolbox folders that does not depend on a specific platform, MATLAB version, or installation location.

mr = matlabroot returns the name of the folder in which the MATLAB software is installed and assigns it to mr.


Get the location where MATLAB is installed:


MATLAB returns:

C:\Program Files\MATLAB\R2009a

Produce a full path to the toolbox/matlab/general folder that is correct for the platform on which it is executed:


Change the current folder to the MATLAB root folder:


To add the folder myfiles to the MATLAB search path, run

addpath([matlabroot '/toolbox/local/myfiles'])

More About

collapse all


matlabroot as Folder Name

The term matlabroot also refers to the folder where MATLAB files are installed. For example, "save to matlabroot/toolbox/local" means save to the toolbox/local folder in the MATLAB root folder.

Using $matlabroot as a Literal

In some files, $matlabroot is literal. In those files, MATLAB interprets $matlabroot as the full path to the MATLAB root folder. For example, including the line:


in javaclasspath.txt, adds myfile.jar, which is located in the toolbox/local folder, to the static Java® class path.

Sometimes, particularly in older code examples, the term $matlabroot or $MATLABROOT is not meant to be interpreted literally but is used to represent the value returned by the matlabroot function.

matlabroot on Macintosh Platforms

In R2008b (V7.7) and more recent versions, running matlabroot on Apple Macintosh platforms returns


In versions prior to R2008b (V7.7), such as R2008a (V7.6), running matlabroot on Macintosh platforms returns, for example


When you use GUIs on Macintosh platforms, you cannot directly view the contents of the MATLAB root folder. For more information, see Navigating Within the MATLAB Root Folder on Macintosh Platforms.

Introduced before R2006a

Was this topic helpful?