# Evaluate an Interpolating function and export results as a table?

**URL:** <https://community.wolfram.com/t/evaluate-an-interpolating-function-and-export-results-as-a-table/14049>\
**Category:** Questions\
**Tags:** equation-solving, import-and-export\
**Created:** [May 6, 2019, 5:34pm UTC](https://community.wolfram.com/t/evaluate-an-interpolating-function-and-export-results-as-a-table/14049 "2019-05-06T17:34:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![csvaughen](https://avatars.discourse-cdn.com/v4/letter/c/d2c977/32.png) [@csvaughen](https://community.wolfram.com/u/csvaughen)\
**Post date:** [May 6, 2019, 5:34pm UTC](https://community.wolfram.com/t/evaluate-an-interpolating-function-and-export-results-as-a-table/14049/1 "2019-05-06T17:34:33Z")

</div>

Hello, this is a ridiculously simple question but I have been working on this far too long and I’m getting no where.

I would like to produce a table of output values based on an interpolating function. The interpolating function is a solution to a nonlinear differential equation and I am able to plot the solution. Frustratingly, I am not able to evaluate the function at specific points or make a table of output values. Ultimately, I’d like to export a table of values say at points t=0 to t=10 that I can import into Excel.

Thank you!!  
Scott Vaughen

[rocket\_equation\_examples.nb](https://community.wolfram.com/uploads/short-url/6zd3sFN1Jl3mtdGIVSJJj6k7taH.nb) (25.1 KB)

---

<div class="post-metadata">

**Author:** ![dontdont9](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@dontdont9](https://community.wolfram.com/u/dontdont9)\
**Post date:** [May 6, 2019, 7:43pm UTC](https://community.wolfram.com/t/evaluate-an-interpolating-function-and-export-results-as-a-table/14049/2 "2019-05-06T19:43:31Z")

</div>

Perhaps you can adapt this

```
sol=v[t]/.NDSolve[DE,v[t],{t,0,10}][[1]];
points=Table[{t,sol},{t,0,10,1}];
Export["file.csv",points]

```

---

<div class="post-metadata">

**Author:** ![mroge02](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/mroge02/32/28775_2.png) [@mroge02](https://community.wolfram.com/u/mroge02)\
**Post date:** [May 6, 2019, 10:45pm UTC](https://community.wolfram.com/t/evaluate-an-interpolating-function-and-export-results-as-a-table/14049/3 "2019-05-06T22:45:04Z")

</div>

I would drop the `[t]` from `v[t]` in the requested form of the solution, and possibly use `NDSolveValue`, depending on how I wanted to use the solution.

```
sol = First@NDSolve[DE, v, {t, 0, 10}] (* returns a rule v -> InterpolatingFunction[..] *)

vIF = NDSolveValue[DE, v, {t, 0, 10}] (* return an InterpolatingFunction[..] *)

```

Then you can evaluate `v` like this:

```
v[4] /. sol
(* 225.484 *)

vIF[4]
(* 225.484 *)

```

To get a table of the actual steps taken by `NDSolve`, you can take advantage of built-in methods of `InterpolatingFunctions` that allow you some access to the internal data:

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

```

The following returns a table of `{t, v}` steps:

```
soltab = Transpose@{Flatten@vIF@"Grid", vIF@"ValuesOnGrid"};

```

The following returns a table of `{t, v, v'}` including the values of the derivative `v'`, in case you want to use the table to do Hermite interpolation in another application:

```
soltab = Transpose@{Flatten@vIF@"Grid", vIF@"ValuesOnGrid", vIF'@"ValuesOnGrid"};

```

But if you want an equal-step table, you can use `Table` and either `sol` or `vIF`:

```
soltab = Table[{t, v[t] /. sol}, {t, 0., 10.}]
soltab = Table[{t, vIF[t]}, {t, 0., 10.}]

```

The tables can be exported as Bill Nelson shows:

```
Export["file.csv", soltab]

```

---

<div class="post-metadata">

**Author:** ![csvaughen](https://avatars.discourse-cdn.com/v4/letter/c/d2c977/32.png) [@csvaughen](https://community.wolfram.com/u/csvaughen)\
**Post date:** [May 6, 2019, 11:25pm UTC](https://community.wolfram.com/t/evaluate-an-interpolating-function-and-export-results-as-a-table/14049/4 "2019-05-06T23:25:29Z")

</div>

Thank you!!! Thank you!!! Yes, I am making some progress with this!!

I can eventually turn this into a lesson for my class!

I wasn’t able to retrieve the .csv file, I just got the output line “file.csv”… but I couldn’t find the file, maybe it’s because I’m currently using the free version of the wolfram programming lab.

But I was able to actually see all the results of my interpolating function evaluated at a series of input values for t=0 to t=10. That was my main goal. At this point, I’m just typing the data into excel based on what I can read from the output.

THANK YOU THANK YOU for the quick reply!!!

---

<div class="post-metadata">

**Author:** ![csvaughen](https://avatars.discourse-cdn.com/v4/letter/c/d2c977/32.png) [@csvaughen](https://community.wolfram.com/u/csvaughen)\
**Post date:** [May 6, 2019, 11:27pm UTC](https://community.wolfram.com/t/evaluate-an-interpolating-function-and-export-results-as-a-table/14049/5 "2019-05-06T23:27:45Z")

</div>

Ok!! Yes!!! I’m going to try this!! thank you - Michael, your very helpful reply was posted while I was typing out my response to Bill

Thank you!!

---

<div class="post-metadata">

**Author:** ![csvaughen](https://avatars.discourse-cdn.com/v4/letter/c/d2c977/32.png) [@csvaughen](https://community.wolfram.com/u/csvaughen)\
**Post date:** [May 7, 2019, 12:52pm UTC](https://community.wolfram.com/t/evaluate-an-interpolating-function-and-export-results-as-a-table/14049/6 "2019-05-07T12:52:00Z")

</div>

Thank you again Bill and Michael!

I basically got it now, attached is my result… this will eventually become a lesson in my class, thank you!

-Scott

[Launch\_Flea\_Nonlinear\_Drag.pdf](https://community.wolfram.com/uploads/short-url/jFpziP2dEg9zmUhiCOVcs8zcsEl.pdf) (556 KB)
