extract every tenth row from a long text file with 3 column
1 次查看(过去 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 中查找有关 Data Import and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!