How solve a poly?

1 次查看(过去 30 天)
Rodrigo Franco
Rodrigo Franco 2016-2-26
Hi, i'm with difficults in solver poly in matlab, for example:
syms x;
fx = x^5 + 2*x^4 + 7*x^3 + 9*x^2 + 8*x - 6
x = 0;
ans = -6

回答(2 个)

Star Strider
Star Strider 2016-2-26
If you want the roots of the polynomial, use the vpasolve function:
syms x
fx = x^5 + 2*x^4 + 7*x^3 + 9*x^2 + 8*x - 6
fx_roots = vpasolve(fx == 0)
fx_roots =
0.44238493070265787278357718736358
- 0.051527066306945417459920042848339 - 2.2932784088204198253304516514344i
- 1.1696653990443835189318685508335 - 1.0997720388236547546840787557965i
- 0.051527066306945417459920042848339 + 2.2932784088204198253304516514344i
- 1.1696653990443835189318685508335 + 1.0997720388236547546840787557965i
  2 个评论
Star Strider
Star Strider 2016-2-26
编辑:Star Strider 2016-2-26
Rodrigo Franco’s ‘Answer’ moved here:
Nooo.... I don't want the roots of the function, i want just send values in poly
For example:
syms x
fx = x^5 + 2*x^4 + 7*x^3 + 9*x^2 + 8*x - 6
x = 0;
ans = -6
x = 1
ans = .....
Star Strider
Star Strider 2016-2-26
O.K. If you have R2012a or later, you can create a symbolic funcition:
syms x
f(x) = x^5 + 2*x^4 + 7*x^3 + 9*x^2 + 8*x - 6
f0 = f(0)
f1 = f(1)
f0 =
-6
f1 =
21
Otherwise, use the subs function to get the same result:
fx = x^5 + 2*x^4 + 7*x^3 + 9*x^2 + 8*x - 6
f1 = subs(fx, x, 1)

请先登录,再进行评论。


Image Analyst
Image Analyst 2016-2-26
You can get rid of the "syms" line and just define x before fx:
x = 0;
fx = x^5 + 2*x^4 + 7*x^3 + 9*x^2 + 8*x - 6

类别

Help CenterFile Exchange 中查找有关 Assumptions 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by