Matrix and Vector Entry AssignmentAssignment statements can be used to change the value of entries in an existing Matrix or Vector (whose constructor option ro has not been set to readonly).If assignment statements are used for this purpose, there are consequences regarding how the resulting Matrix or Vector is returned.In the following sections, A is a Matrix and V is a Vector.Assigning Values to EntriesProperties of the Resulting Matrix or Vector

<Text-field style="Heading 2" layout="Heading 2" bookmark="bkmrk0">Assigning Values to Entries</Text-field>Each of the entry selection formats described in Matrix and Vector Entry Extraction can be used on the left-hand side of an assignment statement. Entries selected in the left-hand side of the assignment statement are replaced by the corresponding entries of the right-hand side. Unspecified entries are set to 0. The number of dimensions in such an assignment statement must match; a Vector can be assigned to a submatrix, provided it is a 1 x n submatrix.For example, the assignmentA := Matrix([[9,9,9,9],[9,9,9,9],[9,9,9,9],[9,9,9,9]]);A[1..2, 2..4] := Matrix([[5, 6], [7, 8]]);A;replaces A[1, 2] with 5, A[1, 3] with NiMiIic=, A[2, 2] with NiMiIig=, and A[2, 3] with NiMiIik=. The entries A[1, 4] and A[2, 4] are set to 0.It is not necessary for the selection on the left-hand side of an assignment statement to represent contiguous nor ordered components of the Matrix or Vector. For example, A[[ 3, 1], 1..-1] := B replaces row 3 and row 1 of A with, respectively, row 1 and row 2 of some existing Matrix B.
<Text-field style="Heading 2" layout="Heading 2" bookmark="bkmrk1">Properties of the Resulting Matrix or Vector</Text-field>All of the assignment operations mentioned operate in place -- the resulting Matrix or Vector overwrites the original Matrix or Vector. One consequence is that the command A[1..-1, 1..-1] := Matrix([[...], ..., [...]]) causes a replacement of all the entries of A, whereas the command A := Matrix([[...], ..., [...]]) creates a new Matrix.For all assignments, the values on the right-hand side must be of the same or compatible datatype as that of the Matrix or Vector on the left-hand side. Furthermore, it is an error if the right-hand side does not fit into the selected submatrix, subvector, or scalar location specified on the left-hand side. It is not an error if the right-hand side is smaller than the left-hand side.

See AlsoassignmentMatrixMatrix and Vector Entry Extractionrtable_indexingVector