| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
As an alternative to mkdir, use the Current Folder browser.
mkdir('folderName')
mkdir('parentFolder','folderName')
status = mkdir(...)
[status,message,messageid] = mkdir(...)
mkdir('folderName') creates the folder folderName, where folderName can be an absolute or a relative path.
mkdir('parentFolder','folderName') creates the folder folderName in parentFolder, where parentFolder is an absolute or relative path. If parentFolder does not exist, MATLAB attempts to create it. See the Remarks section.
status = mkdir(...) creates the specified folder. When the operation is successful, it returns a status of logical 1. When the operation is unsuccessful, it returns logical 0.
[status,message,messageid] = mkdir(...) creates the specified folder, and returns the status, message string, and MATLAB message ID. The value given to status is logical 1 for success, and logical 0 for error.
If an argument specifies a path that includes one or more nonexistent folders, MATLAB attempts to create the nonexistent folder. For example, for
mkdir('myFolder\folder1\folder2\targetFolder')if folder1 does not exist, MATLAB creates folder1, creates folder2 within folder1, and creates targetFolder within folder2.
Create a subfolder called newdir in the current folder:
mkdir('newdir')Create a subfolder called newFolder in the folder testdata, using a relative path, where newFolder is at the same level as the current folder:
mkdir('../testdata','newFolder')In this example, the first attempt to create newFolder succeeds, returning a status of 1, and no error or warning message or message identifier:
[s, mess, messid] = mkdir('../testdata', 'newFolder')
s =
1
mess =
''
messid =
''Attempt to create the same folder again. mkdir again returns a success status, and also a warning and message identifier informing you that the folder exists:
[s,mess,messid] = mkdir('../testdata','newFolder')
s =
1
mess =
Directory "newFolder" already exists.
messid =
MATLAB:MKDIR:DirectoryExistscopyfile, cd, dir, ls, movefile, rmdir
![]() | mislocked | mkdir (ftp) | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |