Bar(matrix) with errorbars on the same figure
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi
I'm trying to plot bar with errorbars on the same figure. I tryed but it doesn't seem to work. Code: a=<4x4 double> = [0,1,0,0; 4,3,2,1; 2,2,1,3; 1,0,0,0] b=<4x4 double> = [0,1,0,0; 1,2,1,1; 1,1,1,2; 1,0,0,0] bar(a); hold on;errorbar(a,b,'.'); the answer is

How to put errorbar on each bar?
0 commentaires
Réponses (1)
Star Strider
le 30 Déc 2016
4 commentaires
Star Strider
le 3 Jan 2017
My pleasure!
I assumed you were using R2014b or later. I can no longer run this code (archived from a 2014 Answer), so I will let you adapt it. The loop is different for R2014a and earlier:
load('Mean.mat') % Mean contains all mean values and consists of 5 rows
load('Stddeviation.mat')
x = [time]; % define x-axis
y = [IC1,IC2,IC3,IC4]; % define y-axis
e = [sd1,sd2,sd3,sd4,sd5,sd6]'; % define standard deviation
figure
hBars = bar(y,1.0,'grouped');
set(gca,'XTickLabel',{'Baseline','0,1','0.2','0.3','0.4','0.5'})
% set ticks and tick labels
xlabel('Time')
ylabel('Impulse')
hold on
for k1 = 1:4
hb = get(get(hBars(k1),'Children'), 'XData');
midbar = mean(hb);
errorbar(midbar, y(:,k1), e(:,k1), '.') % plotting errors
end
title('Impulse');
legend('a','b','c','d','Location','SouthEastOutside')
% put in lower right
box off
hold off
Voir également
Catégories
En savoir plus sur Errorbars dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
