Main Content

toolboxdir

Root folder for specified toolbox

Description

example

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.

Examples

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

Tips

  • 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')
    
    control

Extended Capabilities

Version History

Introduced in R2006a