MathGroup Archive 2009

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

Search the Archive

Re: ODE with in a piece wise plot


"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 



  • Prev by Date: Re: How create vertical line using Plot?
  • Next by Date: Re: How to format Superscript and Subscript for a symbol to the same
  • Previous by thread: Re: ODE with in a piece wise plot
  • Next by thread: Ten chess-players...