numpy-meshgrid函数理解

经常遇到np.meshgrid,但是一直没太能理解

该函数输入一些一维向量x1,x2,…,xn
返回X1,X2,…,Xn,它们形状为(len(x1),len(x2),…,len(xn)),在index='ij’的情况下
In the 2-D case with inputs of length M and N, the outputs are of shape (N, M) for ‘xy’ indexing and (M, N) for ‘ij’ indexing. In the 3-D case with inputs of length M, N and P, outputs are of shape (N, M, P) for ‘xy’ indexing and (M, N, P) for ‘ij’ indexing.
在2D和3D的情况下稍有不同
X1,X2…,Xn的元素只与对应的xi有关,只是在哪个维度填充有讲究

For vectors x1, x2,…, ‘xn’ with lengths Ni=len(xi) , return (N1, N2, N3,…Nn) shaped arrays if indexing=’ij’ or (N2, N1, N3,…Nn) shaped arrays if indexing=’xy’ with the elements of xi repeated to fill the matrix along the first dimension for x1, the second for x2 and so on.
官方解释,返回的向量shape,向量的内容要用原始向量来填补,则先在对于维度先拷贝一份原始数组,其它维度都是该数组的重复

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值