Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » sci.math.* » sci.math.symbolic.independent

Topic: Using "If" and "NDSolve" together - Mathematica
Replies: 4   Last Post: Sep 23, 2011 1:00 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Guest

Watch Watch this User
Using "If" and "NDSolve" together - Mathematica
Posted: Jan 22, 2010 11:14 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hello!

I have a tricky job to do: I want to simulate something, and want to
assign a value to a variable under certain conditions. Those are, if
time is within a certain interval, I want that variable to have that
value. Otherwise, I want it to have other value.

Until now, I have been trying to use the following command:

Funcao[first_, last_] :=
Plot[A[t] /.
NDSolve[
{A'[t] == k0 A0 - k1 A[t], B'[t] == k1 A[t] - k2 B[t],
C'[t] == k2 B[t] - k3 C[t], A[0] == 2 10^-6, B[0] == 0,
C[0] == 0} /. k0 -> 10^-2 /. k1 -> 10^-5 /. k2 -> 10^-6 /.
k3 -> 10^1 /. If[first < t < last, A0 -> 1, 0], {A, B, C},
{t,
0, 1000}], {t, 0, 1000}]



for some reason, it is not working, and I cannot figure out why...

With that command I will want to plot A[t], for t->{0,1000}, and
considering that A0->1 if first<t<last, and A0->0 if t<first or
t>last. That way, A[t] should be higher if first<t<last.

Can you guys please give me some tips? Thanks



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.