rearranging txt file in matlab

2 次查看(过去 30 天)
Mayowa
Mayowa 2015-3-27
编辑: Thorsten 2015-3-27
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

回答(1 个)

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

类别

Help CenterFile Exchange 中查找有关 Workspace Variables and MAT-Files 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by