How can I convert this table to a cell array as shown in the screenshot?

조회 수: 2 (최근 30일)
I have a CSV file that looks like thistable.jpg and I would like to convert it to two cell arrays by id.
cell1.jpg
One array contains all "t" of the same id (shown above), and the other array contains all "measure" of the same id as shown below
.cell2.jpg

채택된 답변

Andrei Bobrov
Andrei Bobrov 2019년 9월 5일
편집: Andrei Bobrov 2019년 9월 6일
tout = varfun(@(x){x(:)'},T,'GroupingVariables','id');
C = tout{:,3:end};
measure = C(:,1);
t = C(:,2);
  댓글 수: 4
Andrei Bobrov
Andrei Bobrov 2019년 9월 6일
편집: Andrei Bobrov 2019년 9월 6일
I'm fix (about transpose).
Maybe accept it answer? Or ...
zhongjie
zhongjie 2019년 9월 6일
Sorry I'm new to this community, didn't really notice that "Accept this answer" button. My bad!

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

추가 답변 (1개)

Anmol Dhiman
Anmol Dhiman 2019년 9월 5일
Use the following commands
T = readtable('filename.csv')
c{1} = T{T.id==1,'measure'}
c{2} = T{T.id==2,'measure'}

카테고리

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

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by