       • To: mathgroup at smc.vnet.net
• Subject: [mg73333] Re: Array reference help please
• From: "Ray Koopman" <koopman at sfu.ca>
• Date: Tue, 13 Feb 2007 06:51:37 -0500 (EST)
• References: <eqjiid\$7te\$1@smc.vnet.net>

```On Feb 9, 8:43 pm, rob <r... at piovere.com> wrote:
> I've managed to get this code working but I'm stumped on a
> good way to refer to the entries in the data when plotting.
> The only thing I can get to work is to refer to the first of
> each pair as Part[data[[i]],1] and the second as
> Part[data[[i]],2].
>
> And more humiliating, the second one I have to spell out
> twice. I tried all kinds of substitutions but failed. I know
> you gurus here know how to make this code look better and
> run more quickly. Thanks for your time.
>
> =CE=B1=100;(* decay parameter*)
>
> (* first parameter is pulse amplitude, second is time of
> occurrence - later to follow Poisson *)
>
> data=Table[Random[],{40},{2}];
>
> li=Length[data];
>
> Plot[Sum[
>          Part[data[[i]],1]  UnitStep[t-Part[data[[i]],2]]
>          Exp[-=CE=B1 (t-Part[data[[i]],2])],  {i,li}
>          ]
>    ,{t,0,1}]

a = 100;
SetRandom; data = Table[Random[],{40},{2}];
li = Length[data];
Timing@Plot[Sum[Part[data[[i]],1] UnitStep[t-Part[data[[i]],2]] *
Exp[-a (t-Part[data[[i]],2])], {i,li}], {t,0,1}]

{0.39 Second,-Graphics-}

Timing[{x,y} = Transpose@data;
Plot[x.(UnitStep@# Exp[-a #]&)[t-y], {t,0,1}]]

{0.17 Second,-Graphics-]}

```

• Prev by Date: Re: RandomArray from user defined distribution?
• Next by Date: system of equations