How to read non-rectangular text file?
3 ビュー (過去 30 日間)
古いコメントを表示
Hi All,
I'm having trouble on figuring out how to read this file... It's a text file with an odd format (see below), and I wish to have all numerical values in a matrix. I've tried textscan/textread/fscanf etc.. Any suggestions on how to read this? Any help is much much appreciated!!
1 170.411 17.701 171.50 0.635 0.808 1000.0 1.000 1.00 0 1 3 2 ( 35.7) 17 ( 22.8) 25 ( 19.8)
2 331.737 7.687 36.14 3.721 0.780 1000.0 1.000 1.00 0 1 7 1 ( 35.7) 3 ( 19.1) 17 ( 14.9) 19 ( 12.0) 21 ( 12.2) 26 ( 19.9) 28 ( 16.9)
3 307.133 16.214 43.80 6.711 0.701 1000.0 1.000 1.00 0 1 6 2 ( 19.1) 4 ( 27.5) 16 ( 28.1) 19 ( 11.7) 21 ( 25.3) 22 ( 20.3)
4 103.491 10.151 257.58 9.413 0.022 1000.0 1.000 1.00 0 1 3 3 ( 27.5) 16 ( 18.5) 5 ( 16.4)
Thanks all!
Ben
2 件のコメント
Bob Thompson
2018 年 3 月 28 日
My sloppy form would be to write a while loop which will read each line with fgetl(). It will require some finessing since fgetl classes the line as a string, but you can convert the string values into a set of numbers afterwards and pad a matrix.
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!