# How to create a matrix of complex numbers in python using numpy ?

Published: November 15, 2019

Examples of how to create a matrix of complex numbers in python using numpy:

### Create a matrix of random numbers

````>>> Z = np.array([[1+2j,1+3j],[5+6j,3+8j]])`
`>>> Z`
`array([[ 1.+2.j,  1.+3.j],`
`       [ 5.+6.j,  3.+8.j]])`
```

### Create a matrix of random numbers with 0+0j

````>>> import numpy as np`
`>>> Z = np.zeros(10, dtype=complex)`
`>>> Z`
`array([ 0.+0.j,  0.+0.j,  0.+0.j,  0.+0.j,  0.+0.j,  0.+0.j,  0.+0.j,`
`        0.+0.j,  0.+0.j,  0.+0.j])`
```

Another example

````>>> Z = np.zeros((2,2), dtype=complex)`
`>>> Z`
`array([[ 0.+0.j,  0.+0.j],`
`       [ 0.+0.j,  0.+0.j]])`
`>>>`
```

### Create a matrix of random complex numbers

````>>> Z = np.random.random(10) + np.random.random(10) * 1j`
`>>> Z`
`array([ 0.07062625+0.88227272j,  0.34682234+0.65946885j,`
`        0.92763215+0.86887474j,  0.86426062+0.73231969j,`
`        0.58372574+0.1017348j ,  0.72396286+0.92159865j,`
`        0.27617746+0.96721269j,  0.22302559+0.09493447j,`
`        0.49912649+0.03699016j,  0.06242473+0.3835314j ])`
```