MathGroup Archive 2009

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

Search the Archive

Table Format Problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg98372] Table Format Problem
  • From: Solver <shawnleroux at hotmail.com>
  • Date: Wed, 8 Apr 2009 05:02:25 -0400 (EDT)

Hello,

I would like to export the results of an NDSolve simulation but I can
not seem to figure out how to export my data in the format I want.
Here is a simplified version of my code. I have two variables: R1 and
P1. I am solving the system from t = 100 to 110 for values of J = 1 to
5. I want my data to be in the following format:
Each column is a solution to a variable for a given time (time are the
rows). I would have 10 columns (R1[J=1], P1[J=1],R1[J=2],P1[J=2]...R1
[J=5],P1[J=5]) and 11 rows (one for each time step). The closest I
could get was having 2 columns (R1, P1) with the rows being solutions
for J=1, then J=2, etc.
Here is my code:

a1=1;
d1=.3;
l1=.15;
T=110;

dR1=J-l1*R1[t]-a1*R1[t]*P1[t];
dP1=a1*R1[t]*P1[t]-d1*P1[t];

Flatten[Map[({R1[110],(P1[110])}/.#)&,Table[sol[J]=NDSolve[{R1'[t]
==dR1,P1'[t]==dP1,R1[0]==1,P1[0]==1},{R1,P1},{t,100,T},MaxSteps-
>100000],{J,1,5,1}]],1]//Transpose;

A=Flatten[Table[Evaluate[({R1[t],P1[t]}/.sol[J]),{J,1,5,1}],{t,100,T,
1}],2];

Export["Data.csv",A];

I appreciate any help you can provide!

Cheers,
Shawn


  • Prev by Date: Re: Bug in Convolve, version 7
  • Next by Date: Re: Enlarging figure size by Mathematica
  • Previous by thread: Re: Re: nostalgia for old behaviour: graphics re-sizing
  • Next by thread: Re: Table Format Problem