These calculations take many minutes, and I want to beable to save the
interpolated function--so it does not have to be regenerated every
time I come back to the problem.
How can I do this.?
Thanks
Phil
You need to use Import/Export.
Using v 6:
(* construct an interpolating function *)
In[1]:= if =
y /. NDSolve[ {y''[t] - y[t] t^2 == 0, y[0] == 0, y'[0] == 1},
y, {t, 0, 10}][[1]];
In[2]:= Head[if]
Out[2]= InterpolatingFunction
In[3]:= Export[
ToFileName[{$HomeDirectory, "Desktop"}, "interfunc.m"], if]
Out[3]= C:\Documents and Settings\....\Desktop\interfunc.m
In[4]:= if2 =
Import[ToFileName[{$HomeDirectory, "Desktop"}, "interfunc.m"]];
In[5]:= if2 === if
Out[5]= True
Oleksandr Pavlyk
Wolfram Research
On Sep 7, 1:03 am, "lede...@ssb.rochester.edu"
The function *DumpSave* should be what you are looking for. Here is an
example: we save the interpolating function in the default user
directory, then, in a new session, we load its definition with *Get* (or
<<).
In[1]:= f =
First[u /. NDSolve[{u''[t] + u[t] == 0, u[0] == 0, u'[0] == 1},
u, {t, 0, \[Pi]}]]
Out[1]= InterpolatingFunction[]
In[2]:= DumpSave["f.mx", f]
Out[2]= InterpolatingFunction[]
In[3]:= Quit[]
(* Later, in a fresh session *)
In[1]:= << f.mx
In[2]:= Plot[{f[t], f'[t]}, {t, 0, \[Pi]}]
[... graphic deleted ...]
Regards,
--
Jean-Marc
> I am doing some numerical analysis leading to an interpolated function
> that I will need later.
>
> These calculations take many minutes, and I want to beable to save the
> interpolated function--so it does not have to be regenerated every
> time I come back to the problem.
>
> How can I do this.?
Use Get and Put eg:
g=Interpolation[Range[5]];
g>>"func";
e=<<"func";
Plot[g[x],{x,1,5}]
Plot[e[x],{x,1,5}]
Regards,
Ssezi
Put[] it into an *.m file
Regards
Jens
Get["test"]
regards robert