Borrar filtros
Borrar filtros

Using errorbar in MATLAB with asymmetric errorbars

32 visualizaciones (últimos 30 días)
Kyle Marocchini
Kyle Marocchini el 11 de Abr. de 2015
Editada: pfb el 11 de Abr. de 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 comentario
the cyclist
the cyclist el 11 de Abr. de 2015
What are the outputs of
size(y)
and
size(momeerr95)
?
The error you are getting suggests that they are of different size.

Iniciar sesión para comentar.

Respuestas (1)

pfb
pfb el 11 de Abr. de 2015
Editada: pfb el 11 de Abr. de 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.

Categorías

Más información sobre Errorbars en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by