Read double datas

18 views (last 30 days)
Taegeun
Taegeun on 19 Jan 2012
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,

Answers (2)

Titus Edelhofer
Titus Edelhofer on 19 Jan 2012
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 on 19 Jan 2012
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.

Community Treasure Hunt

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

Start Hunting!