Frequency against every value
조회 수: 14 (최근 30일)
이전 댓글 표시
i have dataset with column data,the last column in the dataset which i have attached.i want to calculate all number of data greater than 4 ,greater than 4.1, greater than 4.2 so on ....data sample is as Data
data
6
4.7
4.4
4.3
4.2
4.8
4
4.2
4.2
4.6
4.1
4.2
4.4
4.4
4.1
4.9
4.5
4.1
4.1
4.2
5
4.6
5.4
4
4.4
4.4
4.1
4.4
4
4
4.9
4.4
4.2
4.2
4.8
6
5.1
4.7
4
4
4.3
4.3
4.1
4
4
4.2
4.2
4.2
4.2
4.1
4.6
4.2
4.3
4.1
4.1
4.4
4.4
4.4
4.4
4.7
4.7
4.1
4.3
4.3
4.2
4.4
4.3
4.4
4.8
4.8
4.2
4.2
4.8
5.5
4.7
4.1
4.2
4.1
4.1
4.1
4.1
4.6
4.6
4.6
4.1
4
5.2
5.5
4.6
4.1
4.1
4.1
4.2
4.2
4
4.5
4.8
4.7
4.6
댓글 수: 0
채택된 답변
Guillaume
2015년 12월 8일
Bearing in mind that the number of data greater than 4 also includes the number of data greater than 4.1, what you are asking for is a cumulative histogram but in reverse.
The histcounts function does cumulative histogram (the 'cumcount' option of 'normalization'), but not in reverse. No matter, you can reverse the ordering of your data simply by negating it:
bins = 6:-0.1:3.9; %note that it's 3.9 instead of 4 due to the way histcounts treat the last bin
count = fliplr(histcounts(-data, -bins, 'Normalization', 'cumcount')
count is the reversed cumulative histogram starting at 4, finishing at 5.9. That is count(1) is the number of data > 4, count(2) the number > 4.1, ... count(99) the number > 5.9.
댓글 수: 3
Guillaume
2015년 12월 8일
You don't have to accept an answer if it does not work for you.
You must be running an ancient version of matlab if histcount can't be found. You could possibly replace it with
cumsum(histc(-data, -bin)) %completely untested
You may need to adjusts the bins as histc behaves slightly differently at the edges than histcounts
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!