# Convert list of InterpolatingFunctions to data [closed]

If I have g which is a list of Interpolation functions such (I cannot copy the interpolation functions for some reason):

g=

How can I convert that to a list of data (say from 20 to 100)?. What I mean is a list of data where I could use for instance later ListPlot and I could plot it that way.

UPDATE:

I have tried Table[g, {x, 20, 100}] before but I get the following error:

• Table[g, {x, 20, 100}]? But why not use Plot[g, {x, 20, 100}] directly though? Jan 19 '21 at 4:21
• @MarcoB thanks! I have tried that but it doesn't work in my case (see update). I think is because my Interpolating functions are at different values of x in the list.
– John
Jan 19 '21 at 4:25
• The domain of the first IF ends at x around 90. For x between 90 and 100, you get the error. Jan 19 '21 at 4:26

Clear["Global*"]

data = RandomReal[10, {20, 2}] // Sort;

g = Interpolation[data]


The source data can be extracted from the InterpolatingFunction

data === Transpose[{g[[3, 1]], g[[4, 3]]}]

(* True *)


To uniformly resample the InterpolatingFunction on the domain

dom = g[[1, 1]]

(* {0.0472677, 9.7063} *)

data2 = {#, g[#]} & /@ (Subdivide[##, 9] & @@ dom);

Show[
Plot[g[x], {x, dom[[1]], dom[[2]]},
PlotRange -> All],
ListPlot[{data, data2},
PlotStyle -> {Blue, Red}]]


EDIT: Building on the comment by J.M.

g["Methods"]

(* {"Coordinates", "DerivativeOrder", "Domain", "ElementMesh", "Evaluate", \
"GetPolynomial", "Grid", "InterpolationMethod", "InterpolationOrder", \
"MethodInformation", "Methods", "OutputDimensions", "Periodicity", \
"PlottableQ", "Properties", "QuantityUnits", "Unpack", "ValuesOnGrid"} *)


The x values

(data[[All, 1]] // Sort) ===
(g["Coordinates"] // Flatten) ===
(g["Grid"] // Flatten)

(* True *)


The y values

Sort[data][[All, 2]] === g["ValuesOnGrid"]

(* True *)

• g["Grid"] and g["ValuesOnGrid"]` should work as well. Jan 19 '21 at 7:43