How to organize a table?
Afficher commentaires plus anciens
I have a table around 700 rows and 7 columns. The second column is time. I have 5 different times. The last column is "cell type" which is an integer from 0 to 4. I need to know that at time=0 how many "cell type=3" exists? how many "cell type=4" exists? and do this for all times.
Is varfun appicable in this case?
Thanks 

3 commentaires
madhan ravi
le 16 Août 2019
Modifié(e) : madhan ravi
le 16 Août 2019
Do not let the readers guess, so that they don't spend more time in guessing how the actual data looks like! Always post a sample data of what you're working with. You have always ignored the comments asking for the sample data until now! Posting pictures of data is completely pointless and useless. Attaching a file as .mat would be better to work with.
Zeynab Mousavikhamene
le 16 Août 2019
Modifié(e) : Zeynab Mousavikhamene
le 16 Août 2019
Andrei Bobrov
le 16 Août 2019
Please read about varfun.
Réponse acceptée
Plus de réponses (2)
Zeynab Mousavikhamene
le 16 Août 2019
0 votes
Andrei Bobrov
le 16 Août 2019
Modifié(e) : Andrei Bobrov
le 16 Août 2019
T = readtable('img1.txt');
out = varfun(@sum,T,'GroupingVariables',...
{'time','cell_type'},'InputVariables','cell_type');
out = out(:,1:end-1);
or
[A,out] = findgroups(T(:,{'time','cell_type'}));
out.counts = accumarray(A,1);
Catégories
En savoir plus sur Tables dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!