1

I have a list that is sorted and I want to know how many values are in each bin? I made bins using linspace(floor(fist_element_list), ceil(last_element_list), num_bins) Is there a built in function or an easy way to do this in Matlab? All I can think of is doing it manually. I would like a frequency function like the one in excel.

Ben Fossen
  • 1,331
  • 6
  • 21
  • 33

1 Answers1

7

hist is close. However, it's actually grouping items into bins, not counting values. Normally it plots, but you can get the data instead:

[freqs, vals] = hist(list, num_bins)

See also MATLAB : frequency distribution.

Community
  • 1
  • 1
Matthew Flaschen
  • 278,309
  • 50
  • 514
  • 539
  • Here's the documentation: http://www.mathworks.com/access/helpdesk/help/techdoc/ref/hist.html – mtrw May 19 '10 at 21:19