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