Creating new dataset corresponding to certain name within a variable column

조회 수: 1 (최근 30일)
Clara Woodie
Clara Woodie 2019년 3월 22일
댓글: Clara Woodie 2019년 3월 22일
I have a dataset with four columns: day, bottle, species finalC. Attached is a screenshot for reference. In the bottle column, there are many types of bottle names I reference. I wish to create a new dataset corresponding only to a specific name of bottle, for example "C-a"
Desired outcome looks as follows:
day bottle species finalC
1 'C-a' 'Colp' 1077.58620700000
2 'C-a' 'Colp' 86525.1499800000
2 'C-a' 'Colp' 208333.333300000

답변 (1개)

the cyclist
the cyclist 2019년 3월 22일
Here is one possible way. (It assumes your table's variable name is tbl.)
outcome = tbl(ismember(tbl.bottle,'C-a'),:);
  댓글 수: 1
Clara Woodie
Clara Woodie 2019년 3월 22일
Thank you so much! I had been stuck for so long! May I ask you a follow-up question?
I don't know if this is even possible to do in Matlab, but what I'm trying to do is this in words:
% for day = 1 and bottle = C-a or C-b or C-c or C-d,
insert a new row with day=1, species="Colp", bottle="Colp_avg"
and finalC = the average of finalC values for C-a,C-b,C-c,and C-d

댓글을 달려면 로그인하십시오.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by