Quantcast

Documentation Center

  • Trial Software
  • Product Updates

substruct

Create structure argument for subsasgn or subsref

Syntax

S = substruct(type1, subs1, type2, subs2, ...)

Description

S = substruct(type1, subs1, type2, subs2, ...) creates a structure with the fields required by an overloaded subsref or subsasgn method. Each type string must be one of '.', '()', or '{}'. The corresponding subs argument must be either a field name (for the '.' type) or a cell array containing the index vectors (for the '()' or '{}' types).

Output Arguments

S

struct with these fields:

  • type: one of '.', '()', or '{}'

  • subs: subscript values (field name or cell array of index vectors)

Examples

Call subsref with arguments equivalent to the syntax:

B = A(3,5).field;

where A is an object of a class that implements a subsref method

Use substruct to form the input struct, S:

S = substruct('()',{3,5},'.','field');

Call the class method:

B = subsref(A,S);

The struct created by substruct in this example contains:

S(1)

ans = 

    type: '()'
    subs: {[3]  [5]}

S(2)

ans = 

    type: '.'
    subs: 'field'

See Also

|

Tutorials

Was this topic helpful?