Documentation Center

  • Trial Software
  • Product Updates

Contents

Swap and Delete Rows and Columns

The MuPAD® linalg library provides the functions for interchanging or deleting rows and columns of a matrix. For example, to swap two rows of a matrix, use linalg::swapRow. To swap two columns, use linalg::swapCol:

OriginalMatrix := linalg::pascal(3);
SwapRows := linalg::swapRow(OriginalMatrix, 1, 2);
SwapColumns :=linalg::swapCol(OriginalMatrix, 1, 2)

To delete a row or a column, use linalg::delRow or linalg::delCol, respectively:

OriginalMatrix := linalg::pascal(3);
DeleteRows := linalg::delRow(OriginalMatrix, 3);
DeleteColumns := linalg::delCol(OriginalMatrix, 3)

To delete a block of rows or columns simultaneously, use the same functions as for one row or column. Specify the range of rows or columns that you want to delete:

OriginalMatrix := linalg::pascal(3);
DeleteRows := linalg::delRow(OriginalMatrix, 2..3);
DeleteColumns := linalg::delCol(OriginalMatrix, 2..3)

Was this topic helpful?