Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2013

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

Search the Archive

Re: Help. Fitting 2 dimensional lists with a parametric differential

  • To: mathgroup at smc.vnet.net
  • Subject: [mg129599] Re: Help. Fitting 2 dimensional lists with a parametric differential
  • From: Bob Hanlon <hanlonr357 at gmail.com>
  • Date: Mon, 28 Jan 2013 02:24:42 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <20130126063936.01E9068D8@smc.vnet.net>

data1211 = {
   {0., 0.}, {1., 3.26437*10^-6},
   {2., 8.2151*10^-6}, {3., 0.0000145337},
   {4., 0.000019431}, {5., 0.0000251649},
   {6., 0.0000305308}, {7., 0.000035411},
   {8., 0.0000401542}, {9., 0.0000449553},
   {10., 0.0000499532}, {11., 0.0000545809},
   {12., 0.0000592216}, {13., 0.0000640473},
   {14., 0.0000690212}, {15., 0.0000740661},
   {16., 0.0000782586}, {17., 0.0000822824},
   {18., 0.0000861226}, {19., 0.0000898602},
   {20., 0.0000937152}, {21., 0.0000978347},
   {22., 0.000101408}, {23., 0.000105147},
   {24., 0.000108497}, {25., 0.000111885},
   {26., 0.000115624}, {27., 0.000119227},
   {28., 0.000122341}, {29., 0.00012508},
   {30., 0.000127729}, {31., 0.000130467},
   {32., 0.000133645}, {33., 0.000136591},
   {34., 0.000139623}, {35., 0.00014186},
   {36., 0.000144227}, {37., 0.000146746},
   {38., 0.000148986}, {39., 0.00015123},
   {40., 0.000153402}, {41., 0.000155531},
   {42., 0.0001574}, {43., 0.000159421},
   {44., 0.000161271}, {45., 0.000162982},
   {46., 0.000164705}, {47., 0.000166305},
   {48., 0.000167756}};

tmax = Max[data1211[[All, 1]]];

Clear[model];
model[a_?NumericQ, b_?NumericQ] :=
 y /. NDSolve[{
     y'[t] == -a y[t]^2 + b (1 - y[t]),
     y[0] == 0}, y, {t, 0, tmax}][[1]]

Column[{
   param = FindFit[data1211,
     model[a, b][t], {a, b}, t],
   Plot[
    Evaluate[model[a, b][t] /. param],
    {t, 0, tmax},
    ImageSize -> 350,
    PlotRange -> All,
    AxesLabel -> {"t (sec)", "Ca,mol/liter"},
    BaseStyle -> {FontSize -> 15},
    Epilog -> {Point[data1211]}]}] // Quiet


Bob Hanlon


On Sat, Jan 26, 2013 at 1:39 AM,  <dinodeblasio at gmail.com> wrote:
> Hello everyone,
> I have the following code:
>
> Clear[y];
> Column[{model =
>     DSolve[{y'[t] == -A (y[t])^2 + B (1 - y[t]), y[0] == 0}, y[t],
>       t][[1]], param = FindFit[data1211, y[t] /. model, {A, B}, t],
>    Plot[y[t] /. model /. param, {t, 0, Max[data1211[[All, 1]]]},
>     PlotRange -> All, ImageSize -> 350, PlotStyle -> {Black},
>     AxesLabel -> {"", "Ca,mol/liter"}, BaseStyle -> {FontSize -> 15},
>     Epilog -> {Text["Step [1]", {50, 0.00002}],
>       Text["(sec)", {140, 0.00002}], Point[data1211]}]}] // Quiet
>
> where "data1211" is a list as follows:
> {{0., 0.}, {1., 3.26437*10^-6}, {2., 8.2151*10^-6}, {3.,
>   0.0000145337}, {4., 0.000019431}, {5., 0.0000251649}, {6.,
>   0.0000305308}, {7., 0.000035411}, {8., 0.0000401542}, {9.,
>   0.0000449553}, {10., 0.0000499532}, {11., 0.0000545809}, {12.,
>   0.0000592216}, {13., 0.0000640473}, {14., 0.0000690212}, {15.,
>   0.0000740661}, {16., 0.0000782586}, {17., 0.0000822824}, {18.,
>   0.0000861226}, {19., 0.0000898602}, {20., 0.0000937152}, {21.,
>   0.0000978347}, {22., 0.000101408}, {23., 0.000105147}, {24.,
>   0.000108497}, {25., 0.000111885}, {26., 0.000115624}, {27.,
>   0.000119227}, {28., 0.000122341}, {29., 0.00012508}, {30.,
>   0.000127729}, {31., 0.000130467}, {32., 0.000133645}, {33.,
>   0.000136591}, {34., 0.000139623}, {35., 0.00014186}, {36.,
>   0.000144227}, {37., 0.000146746}, {38., 0.000148986}, {39.,
>   0.00015123}, {40., 0.000153402}, {41., 0.000155531}, {42.,
>   0.0001574}, {43., 0.000159421}, {44., 0.000161271}, {45.,
>   0.000162982}, {46., 0.000164705}, {47., 0.000166305}, {48.,
>   0.000167756}}
>
> Now I'd like to fit the equation: y'[t] == -A (y[t])^3 + B (1 - y[t]),
> by using NDsolve and find the two parameters A and B.
>
> Can anyone help on this?
> Thank really much for your help.
> Dino
>



  • Prev by Date: Mathematica 9 IsotopeData is no longer self-consistent
  • Next by Date: Re: New package for using true (quantum) randomness in Mathematica
  • Previous by thread: Help. Fitting 2 dimensional lists with a parametric differential
  • Next by thread: Re: Help. Fitting 2 dimensional lists with a parametric differential