RunMat
  • Pricing
RunMat
GitHub
GitHub
Sign inTry in browser
DesktopRuntimePhysicsCADAdministrationAgent

Get RunMat updates

New releases, guides and examples.

Product+
  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download
Math+
  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting
Physics+
  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA
Industries+
  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance
Learn+
  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students
Compare+
  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons
Company+
  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms

Product

  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download

Math

  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting

Physics

  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA

Industries

  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance

Learn

  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students

Compare

  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons

Company

  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms
GitHubXLinkedIn

© Dystr, Inc. · RunMat v0.7.1, Nov 17, 2026

RunMat® is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

/
See all docs
Builtin Reference
    • addpath
    • cd
    • copyfile
    • delete
    • dir
    • exist
    • fileattrib
    • fileparts
    • filesep
    • fullfile
    • genpath
    • getenv
    • getpref
    • isenv
    • isfile
    • isfolder
    • ispref
    • ls
    • matlabroot
    • memmapfile
    • memmapfile.subsasgn
    • memmapfile.subsref
    • mkdir
    • movefile
    • open
    • opentoline
    • path
    • pathsep
    • pcode
    • pwd
    • readstruct
    • rehash
    • restoredefaultpath
    • rmdir
    • rmpath
    • run
    • savepath
    • setenv
    • setpref
    • system
    • tempdir
    • tempname
    • uigetdir
    • uigetfile
    • uiputfile
    • unsetenv
    • userpath
    • what
    • winqueryreg
    • xmlread
    • xmlwrite

mkdir — Create directories and return logical status with optional diagnostics.

mkdir creates a directory hierarchy through the active filesystem service.

Syntax

[status, msg, msgID] = mkdir(folderName)
[status, msg, msgID] = mkdir(parentFolder, folderName)

Inputs

folderName
Type
StringScalar
Required
Yes
Description
Folder path to create, including missing intermediate folders.
parentFolder
Type
StringScalar
Required
Yes
Description
Parent path to create when necessary.
folderName
Type
StringScalar
Required
Yes
Description
Relative child path beneath parentFolder.
NameTypeRequiredDefaultDescription
folderNameStringScalarYes—Folder path to create, including missing intermediate folders.
parentFolderStringScalarYes—Parent path to create when necessary.
folderNameStringScalarYes—Relative child path beneath parentFolder.

Returns

status
Type
LogicalArray
Description
Logical true when the folder exists after the operation.
msg
Type
StringScalar
Description
Character-row diagnostic, empty after a newly created folder.
msgID
Type
StringScalar
Description
Character-row diagnostic identifier.
NameTypeDescription
statusLogicalArrayLogical true when the folder exists after the operation.
msgStringScalarCharacter-row diagnostic, empty after a newly created folder.
msgIDStringScalarCharacter-row diagnostic identifier.

Returned values from mkdir depend on how many outputs the caller requests.

Errors

RunMat:mkdir:InvalidArgumentCount
When
The call has zero or more than two inputs.
Message
mkdir: expected one folder or a parent and relative child
RunMat:mkdir:InvalidFolder
When
A folder input is not a character row or string scalar.
Message
mkdir: folder names must be character vectors or string scalars
RunMat:mkdir:InvalidFolderName
When
A required folder name is empty.
Message
mkdir: folder name must not be empty
IdentifierWhenMessage
RunMat:mkdir:InvalidArgumentCountThe call has zero or more than two inputs.mkdir: expected one folder or a parent and relative child
RunMat:mkdir:InvalidFolderA folder input is not a character row or string scalar.mkdir: folder names must be character vectors or string scalars
RunMat:mkdir:InvalidFolderNameA required folder name is empty.mkdir: folder name must not be empty
RunMat:mkdir:FolderMustBeRelativeThe child in the two-input form is rooted.mkdir: folder name must be relative when a parent folder is supplied
RunMat:mkdir:TargetNotDirectoryThe target or an intermediate component is not a directory.mkdir: a path component is not a directory
RunMat:mkdir:OSErrorThe filesystem cannot create the folder.mkdir: unable to create folder
RunMat:mkdir:DirectoryExistsThe target already exists as a directory.Directory already exists.

Create directories

mkdir(folderName) creates the named directory and any missing intermediate directories. mkdir(parentFolder, folderName) creates a relative child beneath the parent and creates the parent when necessary.

With outputs, status is a logical scalar. A newly created directory returns true with empty character rows for msg and msgID. An existing directory also returns true and supplies an informational message and identifier.

Errors and execution

When outputs are requested, an operational filesystem failure returns false with diagnostic text. Without outputs, the same failure raises an error; an existing directory emits a warning governed by the session's warning settings.

Folder names accept character rows and scalar strings. Relative paths use the current folder, a leading ~ expands through the active environment, and native Windows paths may use drive-letter or UNC syntax. The filesystem service receives the path without rewriting platform-specific components.

Directory creation runs through the host or browser filesystem service rather than an acceleration provider. Folder names must be host text; numeric or provider-resident values are rejected without a device transfer.

Examples

Create a directory

folder = tempname();
status = mkdir(folder);
existsAfter = exist(folder, 'dir');
rmdir(folder);

Expected output:

status is logical true and existsAfter is nonzero

Create a missing parent and nested child

parent = tempname();
status = mkdir(parent, fullfile('archive', '2026'));
created = exist(fullfile(parent, 'archive', '2026'), 'dir');
rmdir(parent, 's');

