Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

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?