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

2 次查看(过去 30 天)
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,

采纳的回答

Walter Roberson
Walter Roberson 2015-6-29
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'})

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Cell Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by