need to import data capable of skipping lines based on conditions

조회 수: 4 (최근 30일)
Truman Cassady
Truman Cassady 2019년 3월 2일
답변: Walter Roberson 2019년 3월 2일
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