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.


Specify MATLAB current working folder after startup


= MLStartDir(path)
MLStartDir path
out = MLStartDir(path)


= MLStartDir(path) sets the MATLAB® working folder after startup. Use this syntax when working directly in a worksheet.

MLStartDir path sets the MATLAB working folder after startup. Use this syntax in a VBA macro.

out = MLStartDir(path) lets you catch errors when executing MLStartDir in a VBA macro. If MLStartDir fails, then out is a string containing error code. Otherwise, out is 0.

Input Arguments


Path to the new MATLAB working folder after startup.

Output Arguments


Execution status that contains 0 if the command succeeded. Otherwise, out contains a string with an error code.


collapse all

Set the MATLAB working folder to d:\work after start up in a worksheet cell.


If your folder path includes a space, embed the path in single quotation marks within double quotation marks.

Set the MATLAB working folder to d:\my work in a VBA macro.

MLStartDir "'d:\my work'"

Set the MATLAB working folder to d:\work after start up in a VBA macro. Return the execution status out.

out = MLStartDir("d:\work")


  • This function does not work like the standard Microsoft® Windows® Start In setting, because it does not automatically run startup.m or matlabrc.m in the specified folder.

  • The working folder changes only if you run MATLAB after you run this function. Running this function while MATLAB is running does not change the working folder for the current session. In this case, MATLAB uses the specified folder as the working folder when it is restarted.

See Also

Introduced in R2006b