MATLAB: Is it possible to use a scalar for specifying the error bar length for ERRORBAR in MATLAB 7.9 (R2009b)

MATLAB

When using ERRORBAR, I would like to be able to use a scalar for the error bar length instead of a vector (all error bar of the same length).
For example, the following piece of code works:
X = 0:pi/10:pi;
Y = sin(X);
E = std(Y)*ones(size(X));
errorbar(X,Y,E)
But the following:
X = 0:pi/10:pi;
Y = sin(X);
E = 0.371;
errorbar(X,Y,E)
produces this error:
??? Error using ==> errorbar at 76
X, Y and error bars must all be the same length

Best Answer

The ability to use scalar for error bar length in ERRORBAR is not available in MATLAB 7.9 (R2009b).
To work around this issue, download the attached version of the MATLAB file. Here are the steps:
1. Find the $MATLABROOT directory where $MATLABROOT is the MATLAB root directory on your machine, as returned by typing
matlabroot
at the MATLAB Command Prompt.
2. Quit MATLAB.
3. Download the attached file. Place the new file in the directory $MATLABROOT\toolbox\matlab\specgraph\
4. Restart MATLAB
5. After restarting MATLAB, issue the following command at the MATLAB Command Prompt:
rehash toolboxcache
6. The following code will now plot all error bars with the same length:
X = 0:pi/10:pi;
Y = sin(X);
E = 0.371;
dt_errorbar(X,Y,E)