How can I add standard error bars from standard deviation to individual points on a scatter plot ??

11 次查看(过去 30 天)
Hi, I have the following code:
dataset = xlsread('Test Excel file Mean and std.xlsx');
x = dataset(:, 1);
y = dataset(:, 2);
scatter(x,y,'*b');
grid on
a = ismembertol(dataset(:, 1), 0.13, 0.001); % Rows where column 1 = 0.13
b = ismembertol(dataset(:, 1), 0.26, 0.001); % Rows where column 1 = 0.26
c = ismembertol(dataset(:, 1), 0.39, 0.001); % Rows where column 1 = 0.39
d = ismembertol(dataset(:, 1), 0.52, 0.001); % Rows where column 1 = 0.52
e = ismembertol(dataset(:, 1), 0.65, 0.001); % Rows where column 1 = 0.65
theMean1 = mean(y(a));
theMean2 = mean(y(b));
theMean3 = mean(y(c));
theMean4 = mean(y(d));
theMean5 = mean(y(e));
hold all;
plot(0.13, theMean1, 'rs','MarkerFaceColor','r','MarkerSize',10);
plot(0.26, theMean2, 'rs','MarkerFaceColor','r','MarkerSize',10);
plot(0.39, theMean3, 'rs','MarkerFaceColor','r','MarkerSize',10);
plot(0.52, theMean4, 'rs','MarkerFaceColor','r','MarkerSize',10);
plot(0.65, theMean5, 'rs','MarkerFaceColor','r','MarkerSize',10);
xlabel('distance d b/w mic pairs[cm]');
ylabel('\phi_r_a_t_i_o');
title('Relationship between \phi ratio and distance between Mic Pairs for Array 3');
When I run this code i get following figure :
Now, I want to display error bars such as it shows variation of error from blue data points to each red square for each set of data.Also I want to compute error bars with the help of standard deviation. Can anybody suggest me suitable code modification so that i can get a desirable display ? Thank you

回答(1 个)

jonas
jonas 2018-10-13
I do not have your dataset so cannot run your code. Here's an example of how to use the build-in function errorbar. Should be easy to adapt.
x=1:10;
y=rand(10,50)
errorbar(x,mean(y,2),std(y,[],2))

类别

Help CenterFile Exchange 中查找有关 Errorbars 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by