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 Exchange에서 Matrix 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