MathGroup Archive 2010

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

Search the Archive

Re: Manipulate piecewise functions,

  • To: mathgroup at smc.vnet.net
  • Subject: [mg107653] Re: Manipulate piecewise functions,
  • From: "Nasser M. Abbasi" <nma at 12000.org>
  • Date: Mon, 22 Feb 2010 03:07:28 -0500 (EST)
  • References: <hlqu4a$gog$1@smc.vnet.net>

"Vedhas | sahdeV" <vedhas at gmail.com> wrote in message 
news:hlqu4a$gog$1 at smc.vnet.net...
>a = {1 2 3 4 5 6}
> The goal is to plot a piecewise function corresponding to each of "a"
> values, with manipulate where control variable is p, and the function
> for plot y versus x is:
> y=x-p for x-p<a, and (x-p)^2 for (x-p)>=a i.e. 6 plots getting
> manipulated simultaneously.
>
> I am new to Mathematica and this might be a naive question, but I
> couldn't find a solution through help documentation. I will appreciate
> if you can help!
>
> Thanks,
>
> Vedhas
>

Not sure if this is what you meant

Manipulate[process[a, p, max], {{a, 1, "a"}, 1, 6, 1,
   Appearance -> "Labeled"}, {{p, 1, "p"}, 1, 100, 0.1,
   Appearance -> "Labeled"}, {{max, 10, "max range"}, 1, 100, 1,
   Appearance -> "Labeled"}, FrameMargins -> 0, ImageMargins -> 0,
  ContinuousAction -> False, SynchronousUpdating -> False,
  Initialization :> {process[a_, p_, max_] :=
     Module[{y}, y[x_] := Piecewise[{{x - p, x - p < a},
          {(x - p)^2, x - p >= a}}]; Plot[y[x], {x, -max, max},
        ImagePadding -> {{5, 1}, {20, 4}}, ImageMargins -> 5,
        ImageSize -> 400, AspectRatio -> 0.5]]}]

--Nasser 




  • Prev by Date: Re: Manipulate piecewise functions,
  • Next by Date: Re: DiscreteUniformDistribution PDF isn't piecewise?
  • Previous by thread: Re: Manipulate piecewise functions,
  • Next by thread: Re: Manipulate piecewise functions,