What is the equivalent of MATLAB's repmat in NumPy

后端 未结 7 1534
心在旅途
心在旅途 2020-11-29 18:43

I would like to execute the equivalent of the following MATLAB code using NumPy: repmat([1; 1], [1 1 1]). How would I accomplish this?

7条回答
  •  离开以前
    2020-11-29 19:03

    Know both tile and repeat.

    x = numpy.arange(5)
    print numpy.tile(x, 2)
    print x.repeat(2)
    

提交回复
热议问题