rearranging txt file in matlab

2 views (last 30 days)
Mayowa
Mayowa on 27 Mar 2015
Edited: Thorsten on 27 Mar 2015
I need help rearranging this data into table in matlab. I want the first row to start from 200.1012 and ends at -999.2555. The next row to start from 200.2536 and ends at -999.2566. It's a large dataset and I will like to rearrange it in such manner. The data is a text file(.txt). I simply want first number (200.1012) to be arranged in such a way that the next vertical number below it is has 200.2536 and so on til it get to the last number on the first row (-999.2555), which has the number vertically below to be (-999.2566). Thanks in advance.
200.1012
-999.2500 4.2655 -999.2500 -999.2500 -999.2500
-999.2500 9.1020 -999.2500 -999.2500 -999.2500
-999.2500 -999.2500 -999.2500 -999.2500 -999.2500
-999.2500 -999.2500 -999.2500 -999.2500 -999.2500
177.0910 -999.2500 444575.0938 6601617.5000 -999.2555
200.2536
-999.2500 4.2655 -999.2500 -999.2500 -999.2500
-999.2500 10.7474 -999.2500 -999.2500 -999.2500
-999.2500 -999.2500 -999.2500 -999.2500 -999.2500
-999.2500 -999.2500 -999.2500 -999.2500 -999.2500
177.2434 -999.2500 444575.0938 6601617.5000 -999.2566

Answers (1)

Thorsten
Thorsten on 27 Mar 2015
Edited: Thorsten on 27 Mar 2015
D = textscan(fopen('test.txt'), '%f');
% format to rows with N=26 values
N = 26;
D = reshape(D{1}, [], N);

Tags

Community Treasure Hunt

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

Start Hunting!