Plotting error bars?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I would like to plot error bars representing the standard deviation of x values, but at the moment the error bars on my graph are only appearing in the vertical axis? Is there anyway I can change the orientation so they are in the correct axis?
Here's the script i'm working with:
x = [12.755 9.1827 6.9252 5.4083 4.3403];
y = [408 265 236 139 124];
coeffs = polyfit(x , y, 1);
yfit = polyval(coeffs, x);
res = y - yfit ;
xfit = x;
SE = std(x)/sqrt(5);
SD = std(x)
err = [SD SD SD SD SD]
grad = (yfit(1) - yfit(5)) / (x(1) - x(5));
disp(['The gradient of the trendline = ', num2str(grad)])
errorbar(x, y, err, 'blue')
hold on
plot(x ,y, 'x', xfit, yfit, 'r-+', 'LineWidth',1.1)
set (gca, 'FontName', 'Century')
grid on
grid minor
title('Plot of buckling load vs 1/Length for fixed-fixed end condition')
ylabel('Pcr / N');
xlabel('1/L^2 / m^2')
legend('Standard Deviation', 'Data Points', 'Trendline')
0 Kommentare
Antworten (1)
the cyclist
am 9 Apr. 2018
(Unless you have an older version of MATLAB, which I think might not have had horizontal bars.)
2 Kommentare
the cyclist
am 3 Mär. 2022
This link will take you directly to the documentation example of plotting both horizontal error bars. Here is the code:
x = 1:10:100;
y = [20 30 45 40 60 65 80 75 95 90];
err = [1 3 5 3 5 3 6 4 3 3];
errorbar(x,y,err,'horizontal')
So, I'm not sure why you claim it doesn't.
Siehe auch
Kategorien
Mehr zu Line Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
