| MATLAB Function Reference | ![]() |
Graphical Interface
As an alternative to the mkdir function, you can click the
icon in the Current Directory browser to add a directory.
Syntax
Description
mkdir(' creates the directory dirname')
dirname in the current directory.
mkdir(' creates the directory parentdir','dirname')
dirname in the existing directory parentdir, where parentdir is an absolute or relative pathname.
[status,message,messageid] = mkdir(...,'dirname')
creates the directory dirname in the existing directory parentdir, returning the status, a message, and the MATLAB error message ID (see error and lasterr). Here, status is 1 for success and is 0 for no error. Only one output argument is required.
Create a Subdirectory in Current Directory
To create a subdirectory in the current directory called newdir, type
Create a Subdirectory in Specified Parent Directory
To create a subdirectory called newdir in the directory testdata, which is at the same level as the current directory, type
Return Status When Creating Directory
In this example, an attempt to create newdir fails because the directory already exists, and the error information is returned:
[s,mess,messid] = mkdir('../testdata','newdir') s = 0 mess = Directory "newdir" already exists messid = MATLAB:MKDIR:DirectoryExists
See Also
copyfile, cd, dir, fileattrib, filebrowser, ls, movefile, rmdir
| mislocked | mkpp | ![]() |