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?

回答(1 个)

Walter Roberson
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.)

类别

Help CenterFile Exchange 中查找有关 Data Import and Analysis 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by