MathGroup Archive 2005

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

Search the Archive

Re: Controlling program flow across cells

  • To: mathgroup at
  • Subject: [mg54376] Re: Controlling program flow across cells
  • From: highegg at (highegg)
  • Date: Sat, 19 Feb 2005 02:32:43 -0500 (EST)
  • References: <tbq1b6j7edyo@legacy>
  • Sender: owner-wri-mathgroup at

On 18 Feb 05 09:24:43 -0500 (EST), semiclassical wrote:
>Here is the problem:
>I import a large data file - 20 years of hourly observations, which
>used to populate a raw data list of approximately 176,000 rows with
>the following structure:
>{year, day, hour, validity_Flag, data_Item1, ... ,data_Item5}
>The list is then parsed, filtered and operated upon in several
>different ways. In particular I calculate statistical properties of a
>specified 5 year period. The process is encapsulated in a number of
>Cell_1 : Parse[ Import and filter raw data ];
>Cell_2a: Parse[ Chip out and sort period of interest ];
>Cell_2b: Calculate[ statistical properties of validity_Flag ];
>Cell_2c: Calculate[ statistical properties of data_Item ];
>Cell_2d: Calculate[ distribution of data_Item ];
>This is done for most data_Items, additionally calculations are made
>for hourly statistics and quartely statistics. Now what I would like
>to be able to do is loop over the four 5 year periods within the
>complete 20 year span. Here are two questions:
>1. I would like to set up a For[] loop across Cell_2a-Cell_2d to loop
>through the four periods of interest. How can I do this, or should I
>actually have built the program in a different way?
>2. How can I get output from within a For[] loop as it is executing?
>For example, I might like to watch some value of a given variable
>within the loop as it is calculated (in C I would use a printf). 
>semiclassical at

1. evaluating cells repeatedly is possible using FrontEnd functions,
but I strongly recommend you rewrite those as one or more functions,
which can be called "normally".
2. You can use Print[] function in Mathematica 
or StylePrint, CellPrint if you're interested in a good-looking output


  • Prev by Date: Re: "teach" mathematica an integral
  • Next by Date: FW: comparing two lists
  • Previous by thread: Controlling program flow across cells
  • Next by thread: Re: Controlling program flow across cells