transform to input to symbol
이전 댓글 표시
Dear all
how can i creat a function which take any desired variable like x or y or z and transform it to a symbol. i mean the function take the x and give back to symbol x.
thanks alot
답변 (1개)
madhan ravi
2019년 4월 2일
syms(sym('x')) % works only for scalar variables , bearing in mind this is only used for symbolic calculations.
댓글 수: 6
saeed rezaei
2019년 4월 2일
편집: saeed rezaei
2019년 4월 2일
madhan ravi
2019년 4월 2일
saeed?? Upload the function.
saeed rezaei
2019년 4월 2일
madhan ravi
2019년 4월 2일
편집: madhan ravi
2019년 4월 2일
eq=input('Enter the equation:','s') % Type x^2+x-5
n=2;
eqn = str2func(['@(x)',eq]);
eqn(n)
Note: Remove clc and clear all inside your function.
saeed rezaei
2019년 4월 2일
madhan ravi
2019년 4월 2일
eq=input('Enter the equation:','s') % Type x^2+x-5
n=2;
Result = saeed(eq,n)
function Result=saeed(eq,n)
eqn = str2func(['@(x)',eq]);
Result=eqn(n);
end
카테고리
도움말 센터 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!