How can i call the value of another variable defined or solved above for solving another equation?

10 ビュー (過去 30 日間)
Right now, I have a 6-order polynomial expression, it has only one variable.
I want to be able to call values of some variable defined or obtained above, and solve the polynomial equation for different values of the expression.
I used the following code, but it does not work.
p(1)=1,p(2)=2,p(3)=3,p(4)=4,p(5)=5,p(6)=6,p(7)=7;
f(1)=1,f(2)=2,f(3)=3,f(4)=4,f(5)=5,f(6)=6,f(7)=7;
solve('p(1)*(x.^6)+p(2)*(x.^5)+p(3)*(x.^4)+p(4)*(x.^3)+p(5)*(x.^2)+p(6)*x+ p(7)=f(1)');
what mistake have I made? or in what ways can achieve this purpose?
Thank you.
  1 件のコメント
zy
zy 2014 年 7 月 23 日
I hope to be able to get the numeric roots of the equation, not the expression form.

サインインしてコメントする。

採用された回答

Roger Stafford
Roger Stafford 2014 年 7 月 23 日
編集済み: Roger Stafford 2014 年 7 月 23 日
Instead of using 'solve' try using 'roots' for numerical solutions. It will be much faster.
Also, 'solve' will in general be unable to find symbolic solutions for sixth order polynomials.
  1 件のコメント
zy
zy 2014 年 7 月 24 日
Thank you very much, 'roots' works.
Since it is a 6 order polynomial equation, there may be up to 6 roots including real roots and complex roots.
Can I do something to filter or pick up only real roots?

サインインしてコメントする。

その他の回答 (1 件)

Matz Johansson Bergström
Matz Johansson Bergström 2014 年 7 月 23 日
編集済み: Matz Johansson Bergström 2014 年 7 月 23 日
Try
syms x
p = 1:7;
f = 1:7;
solve(p(1)*x^6+p(2)*x^5+p(3)*x^4+p(4)*x^3+p(5)*x^2+p(6)*x+p(7)==f(1), x)

カテゴリ

Help Center および File ExchangePolynomials についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by