Help with textscan while reading misc data files

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

采纳的回答

TADA
TADA 2019-1-25
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 个评论
TADA
TADA 2019-1-25
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

请先登录,再进行评论。

更多回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by