sym error in define functions

11 visualizaciones (últimos 30 días)
Rastgo Mhamad
Rastgo Mhamad el 4 de Mzo. de 2021
Comentada: Walter Roberson el 4 de Mzo. de 2021
when i define function by sym , exmp:
f = sym('4*xˆ3+4*xˆ2-7*x+2');
it show me this
Error using sym>convertChar (line 1448)
Character vectors and strings in the first argument can only specify a variable or number. To
evaluate character vectors and strings representing symbolic expressions, use 'str2sym'.
Error in sym>tomupad (line 1214)
S = convertChar(x);
Error in sym (line 211)
S.s = tomupad(x);
what is the solution. thanks.....

Respuesta aceptada

Steven Lord
Steven Lord el 4 de Mzo. de 2021
As the error message states, "To evaluate character vectors and strings representing symbolic expressions, use 'str2sym'."
So use str2sym. Alternately define x to be a symbolic variable then build the symbolic expression using it.
syms x
y = x.^2 + 2*x -3
y = 
  2 comentarios
Rastgo Mhamad
Rastgo Mhamad el 4 de Mzo. de 2021
thank you so much.
Walter Roberson
Walter Roberson el 4 de Mzo. de 2021
Using sym('4*xˆ3+4*xˆ2-7*x+2') was permitted before R2018a if I recall correctly (might have been R2018a that was the last release.)

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by