I want to plot Cumulative distribution function (CDF) of a set of values, Z using MATLAB. When I use the following code, the CDF would not be between 0 and 1! I would appreciate if you could help me.
function plot_cdf(Z)
numberbin=100;
[n,x] =hist(Z,numberbin);
pdf=n/sum(n(:))/diff(x(1:2));
cdf = cumsum(pdf);
plot(cdf)
end