2
$\begingroup$

I am trying to create a Manipulate that will take a translated pulse (u[t-t0]-u[t-t0-ϵ]?/ϵ to smaller values of ϵ. My code accomplishes that, but at some point the resulting plot just disappears. Actually, I don't mind that if I could figure a way to display a Dirac delta spike at t0. I need a conditional to determine when ϵ is too small to plot the pulse, then I need a plot of a spike at t0.

My code is below:

Manipulate[
 u[t_] := UnitStep[t];
 Plot[{1/ϵ (u[t - t0] - u[t - t0 - ϵ])}, {t, 0, 
   Max[1.5, 1.5 ϵ]}, 
   PlotRange -> {-0.5, Max[1.5/ϵ, 1]}, Exclusions -> None, 
   PlotStyle -> {Thick, Red}, LabelStyle -> {Bold, 12}],
   {{ϵ, 0.5}, 0.001, 1, 0.001, Appearance -> "Labeled"},
   {{t0, 0.5}, 0, 1.0}
 ]

The disappearance of the pulse seems to depend on the value of t0. This complicates matters even more.

$\endgroup$
  • $\begingroup$ How would you show a Dirac delta on a graph? $\endgroup$ – Mirko Aveta Nov 22 '16 at 23:45
  • $\begingroup$ with a vertical line with base at the coordinate (t0,0) and end at some (t0,x0) for some large value of x0. $\endgroup$ – Stephen Nov 22 '16 at 23:53
  • $\begingroup$ Replace Exclusions -> None with Exclusions -> {t0, t0 + ϵ}, ExclusionsStyle -> Directive[Thick, Red]. $\endgroup$ – Rahul Nov 23 '16 at 0:39
1
$\begingroup$

If the goal is just to graphically motivate the idea, then may be this would also be an option

Manipulate[
 Graphics[
  {
   Red, Thick
   ,
   If[
    e > 0.02
    , Line[{{0, 0}, {t0, 0}, {t0, 1/e}, {t0 + e, 1/e}, {t0 + e, 
       0}, {2, 0}}]
    , Arrow[{{t0, 0}, {t0, 20}}]
    ]
   }
  , PlotRange -> {{0, 2}, {0, Max[1.5, Min[1.5/e, 20]]}}
  , AspectRatio -> 2/3
  , Axes -> True
  ]
 , {{e, 0.1}, 0.01, 0.1}
 , {t0, 0, 2}
 ]

enter image description here

$\endgroup$
  • $\begingroup$ Good idea to avoid the UnitStep function $\endgroup$ – Stephen Nov 23 '16 at 14:41
2
$\begingroup$
Manipulate[u[t_] := UnitStep[t];
 If[ϵ >= 0.01, 
  Plot[{1/ϵ (u[t - t0] - u[t - t0 - ϵ])}, {t, 0, 
    Max[1.5, 1.5 ϵ]}, 
   PlotRange -> {-0.5, Max[1.5/ϵ, 1]}, Exclusions -> None, 
   PlotStyle -> {Thick, Red}, LabelStyle -> {Bold, 12}], 
  Plot[0, {t, 0, Max[1.5, 1.5 ϵ]}, 
   PlotRange -> {-0.5, Max[1.5/0.005, 1]}, Exclusions -> None, 
   PlotStyle -> {Thick, Red}, LabelStyle -> {Bold, 12}, 
   Epilog -> {Directive[Thick, Red], 
     Line[{{t0, 0}, {t0, Max[1.5/ϵ, 1]}}]}]], {{ϵ, 
   0.5}, 0.001, 1, 0.001, Appearance -> "Labeled"}, {{t0, 0.5}, 0, 
  1.0}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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