extraction - matrix and list entry extraction
r=x(i,j) builds the matrix r such as r(l,k)=x(int(i(l)),int(j(k))) for l from 1 to size(i,'*') and k from 1 to size(j,'*') . i ( j ) Maximum value must be less or equal to size(x,1) ( size(x,2) ).
r=x(i) with x a 1x1 matrix builds the matrix r such as r(l,k)=x(int(i(l)),int(i(k))) for l from 1 to size(i,1) and k from 1 to size(i,2) . Note that in this case index i is valid only if all its entries are equal to one.
r=x(i) with x a matrix with one or more columns builds the column vector r such as r(l) ( l from 1 to size(i,'*') ) contains the int(i(l)) entry of the column vector formed by the concatenation of the x 's columns. i Maximum value must be less or equal to size(x,'*') .
If they are present the ki give the path to a sub-list entry of l data structure. They allow a recursive extraction without intermediate copies. The [...]=l(k1)...(kn)(i) and [...]=l(list(k1,...,kn,i)) instructions are interpreted as: lk1 = l(k1) .. = .. lkn = lkn-1(kn) [...] = lkn(i) And the l(k1)...(kn)(i,j) and l(list(k1,...,kn,list(i,j)) instructions are interpreted as: lk1 = l(k1) .. = .. lkn = lkn-1(kn) lkn(i,j) i and j , can be: When path points on more than one list component the instruction must have as many left hand side arguments as selected components. But if the extraction syntax is used within a function input calling sequence each returned list component is added to the function calling sequence.
Note that, l(list() is the same as l .
For soft coded matrix types such as rational functions and state space linear systems, x(i) syntax may not be used for vector element extraction due to confusion with list element extraction. x(1,j) or x(i,1) syntax must be used.
// MATRIX CASE a=[1 2 3;4 5 6] a(1,2) a([1 1],2) a(:,1) a(:,3:-1:1) a(1) a(6) a(:) a([%t %f %f %t]) a([%t %f],[2 3]) a(1:2,$-1) a($:-1:1,2) a($) // x='test' x([1 1;1 1;1 1]) // b=[1/%s,(%s+1)/(%s-1)] b(1,1) b(1,$) b(2) // the numerator // LIST OR TLIST CASE l=list(1,'qwerw',%s) l(1) [a,b]=l([3 2]) l($) x=tlist(l(2:3)) //form a tlist with the last 2 components of l // dts=list(1,tlist(['x';'a';'b'],10,[2 3])); dts(2)('a') dts(2)('b')(1,2) [a,b]=dts(2)(['a','b'])