RunMat
  • Pricing
RunMat
GitHub
GitHub
DownloadSign InTry in Browser
DesktopRuntimeServer
RunMat

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact

Explore

  • RunMat for academia
  • RunMat vs MATLAB Online
  • Benchmarks

Get product updates and release notes from the RunMat team.

© 2026 Dystr · Made withfor the scientific community.

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.

LicensePrivacy
/
See all docs
Builtin Reference
    • addpath
    • cd
    • copyfile
    • delete
    • dir
    • exist
    • fileattrib
    • fileparts
    • fullfile
    • genpath
    • getenv
    • getpref
    • isenv
    • isfile
    • isfolder
    • ispref
    • ls
    • matlabroot
    • memmapfile
    • 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

addpath — Add folders to the MATLAB/RunMat search path for function and script resolution.

addpath prepends or appends folders to the active search path used to resolve functions, scripts, classes, and data files. Changes apply immediately to the current session, with path ordering behavior matching MATLAB semantics.

Syntax

oldpath = addpath(folder1)
oldpath = addpath(folder1, folder2, ...)
oldpath = addpath(folder1, ..., position)
oldpath = addpath(folder1, ..., "-frozen")
oldpath = addpath(folder1, ..., position, "-frozen")

Inputs

NameTypeRequiredDefaultDescription
folder1AnyYes—Folder, path-list string, or container of folders to add.
folder1AnyYes—First folder argument.
folderNAnyVariadic—Additional folder arguments.
foldersAnyVariadic—Additional folder arguments.
positionStringScalarYes"-begin"Insertion position flag: "-begin" or "-end".
frozenStringScalarYes"-frozen"Compatibility flag accepted but currently ignored.

Returns

NameTypeDescription
oldpathStringScalarPrevious search path string.

Errors

IdentifierWhenMessage
—Folder arguments are not character vectors, string scalars/arrays, cell arrays containing those forms, or mode-admitted numeric character-code tensors.addpath: folder names must be character vectors, string scalars, string arrays, or cell arrays of character vectors
—No folder arguments are provided, or all provided folder tokens are empty/options only.addpath: at least one folder must be specified
—A position option is repeated or multiple position options are provided.addpath: position option must be '-begin' or '-end' and may only appear once
—A pathdef token is provided; loading pathdef.m is not implemented.addpath: loading pathdef.m is not implemented yet
—Current directory cannot be resolved while normalizing a relative folder.addpath: unable to resolve current directory
—A requested folder path does not exist.addpath: folder not found
—A requested path exists but is not a directory.addpath: path is not a folder

How addpath works

  • Folder arguments may be character vectors, string scalars, string arrays, or cell arrays of character vectors or strings. Multi-row char arrays contribute one folder per row (trailing padding is stripped).
  • In runmat compatibility mode only, a one-row numeric tensor can encode one folder name as Unicode scalar values. MATLAB-compatible modes reject this convenience form; use a character vector or string scalar for portable code.
  • MATLAB command form is supported for path-like arguments, including addpath ./SourceCode, addpath ../lib -end, and addpath ./src:../shared -frozen.
  • Multiple folders can be passed in a single argument using the platform path separator (: on Linux/macOS, ; on Windows); this is compatible with genpath.
  • By default, folders are added to the top of the search path. Use '-end' to append or '-begin' to force prepending explicitly. Only one position flag is permitted.
  • The '-frozen' flag is accepted for MATLAB compatibility. RunMat does not currently track frozen entries separately; the flag simply suppresses incompatibility warnings.
  • Duplicate entries are removed automatically so each folder appears at most once. On Windows, comparisons are case-insensitive.
  • Inputs are resolved to absolute, canonicalised paths. Relative inputs are interpreted relative to the current working directory, and ~ expands to the user’s home directory.
  • Folders must exist. RunMat raises addpath: folder '<name>' not found when a directory is missing or addpath: '<name>' is not a folder when the target is not a directory.

Does RunMat run addpath on the GPU?

addpath manipulates host-side configuration. Resident numeric character-code tensors are rejected in MATLAB-compatible modes before gather; admitted RunMat-extension inputs gather to the host before parsing. No acceleration provider hooks or kernels are involved.

GPU memory and residency

No. addpath operates entirely on CPU-side text and path state. A resident numeric character-code tensor is a mode-gated RunMat extension that gathers only after compatibility admission.

Examples

Add a single folder to the top of the search path

mkdir("util/toolbox");
oldPath = path();
addpath("util/toolbox");
newPath = path();
count = fprintf('%s %s\n', oldPath, newPath);

Expected output:

/util/toolbox

Add a relative folder with MATLAB command syntax

