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 this and I would like to convert it to two cell arrays by id.
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
.
댓글 수: 0
채택된 답변
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
2019년 9월 6일
편집: Andrei Bobrov
2019년 9월 6일
I'm fix (about transpose).
Maybe accept it answer? Or ...
추가 답변 (1개)
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 Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!