Re: ODE with in a piece wise plot
- To: mathgroup at smc.vnet.net
- Subject: [mg104250] Re: ODE with in a piece wise plot
- From: "Nasser M. Abbasi" <nma at 12000.org>
- Date: Sun, 25 Oct 2009 01:06:01 -0400 (EDT)
- References: <hbu7ps$7he$1@smc.vnet.net>
"Becky" <noslowski at comcast.net> wrote in message news:hbu7ps$7he$1 at smc.vnet.net... > > Can this be done? > > First of all, a basic example and then what I want to change. > > E1=If[-1<=x<=0,1,If[3<=x<=5,2,If[-1<=x<=3,(x-1)]]] > Plot[E1,{x,-5,5}] > > The purpose of this was to join all three areas into one plot. > > Now! I want to put in a ODE where the (x-1) is. > > Is this possible, and if so, would you mind giving me an example? > Do as you said. Just solve the ode, and put the solution where (x-1) is? and use Piecwise[] better that those If's ode = Derivative[2][y][x] + y[x] + 2 == 0.5; sol = y[x] /. First[DSolve[{ode, y[0] == 1, Derivative[1][y][0] == 0}, y[x], x]]; E1 = Piecewise[ { {1, -1 <= x <= 0}, {2, 3 <= x <= 5}, {sol, -1 <= x <= 3} } ]; Plot[E1, {x, -5, 5}, PlotRange -> All] --Nasser