| Author |
Comment/Response |
Henry Lamb
|
10/14/02 11:10pm
Here are two ways to do it.
First, you can use the Which function.
f[x_] := Which[x < 0, 0, x < 1, 1, x < 2, -1, True, 0]
Or you can do the same thing with the UnitStep function.
f[x_] := UnitStep[x] - 2 UnitStep[x - 1] + UnitStep[x - 2]
URL: , |
|