Below is a method I just found through trial and error (haha) that works for 2015b (I suspect it would also work for 2014b, 2015a, and 2016a, but I haven't tested it on these versions).
This method works by accessing a hidden primitive object type called LineStrip, whose handle is stored in a hidden property called Bar. The LineStrip object contains a property called VertexData, which stores coordinates for the endpoints (vertices) of all line segments used to draw the figure.
VertexData is a 3-by-(6*N) single-precision numeric array, where N equals the number of error bars represented by the ErrorBar object. This is because there are two vertices per line segment (start and end coordinates), and there are 3 lines that make up a single error bar (one vertical and two horizontal caps), so 2*3=6. More info:
- The three rows contain X, Y, and Z coordinates, in that order.
- Each column contains data for exactly one vertex.
- The columns are organized such that (:,1:2*N) represent the vertical lines, (:,2*N+1:4*N) represent the lower cap-lines, and (:,4*N+1:end) represent the upper cap-lines.
- Within each of these broader sections (vertical error bar, lower cap, upper cap), the column indices map in 2-to-1 fashion onto the XData / YData / ZData properties of the ErrorBar object, so that, for instance: indices (:,1:2) contain the start and end points for a line segment corresponding to the first data point; indices (:,3:4) contain start and end points for a line segment corresponding to the second data point, etc.
- The odd-numbered columns contain coordinates for the lower-most (for the vertical lines) and left-most (for the horizontal lines) end of the line segment. Conversely, the even-numbered columns contain the upper-most and right-most coordinates.
You can then replace or alter these values as you wish to fully customize the error bars. An example implementation is shown here:
X = 0:pi/10:pi;
Y = sin(X);
E = std(Y)*ones(size(X));
hErr = errorbar(X,Y,E);
mult = 2;
b = hErr.Bar;
vd = b.VertexData;
N = numel(X);
capLength = vd(1,2*N+2,1) - vd(1,1,1);
newLength = capLength * mult;
leftInds = N*2+1:2:N*6;
rightInds = N*2+2:2:N*6;
vd(1,leftInds,1) = [X-newLength, X-newLength];
vd(1,rightInds,1) = [X+newLength, X+newLength];
b.VertexData = vd;
(Note: The drawnow command is superfluous if you're stepping through in debug mode or using command-line entry, but it is absolutely essential if you're running in a function or script - otherwise the properties of the LineStrip will still be empty/default when you try to access them.)
Finally, of course, you could also set mult to 0 to eliminate the caps altogether, or manually put in the length you want, or anything else.