MTM
subsref
subscript reference of arrays
Calling Sequence
Parameters
Description
Examples
subsref(A,index)
A
-
array or record
index
record, list, or array
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") > );.
with⁡MTM,subsref:
A≔Array⁡1,2,3,4
A≔1234
subsref⁡A,1,1
1
R≔Record⁡name=Paul
subsref⁡R,Record⁡type=.,:-subs=name
Paul
B≔Array⁡Record⁡name=Paul,Record⁡name=Bryan
B≔Record⁡name=PaulRecord⁡name=Bryan
subsref⁡B,Record⁡type=(),:-subs=2,Record⁡type=.,:-subs=name
Bryan
See Also
Fortran_order
MTM[subsasgn]
Record
Download Help Document