Expected output:

status is logical true and the nested directory exists

Inspect an existing-directory result

folder = tempname();
mkdir(folder);
[status, msg, msgID] = mkdir(folder);
rmdir(folder);

Expected output:

status is true and msg and msgID describe the existing directory

Create intermediate directories from one path

root = tempname();
folder = fullfile(root, 'data', 'archive');
status = mkdir(folder);
created = exist(folder, 'dir');
rmdir(root, 's');

Expected output:

status is logical true and every path component is created

Create a directory from a character row

folder = char(tempname());
status = mkdir(folder);
created = exist(folder, 'dir');
rmdir(folder);

Expected output:

character-row paths use the same filesystem operation

Capture a target-file failure

target = tempname();
fid = fopen(target, 'w');
fclose(fid);
[status, msg, msgID] = mkdir(target);
stillFile = exist(target, 'file');
delete(target);

Expected output:

status is logical false, diagnostics are populated, and the file remains

Inspect successful diagnostic outputs

folder = tempname();
[status, msg, msgID] = mkdir(folder);
messageSize = size(msg);
idSize = size(msgID);
rmdir(folder);

Expected output:

successful creation returns empty character rows

Using mkdir with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how mkdir changes the result.

Run a small mkdir example, explain the result, then change one input and compare the output.

FAQ

Does mkdir create intermediate directories?⌄

Yes. Both the single-path form and a missing parent in the two-input form create the required directory chain.

What happens when the target exists as a file?⌄

The file is never overwritten. Output forms return logical false and diagnostics; a no-output call raises an error.

Can mkdir run on a GPU?⌄

No. Directory creation is a filesystem operation, and its text path arguments do not require device transfers.

Which path value types does mkdir accept?⌄

A character row, scalar string, or one-element string array is accepted. Other values reject before filesystem access.

How do I handle creation failures programmatically?⌄

Request status, message, and message ID. Status is logical false after an operational failure; the other outputs describe it. A no-output call raises an error.

Related Io functions

Repl Fs

addpath · cd · copyfile · delete · dir · exist · fileattrib · fileparts · filesep · fullfile · genpath · getenv · getpref · isenv · isfile · isfolder · ispref · ls · matlabroot · memmapfile · memmapfile.subsasgn · memmapfile.subsref · movefile · open · opentoline · path · pathsep · pcode · pwd · readstruct · rehash · restoredefaultpath · rmdir · rmpath · run · savepath · setenv · setpref · system · tempdir · tempname · uigetdir · uigetfile · uiputfile · unsetenv · userpath · what · winqueryreg · xmlread · xmlwrite

Net

accept · read · readline · tcpclient · tcpserver · write

Tabular

arrayDatastore · csvread · csvwrite · detectImportOptions · dlmread · dlmwrite · fileDatastore · getvaropts · parquetDatastore · parquetinfo · parquetread · readcell · readmatrix · readtable · readtimetable · setvaropts · setvartype · spreadsheetImportOptions · writecell · writematrix · writetable · writetimetable · xlsread · xlswrite

Audio

audioinfo · audioread

Io

clc · diary · disp · display · format · input

Data

commit · data.copy · data.create · data.delete · data.exists · data.export · data.import · data.inspect · data.list · data.move · data.open · DataArray.chunk_shape · DataArray.codec · DataArray.dtype · DataArray.fill · DataArray.name · DataArray.rank · DataArray.read · DataArray.resize · DataArray.shape · DataArray.write · Dataset.array · Dataset.arrays · Dataset.attrs · Dataset.begin · Dataset.get_attr · Dataset.has_array · Dataset.id · Dataset.path · Dataset.refresh · Dataset.set_attr · Dataset.set_attrs · Dataset.snapshot · Dataset.version · DataTransaction.abort · DataTransaction.commit · DataTransaction.create_array · DataTransaction.delete_array · DataTransaction.fill · DataTransaction.id · DataTransaction.resize · DataTransaction.set_attr · DataTransaction.set_attrs · DataTransaction.status · DataTransaction.write

Filetext

fclose · feof · fgetl · fgets · fileread · filewrite · fopen · fprintf · fread · frewind · fwrite · readlines · writelines

Archive

gunzip · gzip · unzip

Hdf5

h5disp · h5info · h5read · h5write · h5writeatt · hdf5info · hdf5read · hdf5write

Import

importdata · textscan

Json

jsondecode · jsonencode

Mat

load · matfile · matlab.io.MatFile.subsasgn · matlab.io.MatFile.subsref · save

Http

sendmail · urldecode · urlencode · weboptions · webread · websave · webwrite

Source you can read

Every RunMat function's source is public. Read exactly how mkdir is executed, line by line, in Rust.

  • View the source for mkdir in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

About RunMat

RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • Create directories
  • Errors and execution
  • Examples
  • Create a directory
  • Create a missing parent and nested child
  • Inspect an existing-directory result
  • Create intermediate directories from one path
  • Create a directory from a character row
  • Capture a target-file failure
  • Inspect successful diagnostic outputs
  • Using mkdir with coding agents
  • FAQ
  • Related Io functions
  • Repl Fs
  • Net
  • Tabular
  • Audio
  • Io
  • Data
  • Filetext
  • Archive
  • Hdf5
  • Import
  • Json
  • Mat
  • Http
  • Source you can read
  • About RunMat