| MATLAB Function Reference | ![]() |
Graphical Interface
As an alternative to the mkdir function, you can use the Current Directory browser to create new folders. To open it, select Current Directory from the View menu in the MATLAB desktop.
Syntax
mkdirdirnamemkdirparentdir dirnamestatus = mkdir(...,'dirname') [status,msg] = mkdir(...,'dirname')
Description
mkdir creates the directory dirname
dirname in the current directory. It returns a status of 1 if the new directory is created successfully, 2 if it already exists. Otherwise, it returns 0.
mkdir creates the directory parentdir dirname
dirname in the existing directory parentdir.
status = mkdir(...,'dirname')
returns status and also returns a nonempty error message string in msg when an error occurs.
[status,msg] = mkdir(...,'dirname')
returns status and also returns a nonempty error message string in msg when an error occurs.
Examples
To create a subdirectory of testdata called newdir,
mkdir ..\testdata newdir
This second attempt to create the same directory fails with an error message.
[status,msg] = mkdir('..\testdata','newdir')
status =
2
msg =
Directory or file newdir already exists in ..\testdata
See Also
| mislocked | mlock | ![]() |