python numpy.meshgrid() 函数的用法(快速生成坐标矩阵)

it2022-05-05  135

示例1:

x = np.array([0, 1, 2]) y = np.array([0, 1]) X, Y = np.meshgrid(x, y) print(X) print(Y)

结果:

[[0 1 2] [0 1 2]] [[0 0 0] [1 1 1]]

示例2:

x = np.linspace(0,60,3) y = np.linspace(0,40,2) X,Y = np.meshgrid(x, y) print(X) print(Y) [[ 0. 30. 60.] [ 0. 30. 60.]] [[ 0. 0. 0.] [40. 40. 40.]]

引用


最新回复(0)