Using errorbar in MATLAB with asymmetric errorbars
34 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Having difficulty using the matlab function errorbar. I'm trying to put errorbars on a plot I drew.
I have a line, y = theta, and a vector of errors named momeerr95.
I tried using errorbar with
errorbar(y, momeerr95, 'rx')
and was returned an error that said "X, Y, and error bars all must be the same length."
Can anyone explain my error or how I might go about plotting these error bars?
1 Kommentar
the cyclist
am 11 Apr. 2015
What are the outputs of
size(y)
and
size(momeerr95)
?
The error you are getting suggests that they are of different size.
Antworten (1)
pfb
am 11 Apr. 2015
Bearbeitet: pfb
am 11 Apr. 2015
My guess is that momeerr95 contains both the upper and the lower values for the errorbars. Or else, how would matlab know that the errorbars are not symmetric? Assuming y is a row vector, I guess that momeerr95 has the same number of columns as y, and two rows instead of one.
Anyway, the answer is in the first sentence of the help for the command "errorbar", which you can summon by typing "help errorbar".
errorbar(X,Y,L,U) plots the graph of vector X vs. vector Y with error bars specified by the vectors L and U...
Apparently you do not have abscissae, so you can define x=1:length(y). Then you have to create two vectors L and U for the lengths of the semi-errorbars. Of course all of the vectors must have the same size.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Errorbars 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!