I have defined an interpolating function, myfcn[x], valid on the domain x = 0 to 1.5. I am then using ContourPlot to create an implicit plot. Something like:
ContourPlot[myfcn[x t] == t, {t,0,5}, {x,0,1}]
I know a priori that the points on the contour are such that x t will always be in the domain x = 0 to 1.5. However, when I run this, Mathematica outputs the warning:
Input value lies outside the range of data in the interpolating function. Extrapolation will be used.
Is there a way I can tell Mathematica not to extrapolate, and not to try to evaluate the interpolating function outside x= 0 to 1.5?
Answer
As already said in my comment, in newer version of Mathematica you can simply restrict your interpolating function. If ContourPlot gets a non-numeric result, it will ignore it. A simple example is
With[{ip = Interpolation[{1, 4, 5, 7, 9}]},
func[x_ /; 1 <= x <= 5] := ip[x]
]
ContourPlot[func[x t] == x, {t, 0, 2}, {x, 0, 8}]
I'm not sure whether this works in all version (especially < V7), but if it doesn't, you still have the chance to let func return a default value instead: func[_]:=0 if it is not in the interpolated region.

Comments
Post a Comment