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

1 vue (au cours des 30 derniers jours)
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

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 5 Sep 2019
Modifié(e) : Andrei Bobrov le 6 Sep 2019
tout = varfun(@(x){x(:)'},T,'GroupingVariables','id');
C = tout{:,3:end};
measure = C(:,1);
t = C(:,2);
  4 commentaires
Andrei Bobrov
Andrei Bobrov le 6 Sep 2019
Modifié(e) : Andrei Bobrov le 6 Sep 2019
I'm fix (about transpose).
Maybe accept it answer? Or ...
zhongjie
zhongjie le 6 Sep 2019
Sorry I'm new to this community, didn't really notice that "Accept this answer" button. My bad!

Connectez-vous pour commenter.

Plus de réponses (1)

Anmol Dhiman
Anmol Dhiman le 5 Sep 2019
Use the following commands
T = readtable('filename.csv')
c{1} = T{T.id==1,'measure'}
c{2} = T{T.id==2,'measure'}
  1 commentaire
zhongjie
zhongjie le 5 Sep 2019
Modifié(e) : zhongjie le 5 Sep 2019
Thank you very much for the answer!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by