Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (47.6k points)

Is there an equivalent to the MATLAB

size()

command in Numpy?

In MATLAB,

>>> a = zeros(2,5) 

0 0 0 0 0 0 0 0 0 0 

>>> size(a) 

2 5

In Python,

>>> a = zeros((2,5)) 

>>> array([[ 0., 0., 0., 0., 0.], 

[ 0., 0., 0., 0., 0.]]) 

>>> ?????

1 Answer

0 votes
by (106k points)

To calculate the size of NumPy array you can use the "shape" in NumPy, and can be requested via the .shape attribute:

>>> a = zeros((2, 5)) 

>>> a.shape 

(2, 5)

Related questions

0 votes
1 answer
0 votes
1 answer
asked Sep 27, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer
0 votes
1 answer

Browse Categories

...