简体   繁体   中英

SymPy - Solving for variable in equation

Is it possible to define an equation and solve a variable in that equation?

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

i_out = D_PWM * (A/Rsense)

print i_out

solve(i_out, Rsense)

Result:

A*D_PWM/Rsense
[]

i_out has not been declared as a symbol.

>>> 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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM