Python Forum

Full Version: y according to x1, x2
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I used this code to obtain all the possibility of value between( -3 and 3 )for x1 and x2:

import numpy as np
import math
x1 = np.arange(-3.0, 3.0,0.1) 
x2 = np.arange(-3.0, 3.0,0.1)
X = np.array ([x1,x2]). T
My problem I don't obtain all the possibility in the space : for example [x1,x2]=[1 ,2]
or [x1,x2]= [2 ,1] .....

Please who have any idea to correct this.
Look at itertools.product. That will give you all the combinations. You can then zip the output to transpose it into the x1 and x2 columns.