# How to create one errorbar for multiple data points?

11 views (last 30 days)
LM on 3 Feb 2021
Commented: LM on 3 Feb 2021
Hello,
i want to plot a x-vector (1,100) and a y-vector (1,100) with an errorbar. I have already calculated the single value for the standard deviation of the y-vector. This y-vector has been measured 100 times, so i just need one standard deviation for the 100 values of y.
I tried to do this with:
x = ones(1,100);
y = ...;
error = 4.17e-04;
errorbar(x,y,error,'.');
##### 1 CommentShowHide None
VBBV on 3 Feb 2021
error variable must be of same size as x and y see the doc page https://in.mathworks.com/help/matlab/ref/errorbar.html

Daniel Pollard on 3 Feb 2021
If I understand you right, could you do something like
figure; hold on
plot(x, y, 'bx')
errorbar(mean(x), mean(y), std(y), 'k+')
hold off
which I believe should plot all of your y values at x=1, and then overlay an errorbar centred at the mean point with a size equal to the standard deviation of y.
LM on 3 Feb 2021
Understood. Thank you for your effort.