Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Errorbars in a dataset

Subject: Errorbars in a dataset

From: Daniel Robbins

Date: 4 Jan, 2013 19:59:08

Message: 1 of 3

Does anyone know how to plot errorbars on a line graph from data stored in a dataset?

If I store the data in an array I can produce the graph with the following code:

c7data=xlsread('TFangleTOP.xls');
c7MEAN=mean(c7data);
c7SD=std(c7data);
c7SEM=c7SD./length(c7SD);
s2data=xlsread('TFangleBOTTOM.xls');
s2MEAN=mean(s2data);
s2SD=std(s2data);
s2SEM=s2SD./length(s2SD);
errorbarLOWERzeros = [0 0 0 0];
errorbarUPPERzeros = [0 0 0 0];
xAXIS = [1 2 3 4];
errorbar(xAXIS,c7MEAN,errorbarLOWERzeros, c7SEM,':bo')

However if I store the data in a dataset in the following approach:

ds1 = dataset('xlsfile', 'Ltrap.xls');

I can plot the data using:

datasetfun(@plot,ds1,'DataVars','Fmean')

but I can't seem to figure out how to get errorbars on the chart.

Any help will be greatly appreciated.
Many thanks
Dan
 

Subject: Errorbars in a dataset

From: Tom Lane

Date: 7 Jan, 2013 16:58:19

Message: 2 of 3

> Does anyone know how to plot errorbars on a line graph from data stored in
> a dataset?
...
> errorbar(xAXIS,c7MEAN,errorbarLOWERzeros, c7SEM,':bo')
...
> datasetfun(@plot,ds1,'DataVars','Fmean')

Dan, the datasetfun function is for applying functions to each of a set of
variables. You want to apply a function to one set in a particular way. I
think the easiest way would be to reference each variable directly:

errorbar(ds1.xAXIS, ds1.c7MEAN, ds1.errorbarLOWERzeros, ds1.c7SEM,':bo')

-- Tom

Subject: Errorbars in a dataset

From: Daniel Robbins

Date: 8 Jan, 2013 11:33:08

Message: 3 of 3

Hi Tom,

This works well, thank you for your help - much appreciated!

Dan



"Tom Lane" <tlane@mathworks.com> wrote in message <kceurb$7q6$1@newscl01ah.mathworks.com>...
> > Does anyone know how to plot errorbars on a line graph from data stored in
> > a dataset?
> ...
> > errorbar(xAXIS,c7MEAN,errorbarLOWERzeros, c7SEM,':bo')
> ...
> > datasetfun(@plot,ds1,'DataVars','Fmean')
>
> Dan, the datasetfun function is for applying functions to each of a set of
> variables. You want to apply a function to one set in a particular way. I
> think the easiest way would be to reference each variable directly:
>
> errorbar(ds1.xAXIS, ds1.c7MEAN, ds1.errorbarLOWERzeros, ds1.c7SEM,':bo')
>
> -- Tom

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us