Just make a vector of max(y), min(y) the same length as x and add/subtract to the mean for the error bar lengths.
Since both functions are vectorized to accept arrays and return (by default) the result by column, it's just one line each assuming you organize your data by column.
mny=mean(y);
ypos=mny+max(y);
yneg=mny-min(y);
errorbar(x,y,yneg,ypos,'x')
ERRATUM:
Actually, the above isn't quite correct...the error bar lengths are the yneg, ypos arguments; errorbar() itself will take care of the arithmetic. And, to boot, I didn't use the mean() as the y. All in all, 0 for 3. :(
Sorry, my bad.
mny=mean(y);
ypos=max(y);
yneg=min(y);
errorbar(x,mny,yneg,ypos,'x')
If you don't have need otherwise for min/max values, you could just compute and pass inside the errorbar call and dispense with the yneg, ypos temporary variables entirely.
Best Answer