Frequency against every value

4 views (last 30 days)
Seemab  Janjua
Seemab Janjua on 8 Dec 2015
Commented: Seemab Janjua on 9 Dec 2015
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

Accepted Answer

Guillaume
Guillaume on 8 Dec 2015
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 Comments
Guillaume
Guillaume on 8 Dec 2015
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
Seemab  Janjua
Seemab Janjua on 9 Dec 2015
thanks sir Guillaume it works...

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!