登录论坛

查看完整版本 : [MATLAB图像处理] 有个关于双误差棒的问题


tnt2345
2009-05-13, 14:40
程序如下 那位大侠解释下我究竟那里出错了啊 运行了不出结果
function errorbarxy(x,y,lx,ly,ux,uy,linecol,errorcol,lw,ms,mf)

if exist('linecol','var')==0 | isempty(linecol)
linecol='b';
end


if exist('errorcol','var')==0 | isempty(errorcol)
errorcol='r';
end

if exist('lw','var')==0 | isempty(lw)
lw=1;
end

if exist('ms','var')==0 | isempty(ms)
ms=5;
end

if exist('mf','var')==0 | isempty(mf)
mf='w';
end

plot(x,y,linecol,'linewidth',lw,'markersize',ms,'markerface',mf)
hold on

xw=(max(x)-min(x))/100;
yw=(max(y)-min(y))/100;


lye=exist('ly','var');
lxe=exist('lx','var');
uye=exist('uy','var');
uxe=exist('ux','var');

if lye+lxe+uye+uxe==0 | isempty(lx) & isempty(ux) & isempty(ly) & isempty(uy)
return
end

if uye==0 | isempty(uy)
uy=ly;
end

if uxe==0 | isempty(ux)
ux=lx;
end

for t=1:length(x)

if ~isempty(ux)
%x errorbars
line([x(t)-lx(t) x(t)+ux(t)],[y(t) y(t)],'color',errorcol)
line([x(t)-lx(t) x(t)-lx(t)],[y(t)-yw y(t)+yw],'color',errorcol)
line([x(t)+ux(t) x(t)+ux(t)],[y(t)-yw y(t)+yw],'color',errorcol)
end

if ~isempty(uy)
%y errorbars
line([x(t) x(t)],[y(t)-ly(t) y(t)+uy(t)],'color',errorcol)
line([x(t)-xw x(t)+xw],[y(t)-ly(t) y(t)-ly(t)],'color',errorcol)
line([x(t)-xw x(t)+xw],[y(t)+uy(t) y(t)+uy(t)],'color',errorcol)
end
end