MathGroup Archive 2003

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

Search the Archive

Re: Variable number of intervals

  • To: mathgroup at smc.vnet.net
  • Subject: [mg40454] Re: Variable number of intervals
  • From: bobhanlon at aol.com (Bob Hanlon)
  • Date: Sun, 6 Apr 2003 04:34:21 -0400 (EDT)
  • References: <b6m029$efc$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

g[x_, n_] := Sum[UnitStep[x - k/n], {k, 0, n - 1}]/n;


Bob Hanlon

In article <b6m029$efc$1 at smc.vnet.net>, vnagornyi at netscape.net (Vadim Nagornyi)
wrote:

<< 
Subject:	Variable number of intervals
From:		vnagornyi at netscape.net (Vadim Nagornyi)
To: mathgroup at smc.vnet.net
Date:		Sat, 5 Apr 2003 07:19:37 +0000 (UTC)

Hello,
here is the function that grows on unit interval in 12 steps:

n=12;
Map[(g[x_]:=#/n/;(#-1)/n<=x<=#/n)&,Range[n]];
Plot[g[x], {x,0,1}]

Now, changing n in the first line we can get different number of
steps.
Instead, I would like to make n the function parameter: g[x_,n_] and
define it when plotting, like

Plot[{g[x,3],g[x,7],g[x,12]}, {x,0,1}]

How to to this?
Thanks.
Vadim.












 >><BR><BR>


  • Prev by Date: RE: Variable number of intervals
  • Next by Date: Re: How do I make graphs of (easy) functions like those in textbooks?
  • Previous by thread: RE: Variable number of intervals
  • Next by thread: Re: Variable number of intervals