Create function handle from function file
7 ビュー (過去 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!