standard deviation in errorbar

143 views (last 30 days)
Sim on 3 Mar 2021
Commented: Star Strider on 3 Mar 2021
[a very silly question!] How to calculate the errorbar with 2 standard deviations in this example?
errorbar(x, mean(y,2), std(y,[],2)) % 1 standard deviation
Just multiplying std by 2 in the errorbar, right?
errorbar(x, mean(y,2), 2 * std(y,[],2))

Accepted Answer

Star Strider
Star Strider on 3 Mar 2021
Not silly at all, however it may not produce the result you want.
It might be more appropriate to calculate the errors as the standard error of the mean (S.E.M.) :
err = 2*(std(y,[],2)/sqrt(size(y,2))); % 2 x Standard Error Of The Mean
errorbar(x, mean(y,2), err) % 2 standard errors of the mean
rather than the standard deviation of the observations themselves.
Star Strider
Star Strider on 3 Mar 2021
@Rik I very much appreciate your compliment!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!