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

MathGroup Archive 2010

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

Search the Archive

Re: Using "If" and "NDSolve" together

  • To: mathgroup at smc.vnet.net
  • Subject: [mg106859] Re: Using "If" and "NDSolve" together
  • From: RBenf <rui.benfeitas at gmail.com>
  • Date: Mon, 25 Jan 2010 05:07:15 -0500 (EST)

Hello Bobby, thanks for all the help! It was good to see how you can simplify what I wrote into just a few coding lines. I'm still learning how to work with Mathematica, and from what I've seen, it will still be a long way until I can use it effectively.

Although the code that you gave me does not do exactly what I want to do, I will surely use it in order to solve my problem. 
Thanks a lot!

> Oh, what a tangled web you weave.
> 
> Clear[funcao]
> funcao[first_, last_] :=
> Module[{k0 = 10^-2, k1 = 10^-5, k2 = 10^-6, k3 =
> = 10, a, b, c},
>    a = a /. First@
> NDSolve[{a'[t] == k0 Boole[first <= t <= last]
> last] - k1 a[t],
> b'[t] == k1 a[t] - k2 b[t], c'[t] == k2 b[t]
> k2 b[t] - k3 c[t],
> a[0] == 2 10^-6, b[0] == 0, c[0] == 0}, {a,
> 0}, {a, b, c}, {t, 0,
>         1000}];
>    Plot[a@t, {t, 0, 1000}, PlotRange -> All]
>    ]
> funcao[0, 100]
> funcao[0, 900]
> funcao[100, 900]
> 
> Bobby


  • Prev by Date: Re: Re: Mathematica gets stuck,
  • Next by Date: Re: Scrolling text: Changing text color, etc.
  • Previous by thread: Re: Using "If" and "NDSolve" together
  • Next by thread: Re: Using "If" and "NDSolve" together