How to calculate the standard deviation of individual points in a dataset

7 views (last 30 days)
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.

Accepted Answer

Star Strider
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.
.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!