Function to plot data with error bars in x and y

function plot_errorbar2(x, ux, y, uy, marker, linestyle)
teex = (max(x)-min(x))/100;
teey = (max(y)-min(y))/100;
plot(x, y, marker)
for i = 1:length(x)
  plot([x(i)-ux(i), x(i)+ux(i)], [y(i), y(i)], linestyle)
  plot([x(i)-ux(i), x(i)-ux(i)], [y(i)-teey, y(i)+teey], linestyle)
  plot([x(i)+ux(i), x(i)+ux(i)], [y(i)-teey, y(i)+teey], linestyle)
  plot([x(i), x(i)], [y(i)-uy(i), y(i)+uy(i)], linestyle)
  plot([x(i)-teex, x(i)+teex], [y(i)-uy(i), y(i)-uy(i)], linestyle)
  plot([x(i)-teex, x(i)+teex], [y(i)+uy(i), y(i)+uy(i)], linestyle)
end

End of plot_errorbar2.m