小编Swa*_*aha的帖子

如何在 Python 中求解非线性三角方程组(MATLAB 可以轻松求解)

我正在尝试用 Python 求解非线性三角方程组。我尝试了以下方法:

from sympy import symbols,solve,sin,cos,pi, Eq

measurements = [(5.71403,0.347064), (4.28889, -0.396854), (5.78091, -7.29133e-05), 
(2.06098, 0.380579), (8.13321, 0.272391), (8.23589, -0.304111), (6.53473, 0.265354), (1.6023, 
0.131908)]

f, a, phi = symbols('f a phi')
eq1 = Eq(a*sin((2.0*pi*f*measurements[0][0])+phi) - measurements[0][1])
eq2 = Eq(a*sin((2.0*pi*f*measurements[4][0])+phi) - measurements[4][1])
eq3 = Eq(a*sin((2.0*pi*f*measurements[6][0])+phi) - measurements[6][1])
solve((eq1,eq2,eq3), (a, f, phi))
Run Code Online (Sandbox Code Playgroud)

Python 需要花很长时间来尝试求解方程。但是,MATLAB 可以立即完成。

有什么问题?

python numpy sympy scipy

1
推荐指数
1
解决办法
767
查看次数

标签 统计

numpy ×1

python ×1

scipy ×1

sympy ×1