# UnitStep in Mathematica when t varies differently

How can I use the UnitStep command when I have a piecewise function $f(t)$, where $f(t)= 0$, when $|t|>4$, and $f(t)=1$, when $|t|<4$? I tried with UnitStep[t-4] but didn't work like I want it to work.

-
Welcome to Mathematica.SE. Please clarify your question. Are you trying to define f[t] in Mathematica? Have you looked at Piecewise in the Documentation Center? – m_goldberg Apr 10 '14 at 4:01
Yes, my teacher asked me to define this f(t) using the UnitStep command – Maria Bonatto Apr 10 '14 at 4:05
Anyone have a suggestion for a better tag than mathematical-optimization? – Michael E2 Apr 10 '14 at 12:04
Sorry about it, I never used this website before, I just put the first thing that I found. – Maria Bonatto Apr 10 '14 at 13:13
Why did you leave out the Abs? Use Plot[UnitStep[4 - Abs[t]], {t, -6, 6}]. – Szabolcs Apr 10 '14 at 14:24

f[t_] := UnitStep[t + 4] - UnitStep[t - 4]
Plot[f[t], {t, -10, 10}, Exclusions -> None]


You can use this like this also:

Plot[Sin[t] f[t], {t, -10, 10}, Exclusions -> None, PlotRange -> All]


 Plot[5 f[t], {t, -10, 10}, Exclusions -> None, PlotRange -> All]


etc...

-
A piss wise master :) – Dr. belisarius Apr 10 '14 at 4:35
Thank u, I was trying to plug with Abs(t), but it was not working. I never used Mathematica before take this class, I am learning now =) – Maria Bonatto Apr 10 '14 at 13:09