Errorbar plotting in MATLAB

조회 수: 1 (최근 30일)
Aniruddha Das
Aniruddha Das 2021년 4월 2일
댓글: Aniruddha Das 2021년 4월 5일
I have 3 vectors which contains numerical data. I can calculate the median, positive and Negative standard deviation of these numbers for each vector. I want to plot these 3 vectors in a single graph showing errorbars and also want to visualise each datapoint of each vector in different colors. How to do that?
  댓글 수: 2
dpb
dpb 2021년 4월 2일
What did you try using errorbar and where did you get stuck, specifically?
I don't know what a "negative standard deviation" is; perhaps you just mean the negative errorbar error value? Unless use asymmetric error values, you only pass one error value for errorbar
You don't give any klews as to what you would want to do about using the median for something; perhaps you might also want to look at Box plots...the boxplot function in ML.
Aniruddha Das
Aniruddha Das 2021년 4월 5일
Thank you.

댓글을 달려면 로그인하십시오.

채택된 답변

Meg Noah
Meg Noah 2021년 4월 2일
편집: Meg Noah 2021년 4월 2일
vec1 = rand(20,1);
vec2 = 20*rand(20,1)-15*rand(20,1);
vec3 = 3*rand(20,1);
med = [median(vec1) median(vec2) median(vec3)];
pos = [3*std(vec1) 3*std(vec2) 3*std(vec3)];
neg = [std(vec1) std(vec2) std(vec3)];
for ivec = 1:3
errorbar(ivec,med(ivec),pos(ivec),neg(ivec),'.','DisplayName',['Vector ' num2str(ivec)]);
hold on;
end
xlim([0 4]);
legend('location','best');
% all the data on one plot with error bars
figure();
errorbar([1:20]',vec1,pos(1)*ones(20,1),neg(1)*ones(20,1),'.','DisplayName','Vector 1');
hold on;
errorbar([1:20]',vec2,pos(2)*ones(20,1),neg(2)*ones(20,1),'.','DisplayName','Vector 2');
errorbar([1:20]',vec3,pos(3)*ones(20,1),neg(3)*ones(20,1),'.','DisplayName','Vector 3');
xlim([0 21]);
legend('location','best');

추가 답변 (0개)

카테고리

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