Re: how to generate pulse function ?
- To: mathgroup at smc.vnet.net
- Subject: [mg41914] Re: how to generate pulse function ?
- From: bobhanlon at aol.com (Bob Hanlon)
- Date: Tue, 10 Jun 2003 04:46:48 -0400 (EDT)
- References: <bc1k0c$bo3$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Clear[u]; u[x_, step_:1, nPulse_:Infinity]:= Module[{y = Mod[x, 2*step]}, (UnitStep[y]-UnitStep[y-step])* (1-UnitStep[x-2*step*nPulse])]; Plot[u[t], {t,0,10.5}]; Plot[u[t,2], {t,0,10.5}]; Plot[u[t,500, 4], {t,0,5000}]; Bob Hanlon In article <bc1k0c$bo3$1 at smc.vnet.net>, "sabrina" <mystery at newbie.com> wrote: << Subject: how to generate pulse function ? From: "sabrina" <mystery at newbie.com> To: mathgroup at smc.vnet.net Date: Mon, 9 Jun 2003 09:28:44 +0000 (UTC) Hello all: I use the following code to generate the pulse function, but it is not right: u[x_,step_,nPulse_]:= Module[ {tlist={},func}, tlist=Table[t,{t,0,nPulse*step,step}]; func=1-UnitStep[Apply[Times,(x-#)&/@tlist]]; Return[func]; ]; s=u[t, 500,4]; Plot[s,{t,0,2200}]; The problem is when the nPulse is odd number, it shows the right answer, but when the nPulse is even, the plot is not right. Would you please help me to make the function right? Thanks a lot!