Effacer les filtres
Effacer les filtres

Help with textscan while reading misc data files

1 vue (au cours des 30 derniers jours)
Sergio
Sergio le 25 Jan 2019
Commenté : Sergio le 26 Jan 2019
Hi,
I'm facing a lot of trouble trying to read data from a text file. Basically, the structure is like this:
01B1305.aaa
65536
0.01
8.816667e-05
6.500000e-05
...
5.866667e-05
Timehistories end here
(lots of useless text after the line above)
So, what I want is to read just the block of data between "8.816667e-05" and "5.866667e-05". Could you help me out?
Thanks,
ps: The line "Timehistories end here" actually exists in every file, but I don't need to read it either.

Réponse acceptée

TADA
TADA le 25 Jan 2019
if you know how many lines you want to skip:
fid = fopen('data.txt'); % your own filename comes in here
a = cell2mat(textscan(fid, '%f', 'HeaderLines', 3, 'ReturnOnError', true))
fclose(fid);
  2 commentaires
TADA
TADA le 25 Jan 2019
this will work if you Know how many lines to skip and if you want all the numeric data up to the line with 'Timehistories end here'
If there is anything thats not numeric in that range, it will fail. if there's data that you don't want to read before that line, it will read it
Sergio
Sergio le 26 Jan 2019
Awesome! Thanks a lot!

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by