Is it possible to scan a group of lines in MATLAB?
Show older comments
I have a textfile I would like to pull data from. Rather than reading line by line I would like to just have it scan my textfile in chunks. For example scanning it every 10 lines. Then I intend to write some of the data from these 10 lines to a new file and read the next 10 lines. Is this possible?
Accepted Answer
More Answers (2)
Walter Roberson
on 11 Sep 2013
0 votes
Yes. After the format specifier, in the next parameter put the number of times you want the format to be reused. 10 for example if the format is for one line's worth of information.
sanky kumar
on 11 Sep 2013
0 votes
hi brian
you can use textscan.
C = textscan(fileID,formatSpec) reads data from an open text file into cell array, C. The text file is indicated by the file identifier, fileID. Use fopen to open the file and obtain the fileID value. When you finish reading from a file, close the file by calling fclose(fileID).
textscan attempts to match the data in the file to formatSpec, which is a string of conversion specifiers.
Categories
Find more on Text Files 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!