 subsref - Maple Help

MTM

 subsref
 subscript reference of arrays 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

 > $\mathrm{with}\left(\mathrm{MTM},\mathrm{subsref}\right):$
 > $A≔\mathrm{Array}\left(\left[\left[1,2\right],\left[3,4\right]\right]\right)$
 ${A}{≔}\left[\begin{array}{cc}{1}& {2}\\ {3}& {4}\end{array}\right]$ (1)
 > $\mathrm{subsref}\left(A,\left[1,1\right]\right)$
 ${1}$ (2)
 > $R≔\mathrm{Record}\left(\mathrm{name}="Paul"\right)$
 ${R}{≔}{\mathrm{Record}}{}\left({\mathrm{name}}{=}{"Paul"}\right)$ (3)
 > $\mathrm{subsref}\left(R,\mathrm{Record}\left(\mathrm{type}=".",':-\mathrm{subs}'="name"\right)\right)$
 ${"Paul"}$ (4)
 > $B≔\mathrm{Array}\left(\left[\mathrm{Record}\left(\mathrm{name}="Paul"\right),\mathrm{Record}\left(\mathrm{name}="Bryan"\right)\right]\right)$
 ${B}{≔}\left[\begin{array}{cc}{\mathrm{Record}}{}\left({\mathrm{name}}{=}{"Paul"}\right)& {\mathrm{Record}}{}\left({\mathrm{name}}{=}{"Bryan"}\right)\end{array}\right]$ (5)
 > $\mathrm{subsref}\left(B,\left[\mathrm{Record}\left(\mathrm{type}="\left(\right)",':-\mathrm{subs}'=⟨2⟩\right),\mathrm{Record}\left(\mathrm{type}=".",':-\mathrm{subs}'="name"\right)\right]\right)$
 ${"Bryan"}$ (6)