Please note that the recommended version of Scilab is 2026.0.0. This page might be outdated.
See the recommended documentation of this function
insertion
partial variable assignation or modification
assignation
partial variable assignation
Calling Sequence
x(i,j)=a x(i)=a l(i)=a l(k1)...(kn)(i)=a or l(list(k1,...,kn,i))=a l(k1)...(kn)(i,j)=a or l(list(k1,...,kn,list(i,j))=a
Arguments
- x
- matrix of any kind (constant, sparse, polynomial,...) 
- l
- list 
- i,j
- indices 
- k1,...kn
- indices with integer value 
- a
- new entry value 
Description
- MATRIX CASE
- If - xis a matrix the indices- iand- j, may be:- Real scalars or vectors or matrices
- In this case the values given as indices should be positive and it is only their integer part which taken into account. - If - ais a matrix with dimensions- (size(i,'*'),size(j,'*')),- x(i,j)=areturns a new- xmatrix such as- x(int(i(l)),int(j(k)))=a(l,k)for- lfrom 1 to- size(i,'*')and- kfrom 1 to- size(j,'*'), other initial entries of- xare unchanged.
- If - ais a scalar- x(i,j)=areturns a new- xmatrix such as- x(int(i(l)),int(j(k)))=afor- lfrom 1 to- size(i,'*')and- kfrom 1 to- size(j,'*'), other initial entries of- xare unchanged.
- If - ior- jmaximum value exceed corresponding- xmatrix dimension, array- xis previously extended to the required dimensions with zeros entries for standard matrices, 0 length character string for string matrices and false values for boolean matrices.
- x(i,j)=[]kills rows specified by- iif- jmatches all columns of- xor kills columns specified by- jif- imatches all rows of- x. In other cases- x(i,j)=[]produce an error.
- x(i)=awith an- avector returns a new- xmatrix such as- x(int(i(l)))=a(l)for- lfrom 1 to- size(i,'*'), other initial entries of- xare unchanged.
- x(i)=awith an- ascalar returns a new- xmatrix such as- x(int(i(l)))=afor- lfrom 1 to- size(i,'*'), other initial entries of- xare unchanged.- If - imaximum value exceed- size(x,1),- xis previously extended to the required dimension with zeros entries for standard matrices, 0 length character string for string matrices and false values for boolean matrices.- if
- xis a 1x1- matrix - amay be a row (respectively a column) vector with dimension- size(i,'*'). Resulting- xmatrix is a row (respectively a column) vector
- if
- xis a row- vector - amust be a row vector with dimension- size(i,'*')
- if
- xis a column- vector - amust be a column vector with dimension- size(i,'*')
- if
- xis a general- matrix - amust be a row or column vector with dimension- size(i,'*')and- imaximum value cannot exceed- size(x,'*').
 
- x(i)=[]kills entries specified by- i.
 
- The : symbol
- The - :symbol stands for "all elements".- x(i,:)=ais interpreted as- x(i,1:size(x,2))=a
- x(:,j)=ais interpreted as- x(1:size(x,1),j)=a
- x(:)=areturns in- xthe- amatrix reshaped according to- xdimensions.- size(x,'*')must be equal to- size(a,'*').
 
- Vectors of boolean
- If an index ( - ior- j) is a vector of booleans it is interpreted as- find(i)or respectively- find(j).
- Polynomials
- If an index ( - ior- j) is a vector of polynomials or implicit polynomial vector it is interpreted as- horner(i,m)or respectively- horner(j,n)where- mand- nare associated- xdimensions. Even if this feature works for all polynomials, it is recommended to use polynomials in- $for readability.
 
- LIST OR TLIST CASE
- If they are present the - kigive the path to a sub-list entry of- ldata structure. They allow a recursive insertion without intermediate copies. The- l(k1)...(kn)(i)=aand- l(list(k1,...,kn,i)=a)instructions are interpreted as:- lk1 = l(k1)- .. = ..- lkn = lkn-1(kn)- lkn(i) = a- lkn-1(kn) = lkn- .. = ..- l(k1) = lk1- And the - l(k1)...(kn)(i,j)=aand- l(list(k1,...,kn,list(i,j))=ainstructions are interpreted as:- lk1 = l(k1)- .. = ..- lkn = lkn-1(kn)- lkn(i,j) = a- lkn-1(kn) = lkn- .. = ..- l(k1)= lk1
- imay be :- a real non negative scalar. - l(0)=aadds an entry on the "left" of the list.- l(i)=asets the- ientry of the list- lto- a. If- i>size(l),- lis previously extended with zero length entries (undefined).- l(i)=null()deletes the- ith list entry.
- a polynomial. If - iis a polynomial it is interpreted as- horner(i,m)where- m=size(l). Even if this feature works for all polynomials, it is recommended to use polynomials in- $for readability.
 
- k1,..knmay be :- real positive scalar. 
- a polynomial, interpreted as - horner(ki,m)where- mis the corresponding sub-list size.
- a character string associated with a sub-list entry name. 
 
 
Remarks
For soft coded matrix types such as rational functions and state space linear systems, x(i) syntax must not be used for vector entry insertion due to confusion with list entry insertion. x(1,j) or x(i,1) syntax must be used.
Examples
// MATRIX CASE a=[1 2 3;4 5 6] a(1,2)=10 a([1 1],2)=[-1;-2] a(:,1)=[8;5] a(1,3:-1:1)=[77 44 99] a(1)=%s a(6)=%s+1 a(:)=1:6 a([%t %f],1)=33 a(1:2,$-1)=[2;4] a($:-1:1,1)=[8;7] a($)=123 // x='test' x([4 5])=['4','5'] // b=[1/%s,(%s+1)/(%s-1)] b(1,1)=0 b(1,$)=b(1,$)+1 b(2)=[1 2] // the numerator // LIST OR TLIST CASE l=list(1,'qwerw',%s) l(1)='Changed' l(0)='Added' l(6)=['one more';'added'] // // dts=list(1,tlist(['x';'a';'b'],10,[2 3])); dts(2).a=33 dts(2)('b')(1,2)=-100
See Also
- find — find indices of boolean vector or matrix true elements
- horner — polynomial/rational evaluation
- parents — ( ) left and right parenthesis
- extraction — matrix and list entry extraction
| Report an issue | ||
| << hat | Scilab keywords | left >> |