MATLAB: How to swap columns of a matrix?

#swap #matrix #help #relocate

I have a matrix of 8760X30, the first 7 columns need to be swap with some other column. eg. the first and the second columns need to need to be swap with the 8 and 9 column.

Best Answer

Simple approach(Consider matrix A):
A(:,[1 2 8 9])=A(:,[8 9 1 2])