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

ls — List file and folder names.

ls lists local files and folders, optionally selected by a file, folder, or wildcard name.

Syntax

list = ls()
list = ls(name)

Inputs

name
Type
StringScalar
Required
Yes
Description
File, folder, or wildcard name as a character vector or string scalar.
NameTypeRequiredDefaultDescription
nameStringScalarYes—File, folder, or wildcard name as a character vector or string scalar.

Returns

list
Type
Any
Description
Platform-formatted character array containing the matching names.
NameTypeDescription
listAnyPlatform-formatted character array containing the matching names.

Errors

RunMat:ls:InvalidArity
When
More than one input is supplied.
Message
ls: too many input arguments
RunMat:ls:InvalidName
When
The name input is not a character vector or string scalar.
Message
ls: name must be a character vector or string scalar
RunMat:ls:TooManyOutputs
When
More than one output is requested.
Message
ls: too many output arguments
IdentifierWhenMessage
RunMat:ls:InvalidArityMore than one input is supplied.ls: too many input arguments
RunMat:ls:InvalidNameThe name input is not a character vector or string scalar.ls: name must be a character vector or string scalar
RunMat:ls:TooManyOutputsMore than one output is requested.ls: too many output arguments

Paths and patterns

With no input, ls lists the current folder. Pass a character vector or string scalar to list a different folder, one file, or names selected by * and ?. Relative paths use the current folder and a leading ~ uses the active environment.

The implemented API interprets its input as a filesystem name. Unix command flags are not passed to a host shell, and remote URLs are not currently resolved.

Character-array result

When an output is requested, ls returns characters. In RunMat mode the result has one padded row per entry on every platform, which makes the shape deterministic across native and browser execution. Directory names end with the platform file separator and duplicate wildcard matches are removed.

MATLAB compatibility mode preserves the platform-specific layout: Unix-like targets return a separated character vector, while Windows returns one padded row per name. A pattern with no matches returns an empty character array.

Execution boundary

Enumeration uses RunMat's filesystem service on native and browser/WASM targets. Paths must be host text; numeric and provider-resident inputs reject before provider or filesystem access.

Calling ls without an output writes the listing to the active console. Capturing the result suppresses that console rendering.

Examples

List the current folder

root = tempname();
mkdir(root);
fid = fopen(fullfile(root, 'current.txt'), 'w'); fclose(fid);
start = cd(root);
listing = ls;
cd(start);
names = cellstr(listing);
rmdir(root, 's');

Expected output:

listing contains current.txt

List a folder

root = tempname();
mkdir(root);
fid = fopen(fullfile(root, 'alpha.txt'), 'w'); fclose(fid);
mkdir(fullfile(root, 'nested'));
listing = ls(root);
names = cellstr(listing);
rmdir(root, 's');

Expected output:

listing contains alpha.txt and nested

List matching files

root = tempname();
mkdir(root);
fid = fopen(fullfile(root, 'one.m'), 'w'); fclose(fid);
fid = fopen(fullfile(root, 'two.txt'), 'w'); fclose(fid);
listing = ls(fullfile(root, '*.m'));
names = cellstr(listing);
rmdir(root, 's');

Expected output:

listing contains one.m

List one file

root = tempname();
mkdir(root);
file = fullfile(root, 'payload.dat');
fid = fopen(file, 'w'); fclose(fid);
listing = ls(file);
rmdir(root, 's');

Expected output:

listing contains payload.dat

Handle no matches

root = tempname();
mkdir(root);
listing = ls(fullfile(root, '*.missing'));
rmdir(root);

Expected output:

listing is empty

Use the portable row layout

root = tempname();
mkdir(root);
fid = fopen(fullfile(root, 'a.txt'), 'w'); fclose(fid);
fid = fopen(fullfile(root, 'long-name.txt'), 'w'); fclose(fid);
listing = ls(root);
rmdir(root, 's');

Expected output:

one padded character row per entry

Match inside nested folders

root = tempname();
mkdir(fullfile(root, 'src'));
fid = fopen(fullfile(root, 'src', 'solver.m'), 'w'); fclose(fid);
listing = ls(fullfile(root, 'src', '*.m'));
rmdir(root, 's');

Expected output:

listing contains solver.m

Using ls with coding agents

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

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

FAQ

Which path values can I pass to ls?⌄

Use a character vector or string scalar. Numeric values, cells, character matrices, and nonscalar string arrays are rejected before filesystem access.

How does ls represent directories?⌄

A directory name ends with the platform's file separator in RunMat's portable row layout.

How does the output differ by compatibility mode?⌄

RunMat mode uses one padded character row per entry on every platform. MATLAB compatibility mode follows the platform-specific MATLAB layout: a separated character vector on Unix-like systems and padded rows on Windows.

Does ls support operating-system flags?⌄

Not currently. The input is interpreted as a file, folder, or wildcard name through RunMat's filesystem service rather than passed to an operating-system shell.

Does ls support remote URLs?⌄

No. The current implementation resolves local paths in the active native or browser filesystem.

Related Io functions

Repl Fs

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

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 ls is executed, line by line, in Rust.

  • View the source for ls 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
  • Paths and patterns
  • Character-array result
  • Execution boundary
  • Examples
  • List the current folder
  • List a folder
  • List matching files
  • List one file
  • Handle no matches
  • Use the portable row layout
  • Match inside nested folders
  • Using ls 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