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 日

0 投票

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 日

0 投票

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

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

質問済み:

2014 年 4 月 4 日

回答済み:

2014 年 4 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by