This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Root folder for specified toolbox


s = toolboxdir(toolboxName)



s = toolboxdir(toolboxName) returns a character vector containing the absolute path to the root folder for the specified toolbox.

It is important to use the toolboxdir function when writing code using MATLAB® Compiler™. A toolbox can have a different path depending on whether it is running from MATLAB or from an application deployed with the MATLAB Compiler. toolboxdir ensures that the correct path is used.


collapse all

Suppose that you have MATLAB R2017b installed with the Control System Toolbox™. Get the path for the Control System Toolbox.

s = toolboxdir('control')
s  = C:\Program Files\MATLAB\R2017b\toolbox\control

Input Arguments

collapse all

Toolbox name, specified as a character vector or string scalar.

Data Types: char | string


  • To determine the toolbox name to use for a given toolbox, run this code, substituting toolbxfcn with the name of a function in the product.

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

    For example, to determine the toolbox 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')

Introduced in R2006a

Was this topic helpful?