function [no,xo] = histogram(y,x)

[m,n] = size(y)

miny = min(min(y))
maxy = max(max(y))
binwidth = (maxy - miny) ./ x
xx = miny + binwidth*(0:x)
xx(length(xx)) = maxy
x = xx(1:length(xx)-1) + binwidth/2

nbin = length(xx)
nn = zeros(nbin,n)
for i=2:nbin
    nn(i,:) = sum(y <= xx(i))
end
nn = nn(2:nbin,:) - nn(1:nbin-1,:);

  if min(size(y))==1, % Return row vectors if possible.
    no = nn';
    xo = x;
  else
    no = nn;
    xo = x';
  end

