Read double datas

9 ビュー (過去 30 日間)
Taegeun
Taegeun 2012 年 1 月 19 日
Dears,
I want to read .txt file that includes too many double type datas. ex) 1.2039 0.3944 1.4595 ... 2.5434 ... ...
I used 'fscanf' function to read this file. But, this txt file have too many entry, thus, I want to read this file from a specific position. How can I read this file from the given position?
Thanks,

回答 (2 件)

Titus Edelhofer
Titus Edelhofer 2012 年 1 月 19 日
Hi,
with fscanf you need not read all data at once but might read only N numbers (take a look at the doc). Use ftell and fseek to read the current position in the file and for moving the file pointer to that position later.
Titus

Walter Roberson
Walter Roberson 2012 年 1 月 19 日
There is no way to select a specific position in a text file, other than to have already read through the text file and recorded all the potential positions of interest.
In particular there is no way to go directly to a specific line number or a specific field number within a line.
If your data file was in binary format and was all one data type, and all the sizes were consistent, then it would be possible to go directly to particular entries.

カテゴリ

Help Center および File ExchangeLow-Level File I/O についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by