Is it wrong to use eval() to read input function?
10 views (last 30 days)
Show older comments
Sergio Luis López Verbel
on 8 Sep 2020
Commented: Sergio Luis López Verbel
on 8 Sep 2020
I want to have a program that prompts the users for an equation and solves it with solve().
syms vrb
vname = input('Input variable name: ','s');
str = input('Equation: ','s');
eqn = eval(str);
solu = solve(eqn,vrb);
fprintf('%s is equal to %d.\n',vname,solu)
I also want to expand the program to solving multivariate equations but I feel that the use of eval() might complicate its efficiency to begin with.
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Symbolic Math Toolbox 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!