Main Content

matlabroot

MATLAB root folder

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.

example

Examples

collapse all

Get the location where MATLAB is installed.

matlabroot
ans =

    'C:\Program Files\MATLAB\R2017b'

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'
cd(matlabroot)

Add the folder myfiles to the MATLAB search path.

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

More About

collapse all

Algorithms

collapse all

Extended Capabilities

expand all

Version History

Introduced before R2006a