I need to separate same first column data values and its corresponding second column value.
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
zhoug zho
el 18 de Mayo de 2021
I have two dimensional data, as shown in figure.
I need to separate same first coloumn (column 1) data values and its corresponding second column (column 2) value, into groups.
How can I do this ?
Thanks in advance.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/621833/image.jpeg)
2 comentarios
the cyclist
el 18 de Mayo de 2021
Editada: the cyclist
el 18 de Mayo de 2021
When you say "separated", what specifically do you mean? How do you want the output organized?
Do you still need just one table, but with the values sorted? Or one table, but with an additional variable to define the unique values in column1? Or maybe you need a new table for every value in the first column?
Respuesta aceptada
Adam Danz
el 18 de Mayo de 2021
Editada: Adam Danz
el 18 de Mayo de 2021
Another method using groupsummary
% Create demo table
g = repelem((1:2:9)',randi(4,5,1)+1,1);
T = table(g, rand(numel(g),1).*randi([2,8],numel(g),1), ...
'VariableNames', {'column1','column2'})
% Average column 2 for each group in column 1
Tstats = groupsummary(T,'column1','mean','column2')
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Cell Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!