Numeric and matlab

Bas wegwerp at gmail.com
Mon Feb 6 04:13:38 EST 2006


Hi,

I am also considering a switch from Matlab to NumPy/SciPy at some
point.

Note that in the last version of Matlab (7?) you don't have to use
'find', but you now can 'conditional arrays'  as an index, so instead
of
  idx=find(a>5);
  a(idx)=6;
you can do:
  cond=a>5;
  a(cond) = 6;
or even shorter
  a(a>5) = 6;

Does someone know if the same trick is possible in NumPy?

Cheers,
Bas




More information about the Python-list mailing list