how to remove data points occur less in a data set
Show older comments
Hi, suppose i have a data set x:
x = [0,2,9,2,5,8,7,3,1,9,4,3,5,8,10,0,1,2,9,5,10] ;
figure(1)
[n,b] = hist(x)
bar(b,n) ;
use above code i can plot the distribution. Is there anyway that i can remove the points that occur less than others, for example, remove the data that occur less than 2 times in the array.
thank you
Answers (1)
Azzi Abdelmalek
on 2 Apr 2014
x = [0,2,9,2,5,8,7,3,1,9,4,3,5,8,10,0,1,2,9,5,10] ;
ii=unique(x)
[aa,bb] = hist(x,ii)
idx=aa>=2
bar(bb(idx),aa(idx))
4 Comments
Xi
on 2 Apr 2014
Azzi Abdelmalek
on 2 Apr 2014
x = [0,2.1,9.2,2.5,2.5,8.4,7,3,1,9,4,3,5,8.4,10.5,0,1,2,9,5,10.5] ;
ii=unique(x)
[aa,bb] = hist(x,ii)
idx=aa<2
bb(idx)=0
[ii,jj]=hist(bb)
bar(jj,ii)
Xi
on 2 Apr 2014
Azzi Abdelmalek
on 2 Apr 2014
Edited: Azzi Abdelmalek
on 2 Apr 2014
Xi when the answer helps, click on [accept this answer]
Categories
Find more on Univariate Discrete Distributions 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!