What is the benefit of using a function handle?
3 ビュー (過去 30 日間)
古いコメントを表示
y = @(x) x; vs y=x... why would I use one over the other? Any benefit to the function handle?
0 件のコメント
採用された回答
per isakson
2015 年 1 月 24 日
IMO: the main benefit is that it can be passed to other functions as an argument.
0 件のコメント
その他の回答 (2 件)
Zoltán Csáti
2015 年 1 月 24 日
The two statements are not the same. The first one defines a function while the second one is an equality. The two identical forms are
y = @(x) x;
and
function y = some_function(x)
y = x;
end
0 件のコメント
Kai
2015 年 1 月 24 日
The function handle is for example helpful for integration. Maybe you can have a look at fplot, which makes use of function handles.
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!