Replace the second plot call with:
patch([x, fliplr(x)], [yCI95(1,:) fliplr(yCI95(2,:))], 'b', 'EdgeColor','none', 'FaceAlpha',0.25)
so the full code is now:
x = 1:100;
y = randn(50,100);
N = size(y,1);
yMean = mean(y);
ySEM = std(y)/sqrt(N);
CI95 = tinv([0.025 0.975], N-1);
yCI95 = bsxfun(@times, ySEM, CI95(:));
figure
plot(x, yMean,'p')
hold on
patch([x, fliplr(x)], [yCI95(1,:) fliplr(yCI95(2,:))], 'b', 'EdgeColor','none', 'FaceAlpha',0.25)
hold off
grid
That should do what you want. (I appreciate your quoting my code!)
Best Answer