Select groups of data with a specific size
Show older comments
Dear all,
Imagine you have a matrix with three colums, the first one is a grouping variable and the other two are coordinates (xy).
The grouping variable looks like this
A = [1 1 1 1 2 2 2 3 3 3 3]';
In this way i have four coordinates in the group 1, three coordinates in the group 2 and four in the group 3. I would like to exclude the groups that do not have 4 data points, i.e., more or less than 4 (in this case group 2).
Accepted Answer
More Answers (1)
KSSV
on 18 Mar 2019
Let x,y be your data points
A = [1 1 1 1 2 2 2 3 3 3 3]';
for i = 1:max(X)
idx = A==i ;
if nnz(idx)<3
plot(x(idx),y(idx),'.')
end
end
1 Comment
Maria Granell Ruiz
on 18 Mar 2019
Categories
Find more on Descriptive Statistics and Visualization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!