Documentation Center

  • Trial Software
  • Product Updates

Contents

linalg::swapCol

Swap two columns in a matrix

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

linalg::swapCol(A, c1, c2)
linalg::swapCol(A, c1, c2, r1 .. r2)

Description

linalg::swapCol(A, c1, c2) returns a copy of the matrix A with the columns with indices c1 and c2 interchanged.

The effect of linalg::swapCol(A, c1, c2, r1.. r2) is that only the components from row r1 to row r2 of column c1 are interchanged with the corresponding components of column c2.

Examples

Example 1

We consider the following matrix:

A := matrix(3, 3, (i, j) -> 3*(i - 1) + j)

The following command interchanges the first and the second column of A. The result is the following matrix:

linalg::swapCol(A, 1, 2)

If only the components in the first two rows should be affected, we enter:

linalg::swapCol(A, 1, 2, 1..2)

The third row remains unchanged.

Parameters

A

An m×n matrix of a domain of category Cat::Matrix

c1, c2

The column indices: positive integers less or equal to n

r1 .. r2

A range of row indices (positive integers less or equal to m)

Return Values

Matrix of the same domain type as A.

See Also

MuPAD Functions

More About

Was this topic helpful?