matlabroot
MATLAB root folder
Syntax
Description
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.
Examples
Get MATLAB Install Location
Get the location where MATLAB is installed.
matlabroot
ans = 'C:\Program Files\MATLAB\R2017b'
Get Full Path to Folder
Get the full path to the
toolbox/matlab/general
folder for the current
system.
fullfile(matlabroot,'toolbox','matlab','general')
ans = 'C:\Program Files\MATLAB\R2017b\toolbox\matlab\general'
Set Current Folder to MATLAB Root
cd(matlabroot)
Add Folder to Path
Add the folder myfiles
to the MATLAB search path.
addpath([matlabroot '/toolbox/local/myfiles'])
More About
matlabroot
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
.
$matlabroot
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.
Algorithms
matlabroot on Macintosh
On Macintosh systems running R2008b (V7.7) or newer versions, running
matlabroot
returns, for example
/Applications/MATLAB_R2008b.app
On Mac systems running R2008a (V7.6) or earlier versions,
matlabroot
returns, for example
/Applications/MATLAB_R2008a
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
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
Version History
Introduced before R2006a
See Also
fullfile
| path
| toolboxdir
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)