Documentation

matlabroot

MATLABroot folder

Syntax

mr = matlabroot

Description

example

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

Examples

collapse all

Get the location where MATLAB is installed.

matlabroot
ans = 'C:\Program Files\MATLAB\R2017b'

Get the full path to thetoolbox/matlab/generalfolder for the current system.

fullfile(matlabroot,'toolbox','matlab','general')
ans = 'C:\Program Files\MATLAB\R2017b\toolbox\matlab\general'
cd(matlabroot)

Add the foldermyfilesto the MATLAB search path.

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

More About

collapse all

matlabroot

The termmatlabrootcan also refer to the folder where MATLAB files are installed.

For example, in the documentation, the phrase "save tomatlabroot/toolbox/local" means save to thetoolbox/localfolder in the MATLAB root folder. If your MATLAB root folder isC:\Program Files\MATLAB\R2017b, then you would save to the folderC:\Program Files\MATLAB\R2017b\toolbox\local.

$matlabroot

The macro$matlabrootcan 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.jarinjavaclasspath.txt, adds the full path ofmyfile.jarto the static Java®class path. For more information, seeStatic Path.

Sometimes, particularly in older code examples, the term$matlabrootor$MATLABROOTis also used to represent the value returned by thematlabrootfunction.

Algorithms

collapse all

matlabrooton Macintosh

OnMacintoshsystems running R2008b (V7.7) or newer versions, runningmatlabrootreturns, for example

/Applications/MATLAB_R2008b.app

OnMacsystems running R2008a (V7.6) or earlier versions,matlabrootreturns, for example

/Applications/MATLAB_R2008a

OnMacsystems, you cannot directly view the contents of the MATLAB root folder. For more information, including how to view the contents, seeNavigating Within the MATLAB Root Folder on Macintosh Platforms.

Introduced before R2006a

Was this topic helpful?