extract every tenth row from a long text file with 3 column

7 ビュー (過去 30 日間)
Akim Mahmud
Akim Mahmud 2017 年 12 月 20 日
コメント済み: Akim Mahmud 2017 年 12 月 20 日
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

採用された回答

Image Analyst
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 ExchangeLow-Level File I/O についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by