How can I use the textscan command to read data below a body of text?

1 view (last 30 days)
I want to use the textscan(fileID) command to read the data within a .txt file. However, the data begins after about 50 lines of text, and the number of lines of text differs with each .txt file. Can Matlab recognize a "flag" that always occurs before the data?
Example:
Line1;
Line2;
...
Line49;
(Line50)Time,MPitot(V),Static(V),Preston(V),Temperature(K),Voltage,Encoder totcnt,
2014/06/24 15:06:24, 0.242, 4.384, 0.219, 21.18, 8.346, 0,
2014/06/24 15:06:28, 0.242, 4.385, 0.219, 21.23, 8.382, 109,
2014/06/24 15:06:33, 0.242, 4.388, 0.220, 21.02, 8.376, 192,

Accepted Answer

Walter Roberson
Walter Roberson on 29 Jun 2015
If there is a line before that which is certain to show up and which starts with a known string, then you can use that string together with 'Time' as your CommentStyle parameter.
For example,
These are the voyages of
...
...
Time,MPitot(V),Static(V),Preston(V),Temperature(K),Voltage,Encoder totcnt,
then textscan(fid, LineFormatHere, 'CommentStyle', {'These', 'Time'})

More Answers (0)

Categories

Find more on Cell Arrays in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!