function plotacf(y,nr)

% Plots autocorrelation function with confidence intervals.
% Usage: plotcf(y,nr)
%

[ar,arsig]=acf(y,nr);
t=(1:length(ar))';
hold off
plot(t,2*arsig,'r',t,-2*arsig,'r')
hold on
Up=find(ar>0);
Lo=find(ar<=0);
if (length(Up)>0)
   errorbar(t(Up),zeros(length(Up),1),zeros(length(Up),1),ar(Up));
end
if (length(Lo)>0)
   errorbar(t(Lo),zeros(length(Lo),1),ar(Lo),zeros(length(Lo),1));
end
hold off
