Main Content


MATLAB root folder



mr = matlabroot returns a character vector giving the full path to the folder where MATLAB® is installed. Use matlabroot to create a path to MATLAB and toolbox folders that is independent of platform, MATLAB version, or installation location.


collapse all

Get the location where MATLAB is installed.

ans =

    'C:\Program Files\MATLAB\R2017b'

Get the full path to the toolbox/matlab/general folder for the current system.

ans =

    'C:\Program Files\MATLAB\R2017b\toolbox\matlab\general'

Add the folder myfiles to the MATLAB search path.

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

More About

collapse all


The term matlabroot can also refer to the folder where MATLAB files are installed.

For example, in the documentation, the phrase "save to matlabroot/toolbox/local" means save to the toolbox/local folder in the MATLAB root folder. If your MATLAB root folder is C:\Program Files\MATLAB\R2017b, then you would save to the folder C:\Program Files\MATLAB\R2017b\toolbox\local.


The macro $matlabroot can be used literally in some types of files to represent the full path to the MATLAB root folder.

For example, including the line $matlabroot/toolbox/local/myfile.jar in javaclasspath.txt, adds the full path of myfile.jar to the static Java® class path. For more information, see Static Path of Java Class Path.

Sometimes, particularly in older code examples, the term $matlabroot or $MATLABROOT is also used to represent the value returned by the matlabroot function.


collapse all

matlabroot on Macintosh

On Macintosh systems running R2008b (V7.7) or newer versions, running matlabroot returns, for example


On Mac systems running R2008a (V7.6) or earlier versions, matlabroot returns, for example


On Mac systems, you cannot directly view the contents of the MATLAB root folder. For more information, including how to view the contents, see Navigating Within the MATLAB Root Folder on macOS Platforms.

Extended Capabilities

Version History

Introduced before R2006a