[SciPy-user] NaN in matrices

Travis Oliphant oliphant at ee.byu.edu
Wed Mar 9 23:19:46 EST 2005


Tim McKenna wrote:

> Hi,
> I've gotten used to using NaN in matrices (mostly for missing data 
> values) in Matlab and Octave.
> there you can go:
> a = [ 1 2 ; NaN 4] no problem
>
> i tried
> >>> a = mat('[1 3 5; 2 5 3; NaN 5 7]')
> among other things and scipy balks
>
> Is there a way to use NaN in matrices/arrays
>
nans can be used in matrices, nan is the correct spelling in scipy.  
But, it looks like the string-handling of mat does not handle them 
well.  This is a bug.

You can create a matrix with nans using

a = mat([[1,3,5],[2,5,3],[nan,5,7]])

-Travis





More information about the SciPy-User mailing list