在这个上下文中,np是numpy。
z_mesh是形状为41*401的数组。
我需要20*200形状的dz_theta_mat和dz_gamma_mat,方法是从2*i,2*j+2th元素中减去2*i,2*j个元素,从2*i+2,2*jth元素中减去2*i,2*j个元素。
我的尝试没有给出列表所需的形状。
如何修改才能得到需要的结果?
print np.shape(z_mesh)
dz_gamma_mat = [z_mesh[2*i,2*j+2]-z_mesh[2*i,2*j] for i,j in itertools.product(range(20),range(199))]
print np.shape(fish_dz_gamma_mat)
dz_theta_mat = [z_mesh[2*i+2,2*j]-z_mesh[2*i,2*j] for i, j in itertools.product(range(19),range(200))]
print np.shape(fish_dz_theta_mat)
(41, 401)
(3980,)
(3800,)https://stackoverflow.com/questions/44312006
复制相似问题