| Author |
Comment/Response |
mike
|
09/22/09 7:22pm
Suppose I have a file called "test" that contains some text, like
g[t]
or more generally
{g1[t],g2[t],...}
I want to import the file, and use the contents to define a new function (or vector function) with t as the variable. (I want a big list of names for functions in a system of ODEs.)
I've tried using Import, ReadList, and Get, but these don't seem to work. For example,
In[1]:= f[t_]:=Get["test"]
In[2]:= f[t]
Out[2]:= g[t]
which initially looks right, but...
In[3]:= f[7]
Out[3]:= g[t]
It is as though the function f is the constant function whose value is the string "g[t]". The same thing happens with Import and ReadList. Of course, if I just things in manually
In[4]:= f[t_]:=g[t]
then things work out as desired:
In[5]:= f[t]
Out[5]:= g[t]
In[6]:= f[7]
Out[6]:= g[7]
I want to import the names from a file so that I can automate an otherwise very long and tedious process. What is the issue here, and how might I resolve it?
URL: , |
|