[Date Index]
[Thread Index]
[Author Index]
Re: Piecewise functions
*To*: mathgroup at smc.vnet.net
*Subject*: [mg51561] Re: [mg51553] Piecewise functions
*From*: DrBob <drbob at bigfoot.com>
*Date*: Sat, 23 Oct 2004 00:21:41 -0400 (EDT)
*References*: <200410220222.WAA07319@smc.vnet.net>
*Reply-to*: drbob at bigfoot.com
*Sender*: owner-wri-mathgroup at wolfram.com
Clear@y
y[x_] /; x > 3 := x
y[x_] /; -1 < x < 3 := -x
y[_] := 1
Plot[y@x, {x, -2, 4}]
y/@{-1,3}
{1,1}
or
Clear@y
y[x_] := Which[x > 3, x,
-1 < x < 3, -x,
True, 1]
Plot[y@x, {x, -2, 4}]
y/@{-1,3}
{1,1}
or
Clear@y
y[x_] := 1 + (-1 - x) UnitStep[x + 1] + 2x UnitStep[x - 3]
Plot[y@x, {x, -2, 4}]
y/@{-1,3}
{1,3}
The last form has big advantages if you want to differentiate or integrate the function.
Bobby
On Thu, 21 Oct 2004 22:22:10 -0400 (EDT), Luca <luca at nospam.it> wrote:
> 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
>
>
>
>
--
DrBob at bigfoot.com
www.eclecticdreams.net
Prev by Date:
**Re: Re: can't MATHEMATICA simplify simple expressions?**
Next by Date:
**Re: [Help]How to reprensent the result in vector form?**
Previous by thread:
**Re: Piecewise functions**
Next by thread:
**Re: Piecewise functions**
| |