How can you make an input to a symbolic variable?

조회 수: 3 (최근 30일)
goodwin membreve
goodwin membreve 2020년 10월 27일
답변: madhan ravi 2020년 10월 27일
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.

채택된 답변

madhan ravi
madhan ravi 2020년 10월 27일
equation = {'x^2 + x'};
diff(str2sym(equation))
ans = 
2x+1
equation = {'x^2 + y'};
eq = str2sym(equation);
syms(symvar(eq))
diff(str2sym(equation), x)
ans = 
2x

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by