How solve a poly?

3 Ansichten (letzte 30 Tage)
Rodrigo Franco
Rodrigo Franco am 26 Feb. 2016
Beantwortet: Image Analyst am 26 Feb. 2016
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

Antworten (2)

Star Strider
Star Strider am 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 Kommentare
Star Strider
Star Strider am 26 Feb. 2016
Bearbeitet: Star Strider am 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
Star Strider am 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)

Melden Sie sich an, um zu kommentieren.


Image Analyst
Image Analyst am 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

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by