How to evaluate a user input function at a given point?
3 ビュー (過去 30 日間)
古いコメントを表示
I'm unsure how to evaluate a given function at a given point X. Hypothetically, the user can input any function using any letter as a desired variable. How can I evaluate the function at the initial point given. I was thinking I could use the syms command. However, I'm unsure of what letter variable they would use. For instance, if the function was x+1 vs y+1, how can I ensure that the "initialX" is evaluated in place of x or y in the given function?
function y = randFunc(initialX, func)
y = func(initialX);
display(y);
0 件のコメント
採用された回答
Matt J
2016 年 2 月 15 日
編集済み: Matt J
2016 年 2 月 15 日
3 件のコメント
Walter Roberson
2016 年 2 月 15 日
In this case if func is given in the form of a symbolic expression, then use matlabFunction() to turn it into a function handle.
その他の回答 (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!