How solve a poly?
1 view (last 30 days)
Show older comments
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
0 Comments
Answers (2)
Star Strider
on 26 Feb 2016
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 Comments
Star Strider
on 26 Feb 2016
Edited: Star Strider
on 26 Feb 2016
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
on 26 Feb 2016
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
on 26 Feb 2016
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
0 Comments
See Also
Categories
Find more on Assumptions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!