How to swap columns of a matrix??

78 views (last 30 days)
Ali nouri
Ali nouri on 24 Mar 2020
Answered: Sayali on 6 Jun 2023
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.

Accepted Answer

Birdman
Birdman on 24 Mar 2020
Simple approach(Consider matrix A):
A(:,[1 2 8 9])=A(:,[8 9 1 2])

More Answers (1)

Sayali
Sayali on 6 Jun 2023
a=[ 1 2 3; 2 4 5]

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!