필터 지우기
필터 지우기

Selecting rows periodically from csv data file.

조회 수: 3 (최근 30일)
Anjali Mishra
Anjali Mishra 2022년 5월 23일
답변: Voss 2022년 5월 23일
I have a table of data as csv file. I want to pick every 10th row and discard all other rows. How can this be done in Matlab? I do not have access to function tableControl.

답변 (1개)

Voss
Voss 2022년 5월 23일
You can read the whole thing using, for instance, readtable
t = readtable('test.csv');
or readmatrix
M = readmatrix('test.csv');
and then use indexing along the rows to keep just the rows you want:
t_keep = t(1:10:end,:) % perhaps keep every 10 rows, starting with row 1
t_keep = 3×1 table
Var1 ____ 1 11 21
t_keep = t(10:10:end,:) % or perhaps keep every 10 rows, starting with row 10
t_keep = 2×1 table
Var1 ____ 10 20
M_keep = M(1:10:end,:) % perhaps keep every 10 rows, starting with row 1
M_keep = 3×1
1 11 21
M_keep = M(10:10:end,:) % or perhaps keep every 10 rows, starting with row 10
M_keep = 2×1
10 20

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by