I want to put error bar in bar plot (above each bar). I tried
bincentres = -85:10:85;
nelements = [1,4,14,24,46,57,63,63,174,147,69,49,22,9,4,2,1,0];
err = sqrt(nelements);
bar(bincentres, nelements);
hold on
errorbar(bincentres,nelements, err);
hold off
Previously I was not getting errorbar because I was missing 'bincentres' in 'errorbar' in above code. Thanks to @Shai for pointing out that. But apart from error bar, now I get a line joining middle of each error bar. I want to skip that blue line.