addErrorbars(values, series1 [,series2] [,x_axis] [,relative])


Adding errorbars to your plots in matlab can be frustrating because it can take some digging into the syntax and use of figures, and the input format isn't always what you expect. ADDERRORBARS is a convenience function that tries to make this a little easier. After you draw your bar or line plot, call this function with the means you used to generate it, and it will generate the needed bars. Note that for simplicity, this function is written to handle only one condition at a time. For plots with multiple conditions, the function should be called multiple times.


addErrorbars(values, series1) creates error bars around the values. The upper and lower limit are an equal distance from the mean. For example, if mean=4 and series1 = 1, then error bars would extend from 3 to 5. addErrorbars(values, series1, series2) creates error bars around each point of the mean series, with lower and upper limits placed at the specified locations. For example, if mean=4, series1=-1 and series2=2, then error bars would extend from 3 to 6. Note that the same result would be obtained with series1=2 and series2=-1. addErrorbars(values, series1, series2, absolute) behaves as above, but when relative is a logical set to true, then the values provided in ll_series and ul_series are interpreted as absolute positions rather than relative to the mean. For example, if mean=4, series1=1 and series2=5, then error bars would extend from 1 to 5. addErrorbars(values, series1, series2, relative, x_axis) adds the error bars at the specified points along the x_axis, rather than the default behaviour of placing the points at x = 1:length(values).