MATLAB Answers

K E
0

Fastest way to read in large mixed text file?

K E
さんによって質問されました 2016 年 11 月 4 日
最新アクティビティ Star Strider
さんによって 回答されました 2016 年 11 月 4 日
I have an ASCII file with 300000 lines with the following format:
01-01-1979T00:00:00 722816.000000 128.783100 0.027240 0.000000 2.212400 1.535800 290.701000 2.570600 0.941000
I would like to read the lines in as follows:
  • Column 1 skip
  • Column 2 read in as number (actually datenum times)
  • Columns 3-10 read in as numbers
I can read this in using textscan thanks to code generated by the Matlab file import tool, but am wondering if there is a faster way.

  0 件のコメント

サインイン to comment.

タグ

1 件の回答

Star Strider
Star Strider 님의 답변 4 Nov 2016

You can easily write your own textscan call:
fidi = fopen('filename.txt',rt');
data = textscan(fidi, ['%*s' repmat('%f',1,9)], 'CollectOutput'1);
See the documentation for textscan for other options and name-value pair arguments you may need to read your file.
NOTE I do not have your file to test with it, so this is UNTESTED CODE.

  0 件のコメント

サインイン to comment.



Translated by