How to write a function of x in a function?
5 ビュー (過去 30 日間)
古いコメントを表示
Angel Hiram Torres Mota
2020 年 3 月 8 日
コメント済み: Angel Hiram Torres Mota
2020 年 3 月 8 日
Im just getting started in Matlab and I cant figure this out
I want to write a function of x and then the value of x inside a function
For example a = Evaluate((x^2)+1, 2)
And I want it to give me the answer. Which should be 5.
function [a] = Evaluate(f(x),x)
end
Thanks!
0 件のコメント
採用された回答
Walter Roberson
2020 年 3 月 8 日
function a = Evaluate(f, x)
a = f(x);
end
Which might be called like
Evaluate(@(x) (x^2)+1, 2)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!