Effacer les filtres
Effacer les filtres

Using errorbar in MATLAB with asymmetric errorbars

32 vues (au cours des 30 derniers jours)
Kyle Marocchini
Kyle Marocchini le 11 Avr 2015
Modifié(e) : pfb le 11 Avr 2015
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 commentaire
the cyclist
the cyclist le 11 Avr 2015
What are the outputs of
size(y)
and
size(momeerr95)
?
The error you are getting suggests that they are of different size.

Connectez-vous pour commenter.

Réponses (1)

pfb
pfb le 11 Avr 2015
Modifié(e) : pfb le 11 Avr 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.

Catégories

En savoir plus sur Errorbars dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by