How to calculate the standard deviation of individual points in a dataset
7 views (last 30 days)
Show older comments
Chiamaka Onwude
on 19 Apr 2022
Commented: Star Strider
on 19 Apr 2022
Hi, I'm still learning how to use Matlab and I'm having challenges plotting an error bar. It seems to be from my calculated standard deviation. I want to plot an errorbar with x against y and showing the standard deviation of y
x=[0.1:0.3]; y=[37.9, 31.9,34.6]; xy=[x,y] sd=std(xy) errorbar(x,y,sd, 'bp')
I also tried std(x,y) but it didn't work either.
0 Comments
Accepted Answer
Star Strider
on 19 Apr 2022
The standard deviation of a point is 0.
The size of ‘sd’ here must be the same size as both ‘x’ and ‘y’ so ( vertically concatenated ‘x’ and ‘y’ to have something the std function can work with (although this is likely not correct from a statistical perspective). I also supplied a ‘step’ of 0.1 for ‘x’ so it will be the same length as ‘y’.
x=[0.1:0.1:0.3];
y=[37.9, 31.9,34.6];
xy=[x;y];
sd=std(xy);
figure
errorbar(x,y,sd, 'bp')
xlim([0 0.4])
I invite you to experiment with these functions.
.
2 Comments
Star Strider
on 19 Apr 2022
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
More Answers (0)
See Also
Categories
Find more on Errorbars in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!