MathGroup Archive 2005

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

Search the Archive

Re: How to define and plot a periodic signal?

  • To: mathgroup at
  • Subject: [mg62597] Re: [mg62556] How to define and plot a periodic signal?
  • From: Murray Eisenberg <murray at>
  • Date: Tue, 29 Nov 2005 04:44:48 -0500 (EST)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <>
  • Reply-to: murray at
  • Sender: owner-wri-mathgroup at

Surely you know how to define a function of some sort, e.g.:

   f[x_] := x^2

And how to plot a function, e.g.:

   Plot[f[x], {x, 0, 8}]

So I assume the only difficulty you're having is to define the
particular triangular function.

My suggestion is to first define it for one period; to do that, you
could use Piecewise (if you're using a recent enough version of
Mathematica) or else synthesize the function using UnitStep (in exactly
the same way one does that via formulas by hand).  Then extend it using
periodicity.  For example:

  f[x_] := Piecewise[ { { x, 0 <= x <= 1}, { 2 - x, 1 <= x <= 2}}]
  f[ x_ /; x > 2] := f[ x - 2]
  f[ x_ /; x < 0] := f[ x + 2]

aza wrote:
> Hello,
> I need to define a function that is a single triangular pulse repeated
> periodically. How could I define this function and plot it?

Murray Eisenberg                     murray at
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305

  • Prev by Date: Re: Problem in Exporting Mathematica graphics What service do we have to run?
  • Next by Date: Bypassing built-in functions in differentiation
  • Previous by thread: How to define and plot a periodic signal?
  • Next by thread: Re: How to define and plot a periodic signal?