How can I convert this table to a cell array as shown in the screenshot?
1 次查看(过去 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 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!