np.meshgrid()

import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
m, n = (5, 3)
x = np.linspace(0, 1, m)
y = np.linspace(0, 1, n)
X, Y = np.meshgrid(x,y)
x
out:
array([ 0. , 0.25, 0.5 , 0.75, 1. ])
y
out:
array([ 0. , 0.5, 1. ])
X
out:
array([[ 0. , 0.25, 0.5 , 0.75, 1. ],
[ 0. , 0.25, 0.5 , 0.75, 1. ],
[ 0. , 0.25, 0.5 , 0.75, 1. ]])
Y
out:
array([[ 0. , 0. , 0. , 0. , 0. ],
[ 0.5, 0.5, 0.5, 0.5, 0.5],
[ 1. , 1. , 1. , 1. , 1. ]])

猜你喜欢

转载自blog.csdn.net/weixin_38246633/article/details/80318539
np