How to pass a function handle if some input argument is fixed?
11 次查看(过去 30 天)
显示 更早的评论
I have to pass a function handle of a single variable function, but I want to use a function with multiple input arguments, and fix some of them. For example I want to pass the handle of single variable function: normpdf(x,10,2).
0 个评论
回答(1 个)
Walter Roberson
2017-5-20
For example,
target = 0.16193;
myfun = @(x) normpdf(x, 10, 2) - target;
fzero(myfun, rand) %example of needing to pass a function of one variable
2 个评论
Stephen23
2017-5-22
"is it possible to do this in one line?"
Why not try it yourself?:
fzero(@(x)normpdf(x,10,2)-target, rand)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!