Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: Piecewise functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg51590] Re: [mg51553] Piecewise functions
  • From: Tomas Garza <tgarza01 at prodigy.net.mx>
  • Date: Sat, 23 Oct 2004 00:23:28 -0400 (EDT)
  • References: <200410220222.WAA07319@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Use "/;" (Condition) in the definition of y (and, of course, use the correct 
Mathematica syntax).

In[1]:=
y[x_] := x /; x > 3;
y[x_] := -x /; -1 < x < 3;
y[x_] := 1 /; x < -1;

In[2]:=
Plot[y[x], {x, -2, 5}];

Tomas Garza
Mexico City

----- Original Message ----- 
From: "Luca" <luca at nospam.it>
To: mathgroup at smc.vnet.net
Subject: [mg51590] [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
>
> 



  • Prev by Date: Re: Step by step answer ?
  • Next by Date: Integration of UnitStep has bugs!? help!
  • Previous by thread: Piecewise functions
  • Next by thread: Re: Piecewise functions