a command for changing the place of columns in a matrix directly

2 次查看(过去 30 天)
Hi all
I have a matrix m-by-n and I want to change the place of columns with an espiciall command in matlab. How can I do this . for Example:
a=[10 20; 20 40; 10 30] chaanged to b=[20 10; 40 20; 30 10]
Thanks for your guidance cheers

采纳的回答

Andrew Newell
Andrew Newell 2011-12-29
You can do this with the matrix indices. For the example you give,
b = a(:,[2 1]);

更多回答(1 个)

Walter Roberson
Walter Roberson 2011-12-29
In the above case,
b = fliplr(a);

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by