Asked by Aftab Ahmed Khan
on 25 Jul 2014

Hi Everyone, How can i put errorbars in my figure below (Between red and green graphs)?

Answer by Star Strider
on 25 Jul 2014

Accepted Answer

Use the errorbar function on the line of your choice. The easiest way to do this is to plot that line, then use hold to plot the others:

figure(1)

errorbar(Traffic, EngsetPb, barvector)

hold on

plot( ... the rest ... )

hold off

grid

Hypothetical variables here.

Star Strider
on 25 Jul 2014

What error bars do you want to plot? The Statistics Toolbox should give you the standard errors if you are using a regression function. The functions and methods you use to get those depend on the regression function you’re using. For nlinfit for instance, you would use nlpredci.

Otherwise calculating confidence intervals is more complicated, for instance if you have empirical data you are plotting as a mean and standard error at each point. Those are usually given with respect to a specific distribution. (My experience with the Erlang distribution is limited, so I can’t comment on it specifically.) The general rule is to use either the t-distribution or the normal distibution. For the normal distribution it is usually given as 1.96 times the standard error. The standard error is given by:

SE = std(data)/sqrt(N);

where N = length(data) for each point.

Aftab Ahmed Khan
on 25 Jul 2014

Star Strider
on 25 Jul 2014

My pleasure!

Sign in to comment.

Answer by Wayne King
on 25 Jul 2014

Edited by Wayne King
on 25 Jul 2014

Do you have the Statistics Toolbox?

x = 1:10;

y = sin(x);

e = std(y)*ones(size(x));

plot(x,y,'b')

hold on

errorbar(x,y,e,'bo','markerfacecolor',[0 0 1])

Not sure exactly what you mean by "between red and green graphs"

I'm assuming that each data point is an estimate and you have an associated confidence inteval that you want to represent

Aftab Ahmed Khan
on 25 Jul 2014

Wayne King
on 25 Jul 2014

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 0 Comments

Sign in to comment.