Re: Re: Manipulate a NDSolve equation is it possible
- To: mathgroup at smc.vnet.net
- Subject: [mg105609] Re: [mg105602] Re: Manipulate a NDSolve equation is it possible
- From: DrMajorBob <btreat1 at austin.rr.com>
- Date: Fri, 11 Dec 2009 04:17:51 -0500 (EST)
- References: <hfnv37$gg4$1@smc.vnet.net> <200912100959.EAA25371@smc.vnet.net>
- Reply-to: drmajorbob at yahoo.com
This does the integration once (symbolically), rather than all over again (numerically) every time r, c, or v0 is changed: Clear[i, v, v0, r, c] i[t_] = Boole[10 <= t <= 60]; v[r_, c_, v0_, t_] = v[t] /. First@ Assuming[{-80 <= v0 <= -50, 1/10 <= c <= 10, , 1/10 <= r <= 10}, DSolve[{v'[t] == 1/c (i[t] - v[t]/r), v[0] == v0}, v, t]]; Manipulate[ Plot[v[r, c, v0, t], {t, 0, 100}, PlotRange -> {{0, 100}, {-80, 10}}, PlotStyle -> {Blue, Thick}, Frame -> True], {r, 0.1, 10}, {c, 0.1, 10}, {v0, -80, -50}] Bobby On Thu, 10 Dec 2009 03:59:27 -0600, Albert Retey <awnl at gmx-topmail.de> wrote: > Hi, > >> Can the following be made interactive? I would like my students to see >> there results quickly when changing certain values such as the >> resistance >> and capacitance. > > sure it can. This is one simple possibility: > > > i[t_] := If[t < 10 || t > 60, 0, 1]; > > RCSoln[R_, c_:1, v0_:-70] := > NDSolve[{v'[t] == 1/c (i[t] - v[t]/R), v[0] == v0}, v, {t, 0, 100}] > > Manipulate[ > Plot[Evaluate[v[t] /. RCSoln[r, c, v0]], {t, 0, 100}, > PlotRange -> {{0, 100}, {-80, 10}}, PlotStyle -> {Blue, Thick}, > Frame -> True], > {r, 0.1, 10}, > {c, 0.1, 10}, > {v0, -80, -50} > ] > > > hth, > > albert > -- DrMajorBob at yahoo.com
- References:
- Re: Manipulate a NDSolve equation is it possible
- From: Albert Retey <awnl@gmx-topmail.de>
- Re: Manipulate a NDSolve equation is it possible