Quantcast

Documentation Center

  • Trial Software
  • Product Updates

rmfield

Remove fields from structure

Syntax

Description

example

s = rmfield(s,field) removes the specified field or fields from structure array s. Specify multiple fields using a cell array of strings. The dimensions of s remain the same.

Examples

expand all

Remove Single Field

Define a scalar structure with fields named a, b, and c.

s.a = 1;
s.b = 2;
s.c = 3;

Remove field b.

field = 'b';
s = rmfield(s,field)
s = 
    a: 1
    c: 3

Remove Multiple Fields

Define a scalar structure with fields first, second, third, and fourth.

S.first = 1;
S.second = 2;
S.third = 3;
S.fourth = 4;

Remove fields first and fourth.

fields = {'first','fourth'};
S = rmfield(S,fields)
S = 
    second: 2
     third: 3

Input Arguments

expand all

s — Input structurestructure array

Input structure, specified as a structure array.

Data Types: struct

field — Field name or namescharacter array | cell array of strings

Field name or names, specified as a character array or a cell array of strings.

Example: 'f1'

Example: {'f1';'f2'}

Data Types: char | cell

See Also

| |

Was this topic helpful?