Matlab - Evaluate Function from String [duplicate]

房东的猫 提交于 2019-12-12 04:44:09

问题


Some Matlab functions handle string functions representation as f='a^x^b+sin(c*x)+d' --i.e. Curve Fitting, Optimization, etc.--

Suppose the variables a,b,c,d and x are given. Is there any function for evaluating f from its string representation?


回答1:


You can do eval(f), but using eval is really discouraged https://uk.mathworks.com/help/matlab/matlab_prog/string-evaluation.html



来源:https://stackoverflow.com/questions/46178175/matlab-evaluate-function-from-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!