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

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact
  • License
  • Privacy

Learn

  • Docs
  • Blog
  • Benchmarks
  • RunMat vs MATLAB Online

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.

/
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

delete — Remove files in MATLAB and RunMat.

delete(filename) removes files without producing a MATLAB-facing output, while delete(obj) invalidates handle objects or listeners. delete(___, "ResolveSymbolicLinks", tf) controls whether a symbolic-link filename removes the link or its target.

Syntax

delete(filename)
delete(filename1, filename2, ...)
delete(___, ResolveSymbolicLinks=tf)

Inputs

NameTypeRequiredDefaultDescription
filenameAnyYes—Filename/pattern string, string array, char matrix, cell array of path strings, or handle input.
filename1AnyYes—First filename/pattern/handle input.
filenameNAnyVariadic—Additional filename/pattern/handle inputs.
filenameAnyYes—Filename, filename collection, or wildcard pattern.
ResolveSymbolicLinksStringScalarYes—Name of the symbolic-link resolution option.
tfAnyYesfalseScalar logical or numeric zero/one selecting link-target deletion.

Errors

IdentifierWhenMessage
RunMat:delete:InvalidInputInput arguments are missing or contain unsupported filename value types.delete: invalid input
RunMat:delete:InvalidHandleHandle deletion inputs are mixed with filename inputs or contain unsupported handle values.delete: invalid handle input
RunMat:delete:EmptyFilenameA filename input is empty after trimming.delete: filename cannot be empty
RunMat:delete:InvalidPatternWildcard pattern parsing or structure validation fails.delete: invalid wildcard pattern
RunMat:DELETE:FileNotFoundTarget path does not exist or pattern matches no files.delete: file not found
RunMat:delete:DirectoriesTarget path is a directory instead of a file.delete: cannot delete directories
RunMat:DELETE:PermissionDeniedUnderlying filesystem operation fails while deleting files.delete: filesystem deletion failed

How delete works

  • Accepts individual paths, string arrays, cell arrays of character vectors, and char matrices. Each element targets one file.
  • Accepts handle objects (handle) and event listeners, marking them invalid (isvalid returns false) without touching the filesystem when invoked with non-string inputs.
  • Expands shell-style wildcards (* and ?) using MATLAB-compatible rules. Patterns must resolve to existing files; otherwise, the builtin throws RunMat:DELETE:FileNotFound.
  • Rejects folders. When a target is a directory, RunMat raises RunMat:DELETE:Directories, matching MATLAB’s “Use rmdir to remove directories” diagnostic.
  • Propagates operating-system failures (for example, permission errors or read-only files) through RunMat:DELETE:PermissionDenied.
  • Expands ~ to the user’s home directory and resolves relative paths against the current working folder (pwd).
  • Treats empty character vectors or empty string scalars as invalid inputs and raises RunMat:DELETE:EmptyFilename.
  • When passed an empty string array or empty cell array, the builtin performs no action and returns without error, just like MATLAB.
  • ResolveSymbolicLinks accepts scalar logical values or exact numeric zero/one, including all eight integer classes. False removes the link itself; true removes the resolved file or empty-folder target and leaves the link. The option is rejected for handle deletion.
  • Multiple targets are processed sequentially. If a later target fails, earlier successful deletions are not rolled back.

Does RunMat run delete on the GPU?

delete performs host-side filesystem I/O. Acceleration providers do not implement a delete hook, and resident arguments are rejected without a download.

GPU memory and residency

No. delete executes on the CPU and rejects resident arguments before provider or filesystem access.

Examples

Deleting a single temporary file

fname = "scratch.txt";
fid = fopen(fname, "w");
fclose(fid);
delete(fname)

Removing multiple files with a wildcard pattern

logs = ["log-01.txt", "log-02.txt"];
for i = 1:numel(logs)
    fid = fopen(logs(i), "w");
    fclose(fid);
end
for i = 1:numel(logs)
    delete(logs(i));
end

Deleting files listed in a string array

files = ["stageA.dat", "stageB.dat"];
for i = 1:numel(files)
    fid = fopen(files(i), "w");
    fclose(fid);
end
delete(files)

Handling missing files safely with try/catch

try
    delete("missing-file.txt");
catch err
    disp(err.identifier)
    disp(err.message)
end

Cleaning up build artifacts stored under your home folder

delete("~/runmat/build/*.o")

Deleting char-matrix filenames generated programmatically

names = char("stage1.tmp", "stage2.tmp");
for row = 1:size(names, 1)
    fname = strtrim(names(row, :));
    fid = fopen(fname, "w");
    fclose(fid);
end
delete(names)

Deleting graphics handles after use

fig = figure;
delete(fig);
tf = isvalid(fig)

Expected output:

tf =
     0

Using delete with coding agents

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

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

FAQ

What message IDs does delete produce?⌄

Missing files raise RunMat:DELETE:FileNotFound, directories raise RunMat:DELETE:Directories, wildcard syntax issues raise RunMat:DELETE:InvalidPattern, operating-system failures raise RunMat:DELETE:PermissionDenied, and invalid handle inputs raise RunMat:DELETE:InvalidHandle.

Can I delete folders with delete?⌄

No. MATLAB reserves folder deletion for rmdir. RunMat follows suit and throws RunMat:DELETE:Directories when a target is a directory.

Does delete support multiple filenames at once?⌄

Yes. Pass a string array, a cell array of character vectors, or a char matrix. Each element is deleted in turn.

How are wildcard patterns resolved?⌄

RunMat uses MATLAB-compatible globbing: * matches any sequence, ? matches a single character, and the pattern is evaluated relative to the current folder (pwd) unless you pass an absolute path.

What happens when a wildcard matches nothing?⌄

The builtin raises RunMat:DELETE:FileNotFound (just like MATLAB) and leaves the filesystem unchanged.

Do empty arrays raise errors?⌄

Empty string arrays or empty cell arrays simply result in no deletions. Empty strings, however, are invalid and trigger RunMat:DELETE:EmptyFilename.

How do GPU inputs behave?⌄

Resident inputs are rejected before provider or filesystem access. Paths and control values must already be host values.

Does delete preserve symbolic links?⌄

By default, deleting a symbolic link removes the link itself. Set ResolveSymbolicLinks to logical true or exact numeric one to remove the resolved target instead; the link then remains.

Can I detect failures programmatically?⌄

Wrap the call in try/catch and inspect err.identifier and err.message just as you would in MATLAB.

Will delete follow relative paths updated by cd?⌄

Yes. Paths are interpreted using the process working directory, so calling cd before delete mirrors MATLAB’s behaviour.

Related Io functions

Repl Fs

addpath · cd · copyfile · 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 delete is executed, line by line, in Rust.

  • View the source for delete 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
  • Errors
  • How delete works
  • Does RunMat run delete on the GPU?
  • GPU memory and residency
  • Examples
  • Deleting a single temporary file
  • Removing multiple files with a wildcard pattern
  • Deleting files listed in a string array
  • Handling missing files safely with try/catch
  • Cleaning up build artifacts stored under your home folder
  • Deleting char-matrix filenames generated programmatically
  • Deleting graphics handles after use
  • Using delete 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