Using errorbar in MATLAB with asymmetric errorbars
34 次查看(过去 30 天)
显示 更早的评论
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 个评论
the cyclist
2015-4-11
What are the outputs of
size(y)
and
size(momeerr95)
?
The error you are getting suggests that they are of different size.
回答(1 个)
pfb
2015-4-11
编辑:pfb
2015-4-11
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Errorbars 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!