Re: Piecewise functions
- To: mathgroup at smc.vnet.net
- Subject: [mg51568] Re: [mg51553] Piecewise functions
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Sat, 23 Oct 2004 00:21:50 -0400 (EDT)
- Reply-to: hanlonr at cox.net
- Sender: owner-wri-mathgroup at wolfram.com
Clear[y]; y[x_ /; x>3]:= x; y[x_ /; -1<x<3]:= -x; y[x_] := 1; Plot[y[x],{x,-3,5}]; However, with this definition you cannot directly plot the derivative. Plot[y'[x],{x,-3,5}]; Whereas, using UnitStep Clear[y]; y[x_] := 1-UnitStep[x+1]*(x+1)+ UnitStep[x-3]*2x; Plot[y[x],{x,-3,5}]; Plot[y'[x],{x,-3,5},PlotRange->All]; Bob Hanlon > > From: Luca <luca at nospam.it> To: mathgroup at smc.vnet.net > Date: 2004/10/21 Thu PM 10:22:10 EDT > To: mathgroup at smc.vnet.net > Subject: [mg51568] [mg51553] Piecewise functions > > Hi all. I'm studying for the exam of signals and systems and I was > trying to plot some kind of functions I transformed for exercise. So, I > need to plot piecewise functions like: > > y(x) = x if x > 3 > y(x) = -x if -1 < x < 3 > y(x) = 1 else > > (should have been a system). > I found out in the guide the chapter about this, and I learned that it > is possible with the function UnitStep, which I know. Anyway, I found > it difficult to determine the equation of the function using this > method. Is it possible to do it simply writing everything like I did > before, more or less? i.e. without having to determine the equation > with the UnitStep function. > Hope I've been clear enought. Many thanks. > > Luca > >