How do you find data points that match a specific value?
이전 댓글 표시
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.
답변 (1개)
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')
댓글 수: 3
Talia Vaughn
2021년 11월 10일
Talia Vaughn
2021년 11월 10일
Cris LaPierre
2021년 11월 10일
편집: Cris LaPierre
2021년 11월 10일
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)
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!