subsref - Maple Help

Online Help

All Products    Maple    MapleSim


MTM

  

subsref

  

subscript reference of arrays

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

subsref(A,index)

Parameters

A

-

array or record

index

-

record, list, or array

Description

• 

The subsref command mirrors subscript referencing in MATLAB®. Using A(index) in MATLAB® will produce the same result as subsref(A,index) indices.  

• 

In Maple, indexing is usually done using square brackets, as in A[i,j,k]. For an n-dimensional Array, A, you must specify n values.  subsref allows you to provide fewer than n values, in which case the Array is indexed as if it only had that number of dimensions, with the last dimension being the size of the product of all remaining dimensions.

For example subsref(A,[i]) can be used to index into an m x n Array.  In this case for the purpose of indexing, A is considered to be a 1D array of size mn in Fortran_order.

• 

The specified index for any dimension can be an array itself.  In this case, multiple values will be fetched from A.  An array will be returned.  

• 

More complicated indexing, such as A(index1).index2(index3) require the use of a Record or array of Records with "type" and "subs" fields to specify the subreference for each indexing operation.  The "type" field can have the values "()", "{}", or ".".  There is no distinction between the first two, "()" and "{}", which indicate array-indexing. The "." type indicates an index into a Record.  The "subs" field contains the actual index value.  For example A(i,j) can be looked up via subsref(A,Record(type="()",subs=Array([i,j]))); Similarly A(i,j).name is accessible via subsref(A,< Record(type="()",subs=Array([i,j])) Record(type=".",subs="name") > );.

Examples

withMTM&comma;subsref&colon;

AArray1&comma;2&comma;3&comma;4

A1234

(1)

subsrefA&comma;1&comma;1

1

(2)

RRecordname=Paul

RRecordname=Paul

(3)

subsrefR&comma;Recordtype=.&comma;:-subs=name

Paul

(4)

BArrayRecordname=Paul&comma;Recordname=Bryan

BRecordname=PaulRecordname=Bryan

(5)

subsrefB&comma;Recordtype=()&comma;:-subs=2&comma;Recordtype=.&comma;:-subs=name

Bryan

(6)

See Also

Fortran_order

MTM[subsasgn]

Record