How can I rearrange an equation with only one variable?

6 ビュー (過去 30 日間)
Troy Walton
Troy Walton 2018 年 9 月 27 日
回答済み: Walter Roberson 2018 年 9 月 27 日
How can I rearrange an equation like x^3+2*x^2+3*x-2=0 to a form set equal to an order of x such as x=(1/3)*(-x^3-2*x^2+2) in MATLAB?

回答 (2 件)

Bish Erbas
Bish Erbas 2018 年 9 月 27 日
Something like this?
syms x
eqn = (x^3+2*x^2+3*x-2 == 0);
  2 件のコメント
Star Strider
Star Strider 2018 年 9 月 27 日
syms x
Eq = x^3+2*x^2+3*x-2;
[Cfs,Trm] = coeffs(Eq,x)
Cfs =
[ 1, 2, 3, -2]
Trm =
[ x^3, x^2, x, 1]


Walter Roberson
Walter Roberson 2018 年 9 月 27 日
Use coeffs() with the two-output form, probably with the 'all' option. Variable to take it with respect to can be found by symvar(). Check the entry corresponding to the variable to power 1, which will be the second-last entry of the 'all' output.
Now subtract the term (coefficient times x) from the original equation, take the negative, and divide by the coefficient of x.
You will need to decide how you want to proceed if the coefficient associated with variable^1 is 0.




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by