function b = bint(s,n)
%
% bint - creates n equal sized bins histograms s
% On input:
%     s: vector of values
%     n: number of bins
% On output:
%     b: vector of n bins with count of elements of s in each
% Call:
%    b = bint(s,n);
% Author:
%     T. Henderson
%     U of U
%     30 Mar 1998
%

b = zeros(1,n);
smax = max(s);
savg = mean(s);
smin = min(s);
slen = length(s);
step = (smax-smin)/n;
if step == 0
   b(floor(n+1)/2) = slen;
   return
end

for t = 1:slen
   bin = floor((s(t)-smin)/step)+1;
   if bin>n
      bin=n;
   end
   b(bin) = b(bin)+1;
end
