Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: Table Format Problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg98425] Re: Table Format Problem
  • From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
  • Date: Thu, 9 Apr 2009 05:57:15 -0400 (EDT)
  • References: <grhp6r$mh1$1@smc.vnet.net>

Shawn,

Only one line needs to be changed an it should work:

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

Cheers -- Sjoerd

On Apr 8, 11:02 am, Solver <shawnler... at hotmail.com> wrote:
> 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 t=
o
> 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},Ma=
xSteps-
>
> >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: Hyperlinks
  • Next by Date: Re: Table Format Problem
  • Previous by thread: Re: Table Format Problem
  • Next by thread: Re: Table Format Problem