|
From: Sasha <nd...@ma...> - 2006-02-17 03:16:00
|
You should make t and x the same type: either add dtype=3D'f' to arange or change dtype=3D'f' to dtype=3D'd' in zeros. On 2/16/06, Brian Blais <bb...@br...> wrote: > Hello, > > In my attempt to learn python, migrating from matlab, I have the followin= g problem. > Here is what I want to do, (with the wrong syntax): > > from numpy import * > > t=3Darange(0,20,.1) > x=3Dzeros(len(t),'f') > > idx=3Dwhere(t>5) > tau=3D5 > x[idx]=3Dexp(-t[idx]/tau) # <---this line is wrong (gives a TypeError) > > #------------------ > > what is the best way to replace the wrong line with something that works:= replace all > of the values of x at the indices idx with exp(-t/tau) for values of t at= indices idx? > > I do this all the time in matlab scripts, but I don't know that the pytho= nic > preferred method is. > > > > thanks, > > bb > > > -- > ----------------- > > bb...@br... > http://web.bryant.edu/~bblais > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep through log fi= les > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D103432&bid=3D230486&dat= =3D121642 > _______________________________________________ > Numpy-discussion mailing list > Num...@li... > https://lists.sourceforge.net/lists/listinfo/numpy-discussion > |