Re: calculating on matrix indices

2006-02-17 Thread Paul Probert
Brian Blais wrote: > Hello, > > In my attempt to learn python, migrating from matlab, I have the following > problem. > Here is what I want to do, (with the wrong syntax): > > from numpy import * > > t=arange(0,20,.1) > x=zeros(len(t),'f') > > idx=(t>5) > tau=5 > x[idx]=exp(-t[idx]/tau) # <-

Re: calculating on matrix indices

2006-02-17 Thread Brian Blais
Robert Kern wrote: > The traceback tells you exactly what's wrong: > > In [7]: x[idx] = exp(-t[idx]/tau) > --- > exceptions.TypeError Traceback (most recent > call > last) > yes, I saw that,

Re: calculating on matrix indices

2006-02-17 Thread Robert Kern
Brian Blais wrote: > Hello, > > In my attempt to learn python, migrating from matlab, I have the following > problem. > Here is what I want to do, (with the wrong syntax): > > from numpy import * > > t=arange(0,20,.1) > x=zeros(len(t),'f') Also, you probably don't want to be using literal typ

Re: calculating on matrix indices

2006-02-17 Thread Robert Kern
Brian Blais wrote: > Hello, > > In my attempt to learn python, migrating from matlab, I have the following > problem. > Here is what I want to do, (with the wrong syntax): > > from numpy import * > > t=arange(0,20,.1) > x=zeros(len(t),'f') > > idx=(t>5) > tau=5 > x[idx]=exp(-t[idx]/tau) # <-

Re: calculating on matrix indices

2006-02-17 Thread Kirk McDonald
Brian Blais wrote: > Hello, > > In my attempt to learn python, migrating from matlab, I have the > following problem. Here is what I want to do, (with the wrong syntax): > > from numpy import * > > t=arange(0,20,.1) > x=zeros(len(t),'f') > > idx=(t>5) > tau=5 > x[idx]=exp(-t[idx]/tau) # <---t

Re: calculating on matrix indices

2006-02-16 Thread Robert Kern
Brian Blais wrote: > Colin J. Williams wrote: > >> Brian Blais wrote: >> >>> In my attempt to learn python, migrating from matlab, I have the >>> following problem. Here is what I want to do, (with the wrong syntax): >>> >>> from numpy import * >>> >>> t=arange(0,20,.1) >>> x=zeros(len(t),'f') >>>

Re: calculating on matrix indices

2006-02-16 Thread Brian Blais
Colin J. Williams wrote: > Brian Blais wrote: >> In my attempt to learn python, migrating from matlab, I have the >> following problem. Here is what I want to do, (with the wrong syntax): >> >> from numpy import * >> >> t=arange(0,20,.1) >> x=zeros(len(t),'f') >> >> idx=(t>5)# <---

Re: [Numpy-discussion] Re: calculating on matrix indices

2006-02-16 Thread Bill Baxter
Howdy,On 2/17/06, Brian Blais <[EMAIL PROTECTED]> wrote: Colin J. Williams wrote:> Brian Blais wrote:>> In my attempt to learn python, migrating from matlab, I have the>> following problem. Here is what I want to do, (with the wrong syntax):>> >> from numpy import * t=arange(0,20,.1)>> x=zeros(

Re: calculating on matrix indices

2006-02-16 Thread Travis E. Oliphant
Brian Blais wrote: > Hello, > > In my attempt to learn python, migrating from matlab, I have the following > problem. > Here is what I want to do, (with the wrong syntax): > > from numpy import * > > t=arange(0,20,.1) > x=zeros(len(t),'f') > > idx=(t>5) > tau=5 > x[idx]=exp(-t[idx]/tau) # <-

Re: calculating on matrix indices

2006-02-16 Thread Colin J. Williams
Brian Blais wrote: > Hello, > > In my attempt to learn python, migrating from matlab, I have the > following problem. Here is what I want to do, (with the wrong syntax): > > from numpy import * > > t=arange(0,20,.1) > x=zeros(len(t),'f') > > idx=(t>5)# <---this produces a Boole

calculating on matrix indices

2006-02-16 Thread Brian Blais
Hello, In my attempt to learn python, migrating from matlab, I have the following problem. Here is what I want to do, (with the wrong syntax): from numpy import * t=arange(0,20,.1) x=zeros(len(t),'f') idx=(t>5) tau=5 x[idx]=exp(-t[idx]/tau) # <---this line is wrong (gives a TypeError) #