Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB   

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).

Outputs

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

subsasgn | subsref

Tutorials

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS