What happened to eval function?
2 次查看(过去 30 天)
显示 更早的评论
I am using R2022a, and the eval function is giving me an error,
eval(['4 + 5'])
Unrecognized function or variable 'eval'.
Ignore "ans = 9" in my question, since that's what happened when I ran it online in R2022a; that is the expected behavior but not what I'm getting on my computer.
Any idea what's going on? I tried restarting Matlab and the error persisted.
采纳的回答
Walter Roberson
2022-6-16
I think maybe you could get this error under the odd conditions:
- you are inside a function
- you assign to a variable named eval
- you run a script
- the script clears the variable named eval
- after the script you try to use eval
I am not positive this will generate that exact error, but MATLAB is allowed to lose track of functions and variables if you do this or you assign to a name inside the script when the name matches a function name
3 个评论
Walter Roberson
2022-6-18
I have to admit that using "syms" is very convenient, especially for creating symbolic functions or arrays of symbols. syms in that form is implemented as assignin('caller') which is a case of creating variables based upon string.
更多回答(0 个)
另请参阅
类别
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!