MathGroup Archive 1998

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

Search the Archive

Re: Writing output to text files


  • To: mathgroup@smc.vnet.net
  • Subject: [mg11249] Re: Writing output to text files
  • From: Paul Abbott <paul@physics.uwa.edu.au>
  • Date: Wed, 4 Mar 1998 01:39:11 -0500
  • Organization: University of Western Australia
  • References: <6ctcc3$lcv@smc.vnet.net>

Jim Banaszak wrote:

> What is the easiest way to write columns of Mathematica output to a text
> file?

Here is one way using TableForm and TextForm:

In[1]:= mat = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};  In[2]:= TextForm @
TableForm[mat,TableSpacing->{0,1}]>>"mat.data"

!!mat.data
1 2 3
4 5 6
7 8 9

In[3]:= mat = Table[Random[]/10^8, {3}, {3}] Out[3]=
            -9            -9            -9 {{4.41607 10  , 4.42522 10  ,
8.38788 10  }, 
 
             -9            -9            -9
  {4.64891 10  , 1.99887 10  , 2.10872 10  }, 
 
             -9            -10            -9
  {4.07425 10  , 3.27859 10   , 8.23698 10  }}

In[4]:= TextForm @ TableForm[Map[FortranForm, mat, {2}],
	TableSpacing->{0,1}]>>"mat.data"

!!mat.data
4.41607232398322e-9  4.425216519075586e-9  8.38788061250006e-9
4.648906948087301e-9 1.99887223470175e-9   2.108724487864244e-9
4.074251989060328e-9 3.278591410474828e-10 8.23698390200569e-9

Cheers,
	Paul 

____________________________________________________________________ 
Paul Abbott                                   Phone: +61-8-9380-2734
Department of Physics                           Fax: +61-8-9380-1014
The University of Western Australia            Nedlands WA  6907       
mailto:paul@physics.uwa.edu.au  AUSTRALIA                            
http://www.pd.uwa.edu.au/~paul

            God IS a weakly left-handed dice player
____________________________________________________________________



  • Prev by Date: Re: lattice definition: help
  • Next by Date: Re: Assignment to submatrices
  • Prev by thread: Re: Computing my own function efficiently
  • Next by thread: Re: Looking for info on making recursions eat less stack.