how to remove data points occur less in a data set

조회 수: 3 (최근 30일)
Xi
Xi 2014년 4월 2일
편집: Azzi Abdelmalek 2014년 4월 2일
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

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2014년 4월 2일
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
Xi
Xi 2014년 4월 2일
Great! Works perfect. Thank you very much!
Azzi Abdelmalek
Azzi Abdelmalek 2014년 4월 2일
편집: Azzi Abdelmalek 2014년 4월 2일
Xi when the answer helps, click on [accept this answer]

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by