Create function handle from function file
9 次查看(过去 30 天)
显示 更早的评论
Is it possible to create a function handle from function file ? In other words, create a function_handle object @foo from file foo.m.
0 个评论
采纳的回答
Star Strider
2020-3-10
编辑:Steven Lord
2020-3-10
Yes!
In some instances, that is necessary in order to evaluate the function.
Example —
function y = f(x)
y = x.^2 - 2;
end
fz = fzero(@f,1)
produces:
fz =
1.4142
[SL: typo fix]
8 个评论
tommsch
2020-11-30
@Steven Lord
The function for which you want to create the function handle must be in scope when the function handle is created. It does not need to be in scope when the function handle is evaluated.
When the function is shadowed by another function later on, the function handle may point to another function.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Performance and Memory 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!