How can I use the input command to ask the user to enter an equation?
1 次查看(过去 30 天)
显示 更早的评论
I want to write a command which will allow the user to enter an equation in terms of x and also, ask the user to enter the value of the variable x.
0 个评论
采纳的回答
Ameer Hamza
2020-4-18
See this example
str = 'sin(x)*exp(x)'; % input function in term of x
f = str2func(['@(x)' str]); % convert to MATLAB function
x = 2; % evaluate at x=2
f(2) % evaluate the function
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!