How can I use the textscan command to read data below a body of text?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Jakob Graf
le 29 Juin 2015
Commenté : Jakob Graf
le 29 Juil 2015
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,
0 commentaires
Réponse acceptée
Walter Roberson
le 29 Juin 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'})
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Cell Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!