function level=confidenceintervals(x,h,threshold) %CONFIDENCEINTERVALS: build confidence interval from histogram. nods=size(h,1); nbins=size(h,2); %make sure h is one column smaller than x if size(x,2) ~= (size(h,2)+1), error('x should be one column larger than the histogram'); end %First build cdf: c=[zeros(nods,1) cumsum(h,2)]; %In percentage: threshold=threshold/100; flags=zeros(nods,nbins+1); pos=find(c