How to organize a table?
Mostrar comentarios más antiguos
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 comentarios
madhan ravi
el 16 de Ag. de 2019
Editada: madhan ravi
el 16 de Ag. de 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
el 16 de Ag. de 2019
Editada: Zeynab Mousavikhamene
el 16 de Ag. de 2019
Andrei Bobrov
el 16 de Ag. de 2019
Please read about varfun.
Respuesta aceptada
Más respuestas (2)
Zeynab Mousavikhamene
el 16 de Ag. de 2019
0 votos
Andrei Bobrov
el 16 de Ag. de 2019
Editada: Andrei Bobrov
el 16 de Ag. de 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);
Categorías
Más información sobre Tables en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!