Root folder for specified toolbox


s = toolboxdir('tbxFolderName')
s = toolboxdir tbxFolderName


toolboxdir('tbxFolderName') returns a string that is the absolute path to the specified toolbox, tbxFolderName, where tbxFolderName is the folder name for the toolbox.

s = toolboxdir('tbxFolderName') returns the absolute path to the specified toolbox to the output argument, s.

s = toolboxdir tbxFolderName is the command form of the syntax.


Obtain the path for the Control System Toolbox™ software:

s = toolboxdir('control')

MATLAB® returns:

s = C:\Program Files\MATLAB\R2012a\toolbox\control

More About

collapse all


toolboxdir is particularly useful for MATLAB Compiler™ software. The base folder of all toolboxes installed with MATLAB software is:


However, in deployed mode, the base folders of the toolboxes are different. toolboxdir returns the correct root folder, whether running from MATLAB or from an application deployed with the MATLAB Compiler software.

To determine the folder name for a given toolbox, run the following code, substituting the name of a product function for toolbxfcn:

n = 'toolbxfcn';
pat = '(?<=^.+[\\/]toolbox[\\/])[^\\/]+';
regexp(which(n), pat, 'match', 'once')

For example, to determine the product name for Control System Toolbox set n to the name of a function unique to Control System Toolbox, such as dss:

n = 'dss'
pat = '(?<=^.+[\\/]toolbox[\\/])[^\\/]+'
regexp(which(n), pat, 'match', 'once')

Was this topic helpful?