MathGroup Archive 2008

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

Search the Archive

Separate input/output files

  • To: mathgroup at smc.vnet.net
  • Subject: [mg87076] Separate input/output files
  • From: Narasimham <mathma18 at hotmail.com>
  • Date: Mon, 31 Mar 2008 02:03:43 -0500 (EST)

A typical Mathematica notebook contains input and output together.
With the objective of separating input and output for convenience and
also eliminating  repeated input  commands and statements, I like to
write two separate smaller files somewhat as under:
------
Harmonic.in

Constant [{yi,ydi,w,tmax} = { 1.,.2, 1.,8.}];
NDSolve[{Y''[t]+w^2 Y[t]==0, Y[0]==yi,Y'[0]==ydi},Y,{t,0,tmax}];
y[t_]= Y[t] /.First[%] ;
(* above two lines to be labelled ODE *)
Plot[y'[t],{t,0,tmax}];
(* above line to be labelled  PLT*)
yi=2.; w=7. ; tmax= 4 ;
Table[ {t,y[t],y'[t]}, {t,0,tmax,tmax/15.}]//ColumnForm
(* above line to be labelled  TABL*)
Plot[y[t],{t,0,tmax}];
(* Only tmax = 4 takes effect but not yi and w, the quantities inside
NDSolve curly barckets, do not take effect *)
------------
Harmonic.run

yi = 1.6; w = 2; tmax= 4.;
ODE
PLT
ydi = 2.; w = 1.2; tmax= 2.5 ;
ODE
PLT
TABL
---------------
Harmonic.out
(* Contains output for ODE, PLT,TAB  for changed input parameters,
Harmonic.run lines echoed before respective outputs *)
-------------

How to make such a file separation possible? Such separation I believe
is convenient for dynamical simulation exercises.

Best Regards,
Narasimham





  • Prev by Date: RE: Fast way to select those elements from a list that are in another
  • Next by Date: Re: The FinancialData Function
  • Previous by thread: Any body can help me solve the equation with piecewise function
  • Next by thread: Re: Separate input/output files