0001 function [linehandles, patchhandles] = errorarea(x,y,l,u)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 if (min(size(x)) == 1), x = x(:); end;
0015 [npts,nlns] = size(x);
0016 switch (nargin),
0017 case 4,
0018 case 3, u = l;
0019 case 2, l = y; u = y; y = x; x = (1:npts)' * ones(1,nlns);
0020 otherwise, error('Invalid syntax.');
0021 end
0022 if (nlns == 1), y = y(:); l = l(:); u = u(:); end;
0023 if (~isequal(size(x), size(y), size(u), size(l)))
0024 error('The sizes of X, Y, L and U must be the same.');
0025 end
0026
0027
0028
0029 linehandles = plot(x,y);
0030
0031
0032 patchhandles = zeros(1,nlns);
0033 for ln = 1:nlns
0034 xwrap = [x(:,ln)',fliplr(x(:,ln)')];
0035 ywrap = [(y(:,ln)+u(:,ln))', flipud(y(:,ln)-l(:,ln))'];
0036 patchhandles(ln) = patch(xwrap, ywrap, get(linehandles(ln), 'Color'), ...
0037 'EdgeColor', 'none', 'FaceAlpha', 0.25);
0038 end
0039
0040 if (nargout == 0)
0041 clear linehandles patchhandles
0042 end