How solve a poly?

1 visualización (últimos 30 días)
Rodrigo Franco
Rodrigo Franco el 26 de Feb. de 2016
Respondida: Image Analyst el 26 de Feb. de 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

Respuestas (2)

Star Strider
Star Strider el 26 de Feb. de 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 comentarios
Star Strider
Star Strider el 26 de Feb. de 2016
Editada: Star Strider el 26 de Feb. de 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 el 26 de Feb. de 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)

Iniciar sesión para comentar.


Image Analyst
Image Analyst el 26 de Feb. de 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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by