Hi,
Could you please help me on how to plot multiple bars (means) and their respective error bars(standard deviations)?
please find example of my data below;
meanA = [1.9000 5.1333 9.6167]
meanB =[2.1069 4.8297 8.8746]
meanC =[1.6632 6.1078 9.9431]
SD_A =[0.1549 0.3983 0.2137]
SD_B =[0.5744 1.0037 0.9494]
SD_C =[0.7757 1.6038 1.5165]
THANKS

 採用された回答

Star Strider
Star Strider 2019 年 2 月 13 日

0 投票

Try this:
meanA = [1.9000 5.1333 9.6167];
meanB =[2.1069 4.8297 8.8746];
meanC =[1.6632 6.1078 9.9431];
SD_A =[0.1549 0.3983 0.2137];
SD_B =[0.5744 1.0037 0.9494];
SD_C =[0.7757 1.6038 1.5165];
meanABC = [meanA; meanB; meanC]';
SD_ABC = [SD_A; SD_B; SD_C];
figure
hBar = bar(meanABC, 0.8); % Return ‘bar’ Handle
for k1 = 1:size(meanABC,1)
ctr(k1,:) = bsxfun(@plus, hBar(k1).XData, hBar(k1).XOffset'); % Note: ‘XOffset’ Is An Undocumented Feature, This Selects The ‘bar’ Centres
ydt(k1,:) = hBar(k1).YData; % Individual Bar Heights
end
hold on
errorbar(ctr, ydt, SD_ABC, '.r') % Plot Error Bars

4 件のコメント

AUWAL ABUBAKAR
AUWAL ABUBAKAR 2019 年 2 月 14 日
Thanks a million. It works perfectly.
Regards
Star Strider
Star Strider 2019 年 2 月 14 日
As always, my pleasure.
YoungBae Jeon
YoungBae Jeon 2021 年 1 月 13 日
Thanks a lot !!!! Perfect answer
Star Strider
Star Strider 2021 年 1 月 13 日
YoungBae Jeon — Thank you!

サインインしてコメントする。

その他の回答 (1 件)

StefBu
StefBu 2019 年 2 月 13 日

0 投票

Hi,
you can use the functions bar and errorbar.
Plot your Mean-Data with bar and your standard deviation with errorbar.
Greetings
Stefan

カテゴリ

ヘルプ センター および File ExchangeErrorbars についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by