# Standard deviation across plots

59 views (last 30 days)
Sharah on 15 Feb 2016
Answered: Arnab Sen on 23 Feb 2016 I am trying to do an analysis where I would need to analyse the consistency across trials: refers to the first picture below. Each line represents one trial. There are 9 to 11 trials altogether. I want to plot the average value between the lines as well as plotting and calculating the standard deviation across trial (so that there will be one average trial value and shaded grey area which represent the distribution of data).
Any idea on how to do this?

Show 1 older comment
Sharah on 15 Feb 2016
the errorbar is only for one plot. I have 12 different plots
Yona on 15 Feb 2016
The average of all plot is 1 plot.
if you have
x1 = [1 2 4];
x2 = [1.1 1.9 3.7];
x3 = [0.9 1.9 3.85];
the average is: [1 1.9333 3.85];
the std is: [0.1 0.577 0.15];
Sharah on 15 Feb 2016
the problem is i do not have the same data size for each line.

Arnab Sen on 23 Feb 2016
Hi Sarah,
You can take the approach described by Yona in earlier comments. If you don't have same number of data in all the vectors as you mentioned, you can use in built 'interp1' function to interpolate the missing values for shorter vector. The syntax is as below:
>>vq = interp1(x,v,xq)
where 'x' is the vector of x axis coordinates and 'v' is the vector corresponding values and 'xq' is the query point.