function w=makemat(y,n)
[d_1,n_M] = max(y);
[d_2,n_m] = min(y);
y(n_M) = 0; y(n_m)=0;
y = abs(y);
L = length(y);
M = max(y);
%boxwidth = floor(L/n);
boxheight = M/n;
boxwidth=L/n;

s = linspace(0,L,n+1);

for k = 1:n
    %x = y((k-1)*boxwidth+1:k*boxwidth);
    x = y(floor(s(k))+1:floor(s(k+1)));
    for j=1:n
        z = (((j-1)*boxheight<x)&(x<=j*boxheight));
        w(n-j+1,k) = sum(z)/boxwidth*100;
    end
end