need to import data capable of skipping lines based on conditions
4 次查看(过去 30 天)
显示 更早的评论
The goal is to import the columns of data then skip this break in data and continue importing. There are 100 rows of data between each block of information about the data. Is there any condition that I can use that would skip importing after a certain number of lines?

0 个评论
回答(1 个)
Walter Roberson
2019-3-2
importdata() cannot do this.
If you use textscan() then immediately after the format string you can give a number indicating the number of times the format string is to be used -- so you could use
textscan(fid, '%f %f', 100)
for example.
Alternately you can use techniques similar to what I did in https://www.mathworks.com/matlabcentral/answers/447889-how-do-i-read-data-from-a-dat-file-seperated-by-lines-of-text-into-individual-vectors#answer_363508 but in your case instead of matching against '^\s*#' you would match against '^[^0-9-]' which would match any line whose first character was not a digit or the character '-' (as I assume that some of your data might be negative.)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!