Change a row of a matrix
MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.
MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.
linalg::setRow(A, p, r) returns a copy of
the matrix A with
row replaced by the row vector .
r is a list with at most n elements,
r is converted into a row vector. An error
message is returned if the conversion is not possible (e.g., if an
element of the list cannot be converted into an object of the component
A; see Example 2).
We define a matrix over the rationals:
MatQ := Dom::Matrix(Dom::Rational): A := MatQ([[1, 2], [3, 2]])
and replace the 2nd row by the 1×2 zero vector:
linalg::setRow(A, 2, MatQ(1, 2, [0, 0]))
We create the 2×4 zero matrix over ℤ6:
B := Dom::Matrix(Dom::IntegerMod(6))(2, 4)
and replace the 2nd row by the vector (1,
- 1, 1, - 1). We give the row vector in form
of a list. Its elements are converted implicitly into objects of the
component ring of
linalg::setRow(B, 2, [1, -1, 1, -1])
The following input leads to an error message because the number can not be
converted into an object of type
linalg::setRow(B, 1, [1/3, 0, 1, 0])
Error: Invalid row vector. [linalg::setRow]
An m×n matrix
of a domain of category
A row vector or a list that can be converted into a row vector
Matrix of the same domain type as