mkdir("SourceCode");
oldPath = path();
addpath ./SourceCode
newPath = path();
count = fprintf('%s %s\n', oldPath, newPath);

Expected output:

/SourceCode

Append folders to the end of the search path

mkdir("shared/filters");
mkdir("shared/signal");
oldPath = path();
dirs = ["shared/filters", "shared/signal"];
addpath(dirs, "-end");
newPath = path();
count = fprintf('%s %s\n', oldPath, newPath);

Expected output:

/shared/filters:/shared/signal

Use genpath output to add a folder tree

mkdir("third_party/toolchain");
mkdir("third_party/toolchain/bin");
oldPath = path();
toolchain = genpath("third_party/toolchain");
addpath(toolchain);
newPath = path();
count = fprintf('%s %s\n', oldPath, newPath);

Expected output:

/third_party/toolchain:/third_party/toolchain/bin

Add folders from a cell array

mkdir("src/algorithms");
mkdir("src/visualization");
oldPath = path();
folders = ["src/algorithms", "src/visualization"];
addpath(folders, "-begin");
newPath = path();
count = fprintf('%s %s\n', oldPath, newPath);

Expected output:

/src/algorithms:/src/visualization

Move an existing folder to the top of the search path

mkdir("src/algorithms");
oldPath = path();
addpath("src/algorithms");
newPath = path();
count = fprintf('%s %s\n', oldPath, newPath);

Expected output:

/src/algorithms

Accept the MATLAB -frozen flag

mkdir("vendor/hardware");
oldPath = path();
addpath("vendor/hardware", "-frozen");
newPath = path();
count = fprintf('%s %s\n', oldPath, newPath);

Expected output:

/vendor/hardware

Retrieve the previous path and restore it later

mkdir("analysis/utilities");
oldPath = path();
old = addpath("analysis/utilities");
newPath = path();
path(old);
count = fprintf('%s %s\n', oldPath, newPath);

Expected output:

/analysis/utilities

Combine multiple options

mkdir("contrib");
mkdir("docs/examples");
oldPath = path();
addpath("contrib", "docs/examples", "-end", "-frozen");
newPath = path();
count = fprintf('%s %s\n', oldPath, newPath);

Expected output:

/contrib:/docs/examples

Using addpath with coding agents

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

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

FAQ

Does addpath insist on absolute paths?⌄

No. Relative inputs are resolved against the current working directory and stored as absolute paths.

What happens with duplicate folders?⌄

Existing occurrences are removed before the new ordering is applied, so each folder appears only once.

How do I append instead of prepend?⌄

Supply '-end' as the final argument. Use '-begin' to force prepending explicitly.

Is -frozen supported?⌄

The flag is accepted for MATLAB compatibility. RunMat currently treats it as a no-op but plans to integrate tighter tooling once savepath support lands.

Can I load pathdef.m directly?⌄

Not yet. RunMat will add parity support in a future release. For now, evaluate the file manually and pass the resulting character vector to path.

Do folders need to exist?⌄

Yes. RunMat validates that every entry exists and is a directory before updating the search path.

Will addpath accept a GPU numeric character-code tensor?⌄

Only in runmat compatibility mode. The extension is classified before gather, then the tensor is decoded and the path is updated on the CPU.

Does addpath return the new path?⌄

Like MATLAB, addpath returns the previous path so it can be restored later with path(old).

Related Io functions

Repl Fs

cd · copyfile · delete · dir · exist · fileattrib · fileparts · fullfile · genpath · getenv · getpref · isenv · isfile · isfolder · ispref · ls · matlabroot · memmapfile · 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

Net

accept · read · readline · tcpclient · tcpserver · write

Tabular

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

Audio

audioinfo · audioread

Io

clc · diary · disp · display · format · input

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 · save

Http

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

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how addpath is executed, line by line, in Rust.

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

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 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
  • How addpath works
  • Does RunMat run addpath on the GPU?
  • GPU memory and residency
  • Examples
  • Add a single folder to the top of the search path
  • Add a relative folder with MATLAB command syntax
  • Append folders to the end of the search path
  • Use genpath output to add a folder tree
  • Add folders from a cell array
  • Move an existing folder to the top of the search path
  • Accept the MATLAB -frozen flag
  • Retrieve the previous path and restore it later
  • Combine multiple options
  • Using addpath with coding agents
  • FAQ
  • Related Io functions
  • Repl Fs
  • Net
  • Tabular
  • Audio
  • Io
  • Filetext
  • Archive
  • Hdf5
  • Import
  • Json
  • Mat
  • Http
  • Open-source implementation
  • About RunMat