在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 (将#修改为@)