need to import data capable of skipping lines based on conditions

3 visualizaciones (últimos 30 días)
Truman Cassady
Truman Cassady el 2 de Mzo. de 2019
Respondida: Walter Roberson el 2 de Mzo. de 2019
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?

Respuestas (1)

Walter Roberson
Walter Roberson el 2 de Mzo. de 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.)

Categorías

Más información sobre Data Import and Analysis en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by