python - 在python和matlab中使用相同的一维数组作为一阶贝塞尔函数的输入,为什么我有不同的结果?
问题描述
我正在将代码从 Matlab 翻译成 Python。在 Python 和 Matlab 中使用相同的一维数组作为一阶 Bessel 函数的输入时,为什么会得到不同的结果?
假设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 中得到了 Bessel 函数(一阶)的图像矩阵。后来我在 Python 中使用图像矩阵来减少 Matlab 中的结果,得到的结果如下:
解决方案
推荐阅读
- google-cloud-kms - 关于解开 KMS 加密密钥的 404 错误
- javascript - Webpack splitChunks 如何为每个 npm 包获取一个块(该块应该包含每个包的依赖项)
- java - 如果信号量锁获取/tryAcquire 失败,如何让 Java 线程执行不同的任务而不是阻塞?
- python-3.x - Pandas 导入 DataFrame 与整个库 - 速度和内存问题
- c - 无法在 Visual Studio 代码中构建 C 代码
- java - 按字母顺序排列的链表排序
- mysql - 避免mysql内部连接结果中的冗余行
- list - set_facts 与 dict 作为循环的参数
- robotframework - 分配给运行关键字 If 中的变量
- audio - Google Cloud Storage:M4A 音频文件:使用 gsutil 上传时无法在控制台中播放