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.
Get the location where MATLAB is installed:
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
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.
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.
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.