# “Repmat” function in Numpy/Scipy?

I’m such a Matlab user. I just want to repeat an array or matrix X times, which I can do easily in Matlab using ‘repmat’. I’m sure this is super easy, and I’m just not seeing something obvious. Any tips? Is it something like concatenating copies of an array with itself? vstack?

…

Hey – I just found what I was looking for: I can do what I need to do here using the ’tile’ function in numpy. It works like this:

`from numpy import *`

```
```

`x = array([1,2]) # create a simple array`

bigx = tile(x,(2,1))

And the output is:

`array([[1,2],`

[1,2]])

Awesome! Now I can get rid of those pesky nested loops!

Also something interesting that I just discovered while messing with this in iPython: even if ‘x’ in this example is not created as an array (say it’s a list or a tuple) – it doesn’t matter – numpy still understands it, and then outputs an array object! Amazing. 🙂