Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question
1  
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 at 4:01
    
Yes, my teacher asked me to define this f(t) using the UnitStep command –  Maria Bonatto Apr 10 at 4:05
    
Anyone have a suggestion for a better tag than mathematical-optimization? –  Michael E2 Apr 10 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 at 13:13
    
Why did you leave out the Abs? Use Plot[UnitStep[4 - Abs[t]], {t, -6, 6}]. –  Szabolcs Apr 10 at 14:24

1 Answer 1

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

Mathematica graphics

You can use this like this also:

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

Mathematica graphics

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

Mathematica graphics

etc...

share|improve this answer
    
A piss wise master :) –  belisarius Apr 10 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 at 13:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.