I have a function testF22 like this
rndA = RandomReal[{0.1, 0.15}]
rndB = RandomReal[{0.2, 0.25}]
testF22[x_] =
If[x <= rndA, Exp[x], If[x >= rndB, Exp[x] - 0.1, 1/zzz]]
zzz - is something unknown. It is a test example. In real program I have similar, but it is difficult to put here because of complexity. unknown variable appears when I use NSolve and it cannot find solution for some input parameters. Let's say I run NSolve many times for different points and it gives me an array of values depend on x, and later I make a function with Interpolation[]. In other words every value of function at point x is a number which is returned by NSolve. I have this gap, if my function is undefined. I put random numbers because I do not know the range of gap, it depends on parameters and can be different.
and if I plot it, it looks like this
Plot[testF22[x], {x, 0, 0.3}]
I would like to fill the gap of my function by last known value like here
I can easily fill it with fixed value like this
testF33[x_] := If[NumericQ[testF22[x]], testF22[x], 0.5]
Plot[testF33[x], {x, 0, 0.3}]
But the problem is, that I do not want to put just fix value lke 0.5 in my exampke, I want to put nearest known defined value, it will be dynamic depends on some parameters or random number in my example. Or maybe there is another way how to fill this gap with something a little bit different?
UPDATE 1
Because I got many answers where it is assumed that I know missing interval, I would like to clarify, that testF22[x_] is an Interpolation of array of data. I do not know what is rndA and rndB. I just put is as an example. I need something like like this:
take existing function testF22[x] with missing data in unknown range and make another one with complete data, without touching testF22 and without knowing it's internal details.
Another example (it is not tested, but just for understanding): In normal case I have something like this
myData = {{0,0},{0.1, 0.5},{0.15, 0.1},{0.16, 0.2},{0.17, 0.3},{0.2, 0.6},{0.25, 0.7},{0.3, 0.8}}
myFunc[x_] = Interpolation[myData][x]
Plot[myFunc[x], {x,0,0.3}]
But in some cases I got something like
myData = {{0,0},{0.1, 0.5},{0.15, zzz},{0.16, zzz},{0.17, zzz},{0.2, 0.6},{0.25, 0.7},{0.3, 0.8}}
myFunc[x_] = Interpolation[myData][x]
Plot[myFunc[x], {x,0,0.3}]
and missing part appears in the graph. And this part {0.15, zzz},{0.16, zzz},{0.17, zzz} I really do not know when it is started and finished. I do not know this numbers 0.15, 0.16, 0.17. It can be different depends on input parameters.
My question is how to make something generic without knowing exact borders of missing data part.





NSolvefails withCheck, and then store the last value when it converged (in the example, something like 1.15) and use this value intestF33instead of0.5. – anderstood Nov 14 '16 at 22:21