MathGroup Archive 2008

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

Search the Archive

Re: Plotting a series of piecewise functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88973] Re: Plotting a series of piecewise functions
  • From: dh <dh at metrohm.ch>
  • Date: Thu, 22 May 2008 06:16:02 -0400 (EDT)
  • References: <g11r06$a7i$1@smc.vnet.net>


Hi Claus,

a simple If statement will do it. Further, you haf a syntax error, 

confusing x0 and xo:

f[lambda_,xo_,x_]:=If[x<x0,0,lambda*Exp[-lambda*(x-xo)]];

Plot[Evaluate[Flatten@Table[f[lambda,x0,x],{lambda,0.5,0.5},{x0,4}]],{x,0,10}]

hope this helps, Daniel



Claus wrote:

> Hi,

> I want to plot a series of functions. Namely I want to plot a series of 

> 2-parametric exponential distribution functions. By series I mean the 

> graphs for various xo values on one plot.

> So,

> the function looks like this:

> 

> f[lambda_, xo_, x_]:=lambda*Exp[-lambda*(x-xo)]

> 

> Now I can plot this (wrongly) with

> 

> Plot[Evaluate[Table[f[lambda,xo,x],{lambda,0.5,0.5},{x0,4}]],{x,0,10}]

> 

> The problem is that, really, f should be zero for x<xo.

> I can plot one graph (for xo=1 and lambda=1) like this:

> 

> Plot[Piecewise[{{f[0.5,1,x],x>1},{0,x<1}}],{x,0,10}]

> 

> Now, how could I plot a series of plots (for different xo) on one chart 

> similarly to the Piecwise approach (can I do it with Piecewise at all, 

> or do I need an If clause of sorts)?

> 

> Thank you for your help,

> Claus

> 





-- 



Daniel Huber

Metrohm Ltd.

Oberdorfstr. 68

CH-9100 Herisau

Tel. +41 71 353 8585, Fax +41 71 353 8907

E-Mail:<mailto:dh at metrohm.com>

Internet:<http://www.metrohm.com>




  • Prev by Date: Re: Colors chosen for ListPlot, etc., in v. 6
  • Next by Date: Re: On which OS is Mathematica best implemented?
  • Previous by thread: Re: Plotting a series of piecewise functions
  • Next by thread: On which OS is Mathematica best implemented?