SymPy - 求解方程中的变量

时间:2016-10-14 16:52:05

标签: python sympy

是否可以定义方程并求解该方程中的变量?

D_PWM, Rsense, A = symbols('D_PWM, Rsense, A')

i_out = D_PWM * (A/Rsense)

print i_out

solve(i_out, Rsense)

结果:

A*D_PWM/Rsense
[]

1 个答案:

答案 0 :(得分:9)

i_out 尚未声明为符号。

>>> from sympy import *
>>> var('D_PWM, Rsense, A i_out')
(D_PWM, Rsense, A, i_out)
>>> eqn=Eq(i_out,D_PWM * (A/Rsense))
>>> solve(eqn,Rsense)
[A*D_PWM/i_out]