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!