How can you make an input to a symbolic variable?
1 次查看(过去 30 天)
显示 更早的评论
varprompt='Enter Variable (space-separated):';
var=inputdlg(varprompt);
syms(sym(string(var)));
eqprompt='Enter Equation (from highest to lowest degree):';
equation=inputdlg(eqprompt);
k=diff(equation)
I dont know what to do. How do you make the program solve the equation? Im having trouble turning the var input to a symbolic variable so that i can use it to solve the equation.
0 个评论
采纳的回答
madhan ravi
2020-10-27
equation = {'x^2 + x'};
diff(str2sym(equation))
equation = {'x^2 + y'};
eq = str2sym(equation);
syms(symvar(eq))
diff(str2sym(equation), x)
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!