Reading a text file containing strings and numeric data
Show older comments
Hi,
I have a .dat file like this:
Time 0.000000400
154 -1 1.77472 1.34813 0.14000 -0.00418 -0.00188 0.00042
155 -1 0.32897 1.41804 0.14000 0.00034 -0.00181 -0.00068
Time 0.000000500
389 -1 1.28893 1.39899 0.12000 0.00304 -0.00191 -0.00033
Time 0.000000600
512 -1 1.86454 1.13224 0.12000 0.00433 -0.00175 -0.00084
520 -1 0.21448 1.44465 0.12000 -0.00033 -0.00190 0.00037
Time 0.000000800
677 -1 1.14717 1.54507 0.12000 -0.00272 -0.00194 0.00005
692 -1 0.64696 1.33344 0.12000 -0.00145 -0.00188 0.00048
697 -1 0.46609 1.33894 0.12000 -0.00097 -0.00187 0.00050
I only need store the numbers and the digital time into two seperate array.
The number of rows of data at each time is not the same, but the number of columns is the same.
Final arrays should look like this:
For numerical data:
154 -1 1.77472 1.34813 0.14000 -0.00418 -0.00188 0.00042
155 -1 0.32897 1.41804 0.14000 0.00034 -0.00181 -0.00068
389 -1 1.28893 1.39899 0.12000 0.00304 -0.00191 -0.00033
512 -1 1.86454 1.13224 0.12000 0.00433 -0.00175 -0.00084
520 -1 0.21448 1.44465 0.12000 -0.00033 -0.00190 0.00037
677 -1 1.14717 1.54507 0.12000 -0.00272 -0.00194 0.00005
692 -1 0.64696 1.33344 0.12000 -0.00145 -0.00188 0.00048
697 -1 0.46609 1.33894 0.12000 -0.00097 -0.00187 0.00050
For digital time:
0.000000400
0.000000500
0.000000600
0.000000800
Total data exceeds 5 million rows, I tried to use xlsread function, but this function is limited to around 1 million rows.
Any help would be appreciated.
2 Comments
Jan
on 1 Mar 2021
Does the 2nd column contain the value -1 only?
ZHU QIXUAN
on 1 Mar 2021
Accepted Answer
More Answers (0)
Categories
Find more on String Parsing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!