need to import data capable of skipping lines based on conditions

4 views (last 30 days)
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?

Answers (1)

Walter Roberson
Walter Roberson on 2 Mar 2019
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.)

Categories

Find more on Data Import and Analysis in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!