How do you find data points that match a specific value?

10 visualizaciones (últimos 30 días)
Talia Vaughn
Talia Vaughn el 10 de Nov. de 2021
Editada: Cris LaPierre el 10 de Nov. de 2021
I have a data set (data.tib) that has x, y and z coordinates in columns 1, 2, and 3, respectively. I want to find all unique z values so I used "uz = unique(data.tib(:,3));". For each z-axis position, I want to count how many x-y coordinates there are for each unique z. I was thinking of using "length()" to count how many and then some variation of the "find()" command.

Respuestas (1)

Cris LaPierre
Cris LaPierre el 10 de Nov. de 2021
I would use groupsummary. If you group by z, the resulting table automatically contains a group count.
x=randi(10,100,1);
y=randi(10,100,1);
z=randi(10,100,1);
data = table(x,y,z);
% group
out = groupsummary(data,'z')
out = 10×2 table
z GroupCount __ __________ 1 8 2 8 3 11 4 9 5 10 6 16 7 10 8 14 9 7 10 7
  3 comentarios
Talia Vaughn
Talia Vaughn el 10 de Nov. de 2021
Nevermind, I fixed that error. Now I'm wondering how to refer to the individual group counts within a line of code.
Cris LaPierre
Cris LaPierre el 10 de Nov. de 2021
Editada: Cris LaPierre el 10 de Nov. de 2021
See how to access data in a table. Continuing the example I shared previously, this will access the group count value in the ith row
out.GroupCount(i)

Iniciar sesión para comentar.

Categorías

Más información sobre Tables en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by