微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在python和matlab中使用相同的一维数组作为一阶贝塞尔函数的输入,为什么我有不同的结果?

如何解决在python和matlab中使用相同的一维数组作为一阶贝塞尔函数的输入,为什么我有不同的结果?

我正在将代码从 Matlab 翻译成 Python。在Python和Matlab中使用相同的一维数组作为一阶贝塞尔函数的输入时,为什么我得到不同的结果?

假设 T 是我输入的数组,在 Matlab 中它是 besselj(1,T),在 Python 中它是 scipy.special.jv(1,T)

这是我的代码

wave0=5000
pixelscale=4e-4
abe = np.zeros((6,1))
psfsize=4191
diam = 2
centr = 0

temx = np.linspace(-1 * pixelscale * math.floor(psfsize/2),pixelscale * math.floor(psfsize/2),psfsize)
[meshtheta,meshphi] = np.meshgrid(temx,np.transpose(temx))
R_pup = np.sqrt(meshphi**2 + meshtheta**2)
teltheta = (R_pup) * np.pi * diam * (wave0 * 1e-10) / 206265

while teltheta.any() == 0:
    teltheta=1e-9

T=teltheta

plt.figure()
plt.imshow(jv(1,T),cmap='hot')
plt.show()

这样我就得到了 Python 中贝塞尔函数(一阶)的图像矩阵。后来我使用Python中的图像矩阵来减少Matlab中的结果,得到如下结果:

enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。