Frequency against every value

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

 采纳的回答

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 个评论

Sir Guillaume , it is giving error "Undefined function 'histcounts' for input arguments of type 'double'."
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
thanks sir Guillaume it works...

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Data Distribution Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by