Python Equivalent of Matlab's size()

Nick Perkins nperkins7 at home.com
Tue Jun 5 22:58:46 EDT 2001


"Prem Rachakonda" <prem at engr.uky.edu> wrote in message
news:e56d8da7.0106051355.5dc362c7 at posting.google.com...
> Hi,
>    What is the Python equivalent of Matlab's size() function. I need
> to find the confirm the size of an reshaped array.
>
> Prem.


Are you using the Numeric module?

>>> import Numeric
>>> a = Numeric.array(range(12))
>>> a
array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11])
>>> a.shape
(12,)
>>> a.shape=(3,4)
>>> a
array([[ 0,  1,  2,  3],
       [ 4,  5,  6,  7],
       [ 8,  9, 10, 11]])
>>> a.shape
(3, 4)







More information about the Python-list mailing list