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
    • fieldnames
    • getfield
    • isfield
    • orderfields
    • rmfield
    • setfield
    • struct
    • structfun

rmfield — Remove one or more top-level fields from a structure or structure array.

rmfield returns a structure with exact, case-sensitive field names removed while preserving structure-array shape and retained values.

Syntax

S2 = rmfield(S, fields)
S2 = rmfield(S, fields, ...)

Inputs

S
Type
Any
Required
Yes
Description
Input structure or structure array.
fields
Type
Any
Required
Yes
Description
Character row, string value, string array, or cell collection of field names.
fields
Type
Any
Required
Yes
Description
First field-name value or collection.
more_fields
Type
Any
Required
Variadic
Description
Additional RunMat-only field-name arguments.
NameTypeRequiredDefaultDescription
SAnyYes—Input structure or structure array.
fieldsAnyYes—Character row, string value, string array, or cell collection of field names.
fieldsAnyYes—First field-name value or collection.
more_fieldsAnyVariadic—Additional RunMat-only field-name arguments.

Returns

S2
Type
Any
Description
Structure or structure array with the selected fields removed.
NameTypeDescription
S2AnyStructure or structure array with the selected fields removed.

Errors

RunMat:rmfield:TooManyOutputs
When
More than one output is requested.
Message
rmfield: too many output arguments
RunMat:rmfield:NotEnoughInputs
When
No field-name argument is supplied.
Message
rmfield: not enough input arguments
RunMat:rmfield:InvalidTarget
When
The first input is not a structure.
Message
rmfield: expected struct or struct array
IdentifierWhenMessage
RunMat:rmfield:TooManyOutputsMore than one output is requested.rmfield: too many output arguments
RunMat:rmfield:NotEnoughInputsNo field-name argument is supplied.rmfield: not enough input arguments
RunMat:rmfield:InvalidTargetThe first input is not a structure.rmfield: expected struct or struct array
RunMat:rmfield:FieldNameTypeA field-name input is not a character row, string value, string array, or cell collection of scalar text.rmfield: field names must be string scalars, character vectors, or single-element string arrays
RunMat:rmfield:FieldNameEmptyA field name is empty.rmfield: field names must be nonempty character vectors or strings
RunMat:rmfield:MissingFieldA requested field does not exist on every input structure element.Reference to non-existent field
RunMat:rmfield:RebuildFailedThe updated structure array cannot retain its original shape.rmfield: failed to rebuild struct array

Field removal

S2 = rmfield(S,fields) returns a structure with every requested top-level field removed. S may be a scalar structure or structure array. fields may be a character row, string value, string array, or cell array of character rows and scalar strings.

Every distinct requested name must exist on every structure element. Names are exact and case-sensitive. Duplicate names are removed once; an empty collection removes nothing, while an empty individual name is invalid.

Compatibility and structure arrays

MATLAB compatibility mode accepts one field-name argument. RunMat mode also accepts separate variadic field-name arguments and flattens them in call order. Use one string array or cell array when the source must remain within the MATLAB form.

Removing fields preserves structure-array dimensions and updates the shared ordered schema. Ordinary cell arrays are not structure arrays, regardless of their contents.

Value and residency preservation

The input value is not mutated. RunMat consumes or copies the outer value according to ordinary value semantics and removes only field-map entries. Retained values preserve their class, payload, and provider ownership.

rmfield launches no accelerator kernel and does not gather nested resident values. It runs as a host metadata operation and forms a fusion boundary.

Examples

Remove one field

s = struct('name', 'entry', 'score', 42);
t = rmfield(s, 'score')

Expected output:

t contains only the name field

Remove fields listed in a cell array

cfg = struct('mode', 'fast', 'rate', 60, 'debug', true);
trimmed = rmfield(cfg, {'rate', 'debug'})

Expected output:

trimmed contains only the mode field

Remove fields listed in a string array

stats = struct('mean', 10, 'median', 9, 'stdev', 2);
reduced = rmfield(stats, ["mean", "median"])

Expected output:

reduced contains only the stdev field

Remove a field from every structure

entries = struct('name', {'first', 'second'}, 'id', {101, 102});
trimmed = rmfield(entries, 'id')

Expected output:

every element retains only name

Remove an optional field

record = struct('id', 7, 'notes', 'draft');
if isfield(record, 'notes')
    record = rmfield(record, 'notes');
end

Expected output:

record contains only id

Use separate field arguments in RunMat mode

s = struct('a', 1, 'b', 2, 'c', 3);
t = rmfield(s, 'a', "b")

Expected output:

t contains only c

Using rmfield with coding agents

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

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

FAQ

Does rmfield modify its input in place?⌄

No. It returns a value with the selected fields removed; the caller's original value retains ordinary value semantics.

Which field-name inputs are accepted?⌄

One character row, string value, string array, or cell array of character rows and scalar strings. RunMat mode additionally accepts multiple separate field-name arguments.

What happens when a field is missing?⌄

The call fails with a missing-field error. For a structure array, every requested name must exist on every element.

Are duplicate or empty names accepted?⌄

Duplicate names are removed once. Empty individual names are invalid; an empty string or cell collection requests no removals.

Can rmfield remove nested fields?⌄

No. It removes top-level fields only.

Does rmfield gather GPU data?⌄

No. Retained resident field values remain with their owning provider because only outer metadata changes.

Related Structs functions

fieldnames · getfield · isfield · orderfields · setfield · struct · structfun

Source you can read

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

  • View the source for rmfield 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
  • Field removal
  • Compatibility and structure arrays
  • Value and residency preservation
  • Examples
  • Remove one field
  • Remove fields listed in a cell array
  • Remove fields listed in a string array
  • Remove a field from every structure
  • Remove an optional field
  • Use separate field arguments in RunMat mode
  • Using rmfield with coding agents
  • FAQ
  • Related Structs functions
  • Source you can read
  • About RunMat