re-arranging of columns

8 ビュー (過去 30 日間)
aditi
aditi 2014 年 4 月 4 日
回答済み: Jos (10584) 2014 年 4 月 4 日
hi everyone..
i have a data file with 24 columns and 125 rows... I want to bring 23rd column after column 4... how will i do that... please help

採用された回答

Viju
Viju 2014 年 4 月 4 日
編集済み: Viju 2014 年 4 月 4 日
Once you import this data into a MATLAB variable, there are multiple methods. One way is as follows, where x is the data and y is where I am storing the new data.
y = [x(:,1:4) x(:,23) x(:,5:22) x(:,24)]
  1 件のコメント
aditi
aditi 2014 年 4 月 4 日
ohh okay.... thanks viju..
so here 'x' is the variable in which i load the data file?? right???

サインインしてコメントする。

その他の回答 (1 件)

Jos (10584)
Jos (10584) 2014 年 4 月 4 日
No need for concatenation …
A = load('mydatafile.txt') % only numbers separated by spaces/tabs
A(:,[4 23]) = A(:,[23 4]) % switch columns 4 and 23

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by