Merge pull request #1115 from mkborregaard/default-function-limits

Function default x limits: fix #1109
This commit is contained in:
Michael Krabbe Borregaard 2017-09-29 09:44:54 +02:00 committed by GitHub
commit bcc2f089be

View File

@ -363,11 +363,24 @@ end
xmin, xmax = try xmin, xmax = try
axis_limits(plt[1][:xaxis]) axis_limits(plt[1][:xaxis])
catch catch
-5, 5 xm = tryrange(f, [-5,-1,0,0.01])
xm, tryrange(f, filter(x->x>xm, [5,1,0.99, 0, -0.01]))
end end
f, xmin, xmax f, xmin, xmax
end end
# try some intervals over which the function may be defined
function tryrange(F, vec)
for v in vec
try
tmp = F(v)
return v
catch
end
end
error("Function not defined over the given interval, $vec")
end
# #
# # -------------------------------------------------------------------- # # --------------------------------------------------------------------
# # 2 arguments # # 2 arguments