필터 지우기
필터 지우기

How can I rearrange an equation with only one variable?

조회 수: 2 (최근 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);
pretty(isolate(eqn,3*x)/3)
  댓글 수: 2
Troy Walton
Troy Walton 2018년 9월 27일
Not exactly. I'm looking for a way to isolate x from x^(any power!=1), but the m file is set for the equation to be user input. So the equation could be anything with only one independent variable. For more context, this is for a part of a fixed point method simplified to having only one variable, so at this point I'm trying to take f(x) and create a g(x) s.t. g(x)=x
Star Strider
Star Strider 2018년 9월 27일
Perhaps:
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.

카테고리

Help CenterFile Exchange에서 Formula Manipulation and Simplification에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by