Matlab - Evaluate Function from String [duplicate]
问题 This question already has an answer here : How can I create function pointers from a string input in MATLAB? (1 answer) Closed 2 years ago . 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