MATLAB: Remove rows based on length of column value

colummatrixmatrix arraymatrix manipulation

I have a matrix , 1531*3 double.
At a first column, numbers represent same particles from 1 to 14. I have 14 particles and each of them has different time points(second column) with intensity value(third column).
I'd like to take only particles which the number of time points is over 2, and make a new matrix. In this example, I need to remove rows of 14th particle and make the new matrix which doesn't have 14th particle, because it has only 2 time points. Should I use 'loop'?
for j = 1:14
if length(find(A(:,1)==j)) > 2
end
end

Best Answer

Instead of implicit expansion (which can take a lot of memory for bigger arrays), you can use histogram counts:
S=load('practice.mat');
A=S.A;
c=histcounts(A(:,1),numel(unique(A(:,1))));
remove_ID=find(c<=2);
L=ismember(A(:,1),remove_ID);
B=A(~L,:);%keep only IDs with >2 time points