extract every tenth row from a long text file with 3 column
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi I have a big text file with like 1000000 rows and 3 column and I imported using the importdata function. Now I want to extract/read only every 10th row from the file using a loop. Any help ? Thanks
댓글 수: 0
채택된 답변
Image Analyst
2017년 12월 20일
You forgot to attach the file, but basically I'm guessing you'd do:
data = importdata(filename);
% Non-loop way:
data10 = data(1:10:end, :);
% Loop way
[rows, columns] = size(data);
data10 = zeros(ceil(rows/10), columns);
thisRow = 1;
for row = 1 : 10 : rows
data10(thisRow, :) = data(row, :);
thisRow = thisRow + 1;
end
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 String Parsing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!