Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1995

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

Search the Archive

Re: piecewise continuous linear function

  • To: mathgroup at
  • Subject: [mg1180] Re: piecewise continuous linear function
  • From: Elliot Weinberg <weinberg at>
  • Date: Sat, 20 May 1995 05:13:32 -0400

...Message-Id: <9505170729.AA09392 at>
...From: REECE_D <REECE+_D%A1%Electromagnetic_Sciences at>
...Subject: [mg1136] Piecewise function generator
...Content-Length: 416
...To: mathgroup at

...   I want to generate a piecewise continuous linear function by giving a 
...function, call it F, a list of {x,y} values defining the corners of the 
...function.  I can't seem to do it.  Does anyone out there have a quick way 
...of doing it?
...   Thanks in advance,
...   Daryl

This can be done with a one-liner.  The resulting function even
plots correctly, although it would be faster to put together
a graphics object that drew the line segments directly.

Mathematica 2.2 for Solaris
Copyright 1988-93 Wolfram Research, Inc.

In[1]:= pieceWise[list_][x_]:=

In[2]:= example={{1,2},{2,5},{3,0},{4,2}};

In[3]:= Map[pieceWise[example],{1.5,2.5,3.5}]

Out[3]= {3.5, 2.5, 1.}


  • Prev by Date: MMA List Output Query
  • Next by Date: Mathematica GUI builder
  • Previous by thread: MMA List Output Query
  • Next by thread: Mathematica GUI builder