String to Sym deprecated
1 view (last 30 days)
Show older comments
Dear all,
I have a huge code using strings to build sym expressions, and I would like to publish this code on the Matlab networ. Unfortunately, since an update, I experience problems. To simplify in a short example, I wrote the following and I wanted to know what's wrong with the simple code :
>> syms a;
>> b=sym('a+1')
I obtain the following warning :
-----
Warning: Support of character vectors that are not valid variable names or define a number
will be removed in a future release. To create symbolic expressions, first create symbolic
variables and then use operations on them.
> In sym>convertExpression (line 1559)
In sym>convertChar (line 1464)
In sym>tomupad (line 1216)
In sym (line 179)
-----
I see that people use simengine :
>> evalin(symengine,'a+1')
This works without warning. But for the following expression :
>> evalin(symengine,'[0,0;0,0]')
I obtain an error :
------
Error using symengine
Invalid input. ']' is expected.
Error in mupadengine/evalin (line 111)
res = mupadmex(statement,output_type{:});
-----
What's wrong ? What alternative may I use to continue using strings to build symbolic expressions ?
Regards,
Mike
0 Comments
Answers (1)
Karan Gill
on 13 Feb 2017
As the warning says, please don't use string input. Is this helpful?
syms a
b = sym(a+1)
If you store strings, then use "eval".
syms a
b = eval('a+1')
b =
a + 1
Could you provide more information on why you use strings to store symbolic expressions?
Thanks, Karan (Symbolic doc)
1 Comment
Sanket Karnik
on 15 Feb 2017
I understand that you want to know how to get rid of 'Warning: Support of character vectors that are not valid variable names or define a number will be removed in a future release. To create symbolic expressions, first create symbolic variables and then use operations on them. ' warning. To add to the Karan's comment please refer to the documentation of the sym, at top of the documentation you can see the example of the similar warning and how to fix it. I hope this helps you in resolving the issue.
Regards,
Sanket
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!