How to convert a string to a symbol ?
Mostrar comentarios más antiguos
Hello guys ,
I just wanted to convert this string :
'x & 1'
to a symbol ,i tried to use sym() function ,which seemed not to work ,obviously ,it doesn't seem to symbolize some characters ,like ampersands ,asterisks ,arithmetic operators , etc...
So any help how can i convert the above string to a symbol ?!
Much Regards
Respuesta aceptada
Más respuestas (3)
Ahmed A. Selman
el 25 de Mzo. de 2013
sym and syms are used to declare symbolic variables, see:
Please specify your idea about (converting a string to symbol in Matlab), do you mean (string to a variable), as in
x=1
y=-90
if so, Matlab variables must not contain special characters as (~!@#$%^&*)..etc. Or you mean text properties in figures? Then Refer to http://www.mathworks.com/help/matlab/ref/text_props.html.
If it was translating a string into an expression, see the functions
regexptranslate
regexp
5 comentarios
Jacky
el 25 de Mzo. de 2013
Walter Roberson
el 25 de Mzo. de 2013
What result are you aiming for, and what are you getting instead?
Jacky
el 25 de Mzo. de 2013
Walter Roberson
el 25 de Mzo. de 2013
When you use
sym('x & 1')
what result are you seeing?
Question: would x&1 be the formula or the limit? Were you meaning
sym('x < 1')
?
Jacky
el 25 de Mzo. de 2013
Walter Roberson
el 25 de Mzo. de 2013
1 voto
MuPAD does not use & for logical conjugation. See http://www.mathworks.com/help/symbolic/logical-operations-1.html
Jacky
el 28 de Mzo. de 2013
1 voto
Categorías
Más información sobre Operations on Strings en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!