numpy 2: 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. ]])
阅读更多

没有更多推荐了,返回首页