MATLAB: How to make a plot using ERRORBAR that plots the entire mean, but only some of the error bars in MATLAB 7.8 (R2009a)

dataerrorbarfewerMATLABpointsresolution

I generate a plot using ERRORBAR with many data points. This creates a very large number of error bars. I would only like it to show every 20th instead

Best Answer

This can be done by first plotting the desired error bars, hiding the mean line, and then plotting the full resolution mean over it. For example, see code below:
means=sin(1:100);
std=rand(1,100);
resolution=20;
h=errorbar(1:resolution:length(means),means(1:resolution:end),std(1:resolution:end));
k = get(h,'Children');
set(k(1),'Color','w');
hold on
plot(means)
This example uses the ERRORBAR function with every 20th point, and then sets the color of the mean line to white. With the error bars in place, the PLOT command is used to plot every point of the mean.