Read double datas
18 views (last 30 days)
Show older comments
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,
0 Comments
Answers (2)
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
0 Comments
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.
0 Comments
See Also
Categories
Find more on Low-Level File I/O in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!