You can swap the two columns of a matrix in MATLAB by directly assigning the columns to each other. Here is an example:
main.m111 chars6 lines
In this example, A(:, [1, 2]) = A(:, [2, 1]);
swaps the first and second columns of matrix A
.
gistlibby LogSnag