Is there a multi-dimensional version of arange/linspace in numpy?

前端 未结 9 1508
有刺的猬
有刺的猬 2020-12-02 08:31

I would like a list of 2d NumPy arrays (x,y) , where each x is in {-5, -4.5, -4, -3.5, ..., 3.5, 4, 4.5, 5} and the same for y.

I could do

x = np.ar         


        
9条回答
  •  日久生厌
    2020-12-02 09:21

    We can use arrange function as:

    z1 = np.array([np.array(np.arange(1,5)),np.array(np.arange(1,5))])
    print(z1)
    o/p=> [[1 2 3 4]
           [1 2 3 4]]
    

提交回复
热议问题