Azzera filtri
Azzera filtri

Help with textscan while reading misc data files

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

TADA
TADA il 25 Gen 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 Commenti
TADA
TADA il 25 Gen 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

Accedi per commentare.

Più risposte (0)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by