histcounts
histcounts(x,options) sorts the values of x, arranging them into bins.
- [xb,y,edges,nb,bin] = histcounts(x,options) with xb as a vector containing the middle value of each bin, y as a vector with the count of x in each bin, edges as a vector defining the limits of each bin, nb as the number of bins and bin as a vector with the indices of the bins.
- options: nbins, widthbins, edges.
Examples
>> x = [6 7 5 4 6 30]
[xb,y,edges,nb,bin] = histcounts(x)
[x:1x6 double]
[xb:1x5 double]
[y:1x5 double]
[edges:1x6 double]
[nb:5]
[bin:1x6 double]
>> xb#
4.5 5.5 6.5 18.5 30.5
>> y#
1 1 2 1 1
>> edges#
4 5 6 7 30 31
>> bin#
3 4 2 1 3 5
>> options = struct
options.nbins = 3
x = [6 7 5 4 6 30]
[xb,y,edges,nb,bin] = histcounts(x,options)
[options:1x1 struct]
[x:1x6 double]
[xb:1x3 double]
[y:1x3 double]
[edges:1x4 double]
[nb:3]
[bin:1x6 double]
>> xb#
8.33333 17 25.6667
>> y#
5 0 1
>> edges#
4 12.6667 21.3333 30
>> bin#
1 1 1 1 1 3