MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Writing to an External file, ie .txt

  • To: mathgroup at smc.vnet.net
  • Subject: [mg90532] Re: Writing to an External file, ie .txt
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Sat, 12 Jul 2008 05:31:01 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <g56ti4$41a$1@smc.vnet.net>

Dave wrote:

> I have a matica simulation that generates a Table. Currently it prints in at 
> the bottom of the notebook and then I copy and paste it into a text file.
> 
> below is the code that generates the Table.
> 
> **************************************************
> PD2mnax0[PD2u_] := 1/(1 + Exp[-(PD2u + 24.7)/5.29]);
> PD2hnax0[PD2u_] := 1/(1 + Exp[(PD2u + 48.9)/5.18]);
> PD2mk10x[PD2u_] := 1/(1 + Exp[-(PD2u + 14.2)/11.8]);
> PD2taumnax[PD2u_] := 1.32 - 1.26/(1 + Exp[-(PD2u + 120)/25]);
> PD2tauhnax[
> PD2u_] := (0.67/(1 + Exp[-(PD2u + 62.9)/10]))*(1.5 +
> 1/(1 + Exp[(PD2u + 34.9)/3.6]));
> PD2taumk1[PD2u_] := 7.2 - 6.4/(1 + Exp[-(PD2u + 28.3)/19.2]);
> 
> 
> 
> 
> solution = NDSolve[{
> 
> PD2mnax'[
> t] == (PD2mnax0[PD2z[t]] - PD2mnax[t])*(1/PD2taumnax[PD2z[t]]),
> PD2mnax[0] == PD2mnax0[-80]*(1/PD2taumnax[-80]),
> PD2hnax'[
> t] == (PD2hnax0[PD2z[t]] - PD2hnax[t])*(1/PD2tauhnax[PD2z[t]]),
> PD2hnax[0] == PD2hnax0[-80]*(1/PD2tauhnax[-80]),
> PD2mkx'[t] == (PD2mk10x[PD2z[t]] - PD2mkx[t])*(1/PD2taumk1[PD2z[t]]),
> PD2mkx[0] == PD2mk10x[-80]*(1/PD2taumk1[-80]), PD2z'[t] == (-1*(0
> + 1*1100*(PD2mnax[t]^3)*PD2hnax[t]*(PD2z[t] - 50)
> + 1*150*(PD2mkx[t]^4)*(PD2z[t] + 80)
> + 1*0.00081*(PD2z[t] + 50)
> )
> *(1/6)),
> PD2z[0] == -80
> 
> },
> 
> 
> 
> {PD2z, PD2mnax, PD2hnax, PD2mkx}, {t, 0, time}, Method -> Automatic,
> MaxSteps -> Infinity];
> 
> 
> mkw = Table[0, {time - 1}];
> 
> 
> For[w = 1, w < (time), mkw[[w]] = PD2z[w] /. solution; w++];
> 
> 
> mkw
> 
> ******************************************************

What about *exporting* the table?

[...]

In[11]:= mkw

Out[11]= {{-79.996}, {-79.9919}, {-79.9879}, {-79.9838}, {-79.9798}, 
{-79.9757}, \
{-79.9717}, {-79.9676}, {-79.9636}}

In[12]:= Export["le.txt", mkw, "Table"]

Out[12]= "le.txt"

In[13]:= FilePrint["le.txt"]

During evaluation of In[13]:=
-79.99595026144705
-79.99190108087485
-79.9878524469452
-79.98380435954662
-79.9797568186066
-79.97570982405419
-79.97166337581847
-79.96761747382855
-79.96357211801356

In[14]:= Import["le.txt", "Table"]

Out[14]= {{-79.996}, {-79.9919}, {-79.9879}, {-79.9838}, {-79.9798}, 
{-79.9757}, \
{-79.9717}, {-79.9676}, {-79.9636}}

In[15]:= Directory[]

Out[15]= "/Users/jean-marcgulliet"

Regards,
-- Jean-Marc


  • Prev by Date: Re: Help with "If" statement within "Table"
  • Next by Date: Re: Defining Functions and Simplifying Solutions
  • Previous by thread: Re: Writing to an External file, ie .txt
  • Next by thread: Re: Writing to an External file, ie .txt